Skip to content

Commit 6e7f90d

Browse files
J. Bruce Fieldschucklever
authored andcommitted
lockd: fix server crash on reboot of client holding lock
I thought I was iterating over the array when actually the iteration is over the values contained in the array? Ugh, keep it simple. Symptoms were a null deference in vfs_lock_file() when an NFSv3 client that previously held a lock came back up and sent a notify. Reported-by: Jonathan Woithe <jwoithe@just42.net> Fixes: 7f024fc ("Keep read and write fds with each nlm_file") Signed-off-by: J. Bruce Fields <bfields@redhat.com> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
1 parent 1672086 commit 6e7f90d

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

fs/lockd/svcsubs.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -179,19 +179,20 @@ nlm_delete_file(struct nlm_file *file)
179179
static int nlm_unlock_files(struct nlm_file *file)
180180
{
181181
struct file_lock lock;
182-
struct file *f;
183182

184183
lock.fl_type = F_UNLCK;
185184
lock.fl_start = 0;
186185
lock.fl_end = OFFSET_MAX;
187-
for (f = file->f_file[0]; f <= file->f_file[1]; f++) {
188-
if (f && vfs_lock_file(f, F_SETLK, &lock, NULL) < 0) {
189-
pr_warn("lockd: unlock failure in %s:%d\n",
190-
__FILE__, __LINE__);
191-
return 1;
192-
}
193-
}
186+
if (file->f_file[O_RDONLY] &&
187+
vfs_lock_file(file->f_file[O_RDONLY], F_SETLK, &lock, NULL))
188+
goto out_err;
189+
if (file->f_file[O_WRONLY] &&
190+
vfs_lock_file(file->f_file[O_WRONLY], F_SETLK, &lock, NULL))
191+
goto out_err;
194192
return 0;
193+
out_err:
194+
pr_warn("lockd: unlock failure in %s:%d\n", __FILE__, __LINE__);
195+
return 1;
195196
}
196197

197198
/*

0 commit comments

Comments
 (0)