Bug 1312200 - Handle negative fcntl flock->l_len values
Summary: Handle negative fcntl flock->l_len values
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: GlusterFS
Classification: Community
Component: locks
Version: 3.7.9
Hardware: All
OS: All
unspecified
urgent
Target Milestone: ---
Assignee: Soumya Koduri
QA Contact:
URL:
Whiteboard:
Depends On: 1241104
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-02-26 05:12 UTC by Soumya Koduri
Modified: 2016-04-19 07:22 UTC (History)
2 users (show)

Fixed In Version: glusterfs-3.7.9
Doc Type: Bug Fix
Doc Text:
Clone Of: 1241104
Environment:
Last Closed: 2016-04-19 07:22:46 UTC
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:


Attachments (Terms of Use)

Description Soumya Koduri 2016-02-26 05:12:39 UTC
+++ This bug was initially created as a clone of Bug #1241104 +++

Description of problem:

As per 'man 3 fcntl', 
       If  l_len  is positive, the area affected shall start at l_start and end at l_start+l_len−1.  If l_len is negative, the area affected shall start at l_start+l_len and end at l_start−1.  Locks may start and extend beyond the current end  of a file, but shall not extend before the beginning of the file. A lock shall be set to extend to the largest possible value of the file offset for that file by setting l_len to 0. If such a lock also has l_start set to 0 and

But in the current lock handling,

int
pl_lk (call_frame_t *frame, xlator_t *this,
       fd_t *fd, int32_t cmd, struct gf_flock *flock, dict_t *xdata)
{
......
.........

        if ((flock->l_start < 0) || (flock->l_len < 0)) {
                op_ret = -1;
                op_errno = EINVAL;
                goto unwind;
        }
.......
.......
}

We invariably return error if l_len is found to be negative. It needs to be fixed.

--- Additional comment from Anand Avati on 2015-07-10 03:22:26 EDT ---

REVIEW: http://review.gluster.org/11613 (locks: Handle negative values for flock->l_len) posted (#1) for review on master by soumya k (skoduri@redhat.com)

--- Additional comment from Anand Avati on 2015-07-10 07:22:41 EDT ---

REVIEW: http://review.gluster.org/11613 (locks: Handle negative values for flock->l_len) posted (#2) for review on master by soumya k (skoduri@redhat.com)

--- Additional comment from Vijay Bellur on 2016-02-23 04:53:04 EST ---

REVIEW: http://review.gluster.org/11613 (locks: Handle negative values for flock->l_len) posted (#3) for review on master by soumya k (skoduri@redhat.com)

--- Additional comment from Vijay Bellur on 2016-02-25 04:35:29 EST ---

COMMIT: http://review.gluster.org/11613 committed in master by Raghavendra G (rgowdapp@redhat.com) 
------
commit e410c3a0c97a7bfe109badba5b6a5dd094016995
Author: Soumya Koduri <skoduri@redhat.com>
Date:   Fri Jul 10 12:40:24 2015 +0530

    locks: Handle negative values for flock->l_len
    
    As per 'man 3 fcntl',
    "If l_len is positive, the area affected shall start at
    l_start and end at l_start+l_len−1. If l_len is negative,
    the area affected shall start at l_start+l_len and end at
    l_start−1. Locks may start and extend beyond the current
    end of a file, but shall not extend before the beginning
    of the file."
    
    Currently we return EINVAL if l_len is found to be negative.
    Fixed the same as mentioned in the man page.
    
    Change-Id: I493ce202c543185fc4ae7266d1aaf9d7e2a66991
    BUG: 1241104
    Signed-off-by: Soumya Koduri <skoduri@redhat.com>
    Reviewed-on: http://review.gluster.org/11613
    NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
    Smoke: Gluster Build System <jenkins@build.gluster.com>
    Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
    CentOS-regression: Gluster Build System <jenkins@build.gluster.com>
    Reviewed-by: Niels de Vos <ndevos@redhat.com>
    Reviewed-by: Raghavendra G <rgowdapp@redhat.com>

Comment 1 Vijay Bellur 2016-02-26 05:18:48 UTC
REVIEW: http://review.gluster.org/13526 (locks: Handle negative values for flock->l_len) posted (#1) for review on release-3.7 by soumya k (skoduri@redhat.com)

Comment 2 Vijay Bellur 2016-02-28 10:37:50 UTC
REVIEW: http://review.gluster.org/13526 (locks: Handle negative values for flock->l_len) posted (#2) for review on release-3.7 by soumya k (skoduri@redhat.com)

Comment 3 Vijay Bellur 2016-02-28 20:14:23 UTC
COMMIT: http://review.gluster.org/13526 committed in release-3.7 by Kaleb KEITHLEY (kkeithle@redhat.com) 
------
commit 7e65e1b5a9a7bdaa7ca28bc5c1773bc5472f19af
Author: Soumya Koduri <skoduri@redhat.com>
Date:   Fri Jul 10 12:40:24 2015 +0530

    locks: Handle negative values for flock->l_len
    
    As per 'man 3 fcntl',
    "If l_len is positive, the area affected shall start at
    l_start and end at l_start+l_len−1. If l_len is negative,
    the area affected shall start at l_start+l_len and end at
    l_start−1. Locks may start and extend beyond the current
    end of a file, but shall not extend before the beginning
    of the file."
    
    Currently we return EINVAL if l_len is found to be negative.
    Fixed the same as mentioned in the man page.
    
    This is backport of the below patch
        - http://review.gluster.org/11613
    
    Change-Id: I493ce202c543185fc4ae7266d1aaf9d7e2a66991
    BUG: 1312200
    Signed-off-by: Soumya Koduri <skoduri@redhat.com>
    Reviewed-on: http://review.gluster.org/11613
    Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
    Reviewed-by: Niels de Vos <ndevos@redhat.com>
    Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
    Reviewed-on: http://review.gluster.org/13526
    Smoke: Gluster Build System <jenkins@build.gluster.com>
    NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
    CentOS-regression: Gluster Build System <jenkins@build.gluster.com>

Comment 4 Kaushal 2016-04-19 07:22:46 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.9, please open a new bug report.

glusterfs-3.7.9 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] https://www.gluster.org/pipermail/gluster-users/2016-March/025922.html
[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.