Bug 1221008

Summary: libgfapi: Segfault seen when glfs_*() methods are invoked with invalid glfd
Product: [Community] GlusterFS Reporter: Prashanth Pai <ppai>
Component: libgfapiAssignee: Prashanth Pai <ppai>
Status: CLOSED CURRENTRELEASE QA Contact: Sudhir D <sdharane>
Severity: low Docs Contact:
Priority: high    
Version: mainlineCC: bugs, gluster-bugs
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: glusterfs-3.8rc2 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1240920 (view as bug list) Environment:
Last Closed: 2016-06-16 13:00:40 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:
Bug Depends On:    
Bug Blocks: 1240920    

Description Prashanth Pai 2015-05-13 06:21:42 UTC
Description of problem:
When glfs_* methods operating on glfd are invoked after calling
glfs_close(), the program segfaults inside __GLFS_ENTRY_VALIDATE_FD
trying to deference glfd->fd->inode which is invalid.

Version-Release number of selected component (if applicable):
Master branch of glusterfs


Steps to Reproduce (Example using python binding)
#!/usr/bin/env python

from glusterfs import gfapi
import os

v = gfapi.Volume("pp", "real")
v.mount()
f = v.open("file", os.O_RDONLY) # assuming file exists
f.close()
f.read() # This will segfault


Actual results:
Segfault with code dump

Expected results:
Gracefully exit with errno set to EBADF

Comment 1 Anand Avati 2015-05-13 06:25:55 UTC
REVIEW: http://review.gluster.org/10759 (libgfapi: Gracefully exit when glfd is invalid) posted (#3) for review on master by Prashanth Pai (ppai)

Comment 2 Anand Avati 2015-05-13 06:46:40 UTC
REVIEW: http://review.gluster.org/10759 (libgfapi: Gracefully exit when glfd is invalid) posted (#4) for review on master by Prashanth Pai (ppai)

Comment 3 Anand Avati 2015-05-14 04:32:43 UTC
REVIEW: http://review.gluster.org/10759 (libgfapi: Gracefully exit when glfd is invalid) posted (#5) for review on master by Prashanth Pai (ppai)

Comment 4 Anand Avati 2015-07-07 15:06:46 UTC
COMMIT: http://review.gluster.org/10759 committed in master by Shyamsundar Ranganathan (srangana) 
------
commit afa793ff16b349989ca7c958466eae15d2d003f9
Author: Prashanth Pai <ppai>
Date:   Tue May 12 16:36:55 2015 +0530

    libgfapi: Gracefully exit when glfd is invalid
    
    When glfs_* methods operating on glfd are invoked after calling
    glfs_close(), the program segfaults inside __GLFS_ENTRY_VALIDATE_FD
    trying to deference glfd->fd->inode which is invalid.
    
    Also, returning EBADF seemed more specific than EINVAL.
    
    BUG: 1221008
    Change-Id: I13a92dca52da9a300252b69e026581b3a9e931fd
    Signed-off-by: Prashanth Pai <ppai>
    Reviewed-on: http://review.gluster.org/10759
    Tested-by: Gluster Build System <jenkins.com>
    Reviewed-by: Shyamsundar Ranganathan <srangana>

Comment 5 Anand Avati 2015-07-08 06:39:13 UTC
REVIEW: http://review.gluster.org/11571 (libgfapi: Gracefully exit when glfd is invalid) posted (#1) for review on release-3.7 by Prashanth Pai (ppai)

Comment 6 Niels de Vos 2016-06-16 13:00:40 UTC
This bug is getting closed because a release has been made available that should address the reported issue. In case the problem is still not fixed with glusterfs-3.8.0, please open a new bug report.

glusterfs-3.8.0 has been announced on the Gluster mailinglists [1], packages for several distributions should become available in the near future. Keep an eye on the Gluster Users mailinglist [2] and the update infrastructure for your distribution.

[1] http://blog.gluster.org/2016/06/glusterfs-3-8-released/
[2] http://thread.gmane.org/gmane.comp.file-systems.gluster.user