Bug 1240920 - libgfapi: Segfault seen when glfs_*() methods are invoked with invalid glfd
Summary: libgfapi: Segfault seen when glfs_*() methods are invoked with invalid glfd
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: GlusterFS
Classification: Community
Component: libgfapi
Version: 3.7.2
Hardware: Unspecified
OS: Unspecified
high
low
Target Milestone: ---
Assignee: Prashanth Pai
QA Contact: Prashanth Pai
URL:
Whiteboard:
: 1218535 (view as bug list)
Depends On: 1221008
Blocks: glusterfs-3.7.4 1255471 1262798
TreeView+ depends on / blocked
 
Reported: 2015-07-08 06:53 UTC by Prashanth Pai
Modified: 2015-09-14 11:47 UTC (History)
5 users (show)

Fixed In Version: glusterfs-3.7.4
Doc Type: Bug Fix
Doc Text:
Clone Of: 1221008
Environment:
Last Closed: 2015-09-09 09:38:20 UTC
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Embargoed:


Attachments (Terms of Use)

Description Prashanth Pai 2015-07-08 06:53:42 UTC
+++ This bug was initially created as a clone of Bug #1221008 +++

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

--- Additional comment from Anand Avati on 2015-05-13 02:25:55 EDT ---

REVIEW: http://review.gluster.org/10759 (libgfapi: Gracefully exit when glfd is invalid) posted (#3) for review on master by Prashanth Pai (ppai)

--- Additional comment from Anand Avati on 2015-05-13 02:46:40 EDT ---

REVIEW: http://review.gluster.org/10759 (libgfapi: Gracefully exit when glfd is invalid) posted (#4) for review on master by Prashanth Pai (ppai)

--- Additional comment from Anand Avati on 2015-05-14 00:32:43 EDT ---

REVIEW: http://review.gluster.org/10759 (libgfapi: Gracefully exit when glfd is invalid) posted (#5) for review on master by Prashanth Pai (ppai)

--- Additional comment from Anand Avati on 2015-07-07 11:06:46 EDT ---

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>

--- Additional comment from Anand Avati on 2015-07-08 02:39:13 EDT ---

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 1 Anand Avati 2015-07-08 06:57:57 UTC
REVIEW: http://review.gluster.org/11571 (libgfapi: Gracefully exit when glfd is invalid) posted (#2) for review on release-3.7 by Prashanth Pai (ppai)

Comment 2 Anand Avati 2015-07-09 04:07:54 UTC
REVIEW: http://review.gluster.org/11571 (libgfapi: Gracefully exit when glfd is invalid) posted (#3) for review on release-3.7 by Prashanth Pai (ppai)

Comment 3 Kaushal 2015-07-30 13:17:56 UTC
This bug could not be fixed in time for glusterfs-3.7.3. This is now being tracked for being fixed in glusterfs-3.7.4.

Comment 4 Niels de Vos 2015-08-25 11:24:08 UTC
*** Bug 1218535 has been marked as a duplicate of this bug. ***

Comment 5 Anand Avati 2015-08-25 11:42:23 UTC
REVIEW: http://review.gluster.org/11571 (libgfapi: Gracefully exit when glfd is invalid) posted (#4) for review on release-3.7 by Niels de Vos (ndevos)

Comment 6 Anand Avati 2015-08-26 16:17:27 UTC
COMMIT: http://review.gluster.org/11571 committed in release-3.7 by Niels de Vos (ndevos) 
------
commit 6c4096f5e6a6d0f2b21cb4b2bea098b6f4eebbed
Author: Prashanth Pai <ppai>
Date:   Tue May 12 16:36:55 2015 +0530

    libgfapi: Gracefully exit when glfd is invalid
    
    This is a backport of: http://review.gluster.org/10759
    
    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: 1240920
    Change-Id: I13a92dca52da9a300252b69e026581b3a9e931fd
    Signed-off-by: Prashanth Pai <ppai>
    Reviewed-on-master: http://review.gluster.org/10759
    Tested-by: Gluster Build System <jenkins.com>
    Reviewed-by: Shyamsundar Ranganathan <srangana>
    Reviewed-on: http://review.gluster.org/11571
    Reviewed-by: Niels de Vos <ndevos>
    Reviewed-by: Humble Devassy Chirammal <humble.devassy>
    Reviewed-by: bipin kunal <bkunal>
    Tested-by: NetBSD Build System <jenkins.org>

Comment 7 Kaushal 2015-09-09 09:38:20 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.7.4, please open a new bug report.

glusterfs-3.7.4 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://thread.gmane.org/gmane.comp.file-systems.gluster.devel/12496
[2] http://thread.gmane.org/gmane.comp.file-systems.gluster.user


Note You need to log in before you can comment on or make changes to this bug.