Skip to content

Commit

Permalink
lockd: set fl_owner when unlocking files
Browse files Browse the repository at this point in the history
Unlocking a POSIX lock on an inode with vfs_lock_file only works if
the owner matches. Ensure we set it in the request.

Cc: J. Bruce Fields <bfields@fieldses.org>
Fixes: 7f024fc ("Keep read and write fds with each nlm_file")
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
  • Loading branch information
Jeff Layton authored and Chuck Lever committed Jul 11, 2022
1 parent 5b2f3e0 commit aec1582
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions fs/lockd/svcsubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,15 @@ nlm_delete_file(struct nlm_file *file)
}
}

static int nlm_unlock_files(struct nlm_file *file)
static int nlm_unlock_files(struct nlm_file *file, fl_owner_t owner)
{
struct file_lock lock;

locks_init_lock(&lock);
lock.fl_type = F_UNLCK;
lock.fl_start = 0;
lock.fl_end = OFFSET_MAX;
lock.fl_owner = owner;
if (file->f_file[O_RDONLY] &&
vfs_lock_file(file->f_file[O_RDONLY], F_SETLK, &lock, NULL))
goto out_err;
Expand Down Expand Up @@ -225,7 +226,7 @@ nlm_traverse_locks(struct nlm_host *host, struct nlm_file *file,
if (match(lockhost, host)) {

spin_unlock(&flctx->flc_lock);
if (nlm_unlock_files(file))
if (nlm_unlock_files(file, fl->fl_owner))
return 1;
goto again;
}
Expand Down

0 comments on commit aec1582

Please sign in to comment.