Skip to content

Commit 18ebd35

Browse files
Trond MyklebustChuck Lever
authored andcommitted
lockd: set other missing fields when unlocking files
vfs_lock_file() expects the struct file_lock to be fully initialised by the caller. Re-exported NFSv3 has been seen to Oops if the fl_file field is NULL. Fixes: aec1582 ("lockd: set fl_owner when unlocking files") Signed-off-by: Trond Myklebust <[email protected]> Reviewed-by: Jeff Layton <[email protected]> Link: https://bugzilla.kernel.org/show_bug.cgi?id=216582 Signed-off-by: Chuck Lever <[email protected]>
1 parent d7064ea commit 18ebd35

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

fs/lockd/svcsubs.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -176,20 +176,23 @@ nlm_delete_file(struct nlm_file *file)
176176
}
177177
}
178178

179-
static int nlm_unlock_files(struct nlm_file *file, fl_owner_t owner)
179+
static int nlm_unlock_files(struct nlm_file *file, const struct file_lock *fl)
180180
{
181181
struct file_lock lock;
182182

183183
locks_init_lock(&lock);
184184
lock.fl_type = F_UNLCK;
185185
lock.fl_start = 0;
186186
lock.fl_end = OFFSET_MAX;
187-
lock.fl_owner = owner;
188-
if (file->f_file[O_RDONLY] &&
189-
vfs_lock_file(file->f_file[O_RDONLY], F_SETLK, &lock, NULL))
187+
lock.fl_owner = fl->fl_owner;
188+
lock.fl_pid = fl->fl_pid;
189+
lock.fl_flags = FL_POSIX;
190+
191+
lock.fl_file = file->f_file[O_RDONLY];
192+
if (lock.fl_file && vfs_lock_file(lock.fl_file, F_SETLK, &lock, NULL))
190193
goto out_err;
191-
if (file->f_file[O_WRONLY] &&
192-
vfs_lock_file(file->f_file[O_WRONLY], F_SETLK, &lock, NULL))
194+
lock.fl_file = file->f_file[O_WRONLY];
195+
if (lock.fl_file && vfs_lock_file(lock.fl_file, F_SETLK, &lock, NULL))
193196
goto out_err;
194197
return 0;
195198
out_err:
@@ -226,7 +229,7 @@ nlm_traverse_locks(struct nlm_host *host, struct nlm_file *file,
226229
if (match(lockhost, host)) {
227230

228231
spin_unlock(&flctx->flc_lock);
229-
if (nlm_unlock_files(file, fl->fl_owner))
232+
if (nlm_unlock_files(file, fl))
230233
return 1;
231234
goto again;
232235
}

0 commit comments

Comments
 (0)