Bug 1196028

Summary: libgfapi: glfs_init() hangs on pthread_cond_wait() when user is non-root
Product: [Community] GlusterFS Reporter: Prashanth Pai <ppai>
Component: libgfapiAssignee: Vijay Bellur <vbellur>
Status: CLOSED WORKSFORME QA Contact: Sudhir D <sdharane>
Severity: high Docs Contact:
Priority: high    
Version: mainlineCC: atumball, bugs, lmohanty, ndevos, srangana, vbellur
Target Milestone: ---Keywords: Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: glusterfs-6.x Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-05-07 14:48:50 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Sample code to be run as non-root none

Description Prashanth Pai 2015-02-25 06:36:06 UTC
Created attachment 994997 [details]
Sample code to be run as non-root

glfs_init() hangs on pthread_cond_wait() when user is non-root

Steps to Reproduce:
$ gcc try.c -I /usr/local/include/glusterfs/ -lgfapi -O0 -ggdb
$ ./a.out

Trace:
Program received signal SIGINT, Interrupt.
0x00007ffff68d7ca0 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
Missing separate debuginfos, use: debuginfo-install glibc-2.18-16.fc20.x86_64 keyutils-libs-1.5.9-1.fc20.x86_64 krb5-libs-1.11.5-11.fc20.x86_64 libcom_err-1.42.8-3.fc20.x86_64 libselinux-2.2.1-6.fc20.x86_64 openssl-libs-1.0.1e-41.fc20.x86_64 pcre-8.33-8.fc20.x86_64 sssd-client-1.11.7-2.fc20.x86_64 xz-libs-5.1.2-12alpha.fc20.x86_64 zlib-1.2.8-3.fc20.x86_64
(gdb) bt
#0  0x00007ffff68d7ca0 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
#1  0x00007ffff7bc6cc2 in glfs_lock (fs=0x630b80) at glfs-internal.h:214
#2  0x00007ffff7bc7fb6 in glfs_init_wait (fs=0x630b80) at glfs.c:703
#3  0x00007ffff7bc82a7 in pub_glfs_init (fs=0x630b80) at glfs.c:809
#4  0x00000000004009d3 in main (argc=1, argv=0x7fffffffdee8) at try.c:20
(gdb) 


Expected results:
Should error out gracefully

Comment 1 Niels de Vos 2015-03-03 12:38:23 UTC
The issue does not occur when the server.allow-insecure and rpc-allow-insecure options are set. Without these options, the gfapi application will not be allowed to connect from ports > 1024. Only root can bind() to ports < 1024, running a gfapi application as non-root uses ports > 1024.

Possibly http://review.gluster.org/7405 contains a way to catch the error and report the problem back to the application.

Comment 2 Prashanth Pai 2015-03-04 12:10:22 UTC
Yes Niels, that's true. I wouldn't expect a hang though. Ideally, glfs_init() should return -1 with errno set to EPERM (or something)

Comment 3 Niels de Vos 2015-03-04 22:10:37 UTC
(In reply to Prashanth Pai from comment #2)
> Yes Niels, that's true. I wouldn't expect a hang though. Ideally,
> glfs_init() should return -1 with errno set to EPERM (or something)

Yes, most definitely!

Comment 4 Amar Tumballi 2019-05-07 14:48:50 UTC
Tried glfsxmp.c as a non-user, and things are working fine with glusterfs-6.x