From a1307d41a3a6682f60c91df4b581f21fb2980265 Mon Sep 17 00:00:00 2001 From: Patrick Farrell Date: Mon, 10 Nov 2014 01:39:29 -0600 Subject: [PATCH] LU-5817 clio: Do not allow group locks with gid 0 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 Reviewed-on: http://review.whamcloud.com/12459 Tested-by: Jenkins Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: frank zago --- lustre/llite/file.c | 5 +++++ lustre/utils/lfs.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/lustre/llite/file.c b/lustre/llite/file.c index 655ac1a..612312c 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -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); diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index fa23bf1..47860f7 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -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); -- 1.8.3.1