Whamcloud - gitweb
LU-5817 clio: Do not allow group locks with gid 0 59/12459/4
authorPatrick Farrell <paf@cray.com>
Mon, 10 Nov 2014 07:39:29 +0000 (01:39 -0600)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 19 Nov 2014 19:16:25 +0000 (19:16 +0000)
When a group lock with GID=0 is released (put_grouplock is
called), an assertion in cl_put_grouplock is hit.

We should not allow group lock requests with GID=0, instead
we should return -EINVAL.

Also fix random_group_id so it never returns gid==0.

Change-Id: I56e58791742809da5353a4d8dfbf3b80a22f3814
Signed-off-by: Patrick Farrell <paf@cray.com>
Reviewed-on: http://review.whamcloud.com/12459
Tested-by: Jenkins
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: frank zago <fzago@cray.com>
lustre/llite/file.c
lustre/utils/lfs.c

index 655ac1a..612312c 100644 (file)
@@ -1639,6 +1639,11 @@ ll_get_grouplock(struct inode *inode, struct file *file, unsigned long arg)
         int                     rc;
         ENTRY;
 
+       if (arg == 0) {
+               CWARN("group id for group lock must not be 0\n");
+               RETURN(-EINVAL);
+       }
+
         if (ll_file_nolock(file))
                 RETURN(-EOPNOTSUPP);
 
index fa23bf1..47860f7 100644 (file)
@@ -368,6 +368,7 @@ static int random_group_id(int *gid)
                goto out;
        }
 
+retry:
        rc = read(fd, gid, sz);
        if (rc < sz) {
                rc = -errno;
@@ -376,6 +377,10 @@ static int random_group_id(int *gid)
                goto out;
        }
 
+       /* gids must be non-zero */
+       if (*gid == 0)
+               goto retry;
+
 out:
        if (fd >= 0)
                close(fd);