Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: aec158242b87 ("lockd: set fl_owner when unlocking files")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Link: https://bugzilla.kernel.org/show_bug.cgi?id=216582
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>

authored by

Trond Myklebust and committed by
Chuck Lever
18ebd35b d7064eaf

+10 -7
+10 -7
fs/lockd/svcsubs.c
··· 176 176 } 177 177 } 178 178 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) 180 180 { 181 181 struct file_lock lock; 182 182 ··· 184 184 lock.fl_type = F_UNLCK; 185 185 lock.fl_start = 0; 186 186 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)) 190 193 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)) 193 196 goto out_err; 194 197 return 0; 195 198 out_err: ··· 229 226 if (match(lockhost, host)) { 230 227 231 228 spin_unlock(&flctx->flc_lock); 232 - if (nlm_unlock_files(file, fl->fl_owner)) 229 + if (nlm_unlock_files(file, fl)) 233 230 return 1; 234 231 goto again; 235 232 }