]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
lockd: Fix invalid lockowner cast after vfs_test_lock
authorBenjamin Coddington <bcodding@redhat.com>
Mon, 26 Jul 2021 13:33:28 +0000 (09:33 -0400)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 15 Oct 2021 09:27:14 +0000 (11:27 +0200)
BugLink: https://bugs.launchpad.net/bugs/1946788
[ Upstream commit cd2d644ddba183ec7b451b7c20d5c7cc06fcf0d7 ]

After calling vfs_test_lock() the pointer to a conflicting lock can be
returned, and that lock is not guarunteed to be owned by nlm.  In that
case, we cannot cast it to struct nlm_lockowner.  Instead return the pid
of that conflicting lock.

Fixes: 646d73e91b42 ("lockd: Show pid of lockd for remote locks")
Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kelsey Skunberg <kelsey.skunberg@canonical.com>
fs/lockd/svclock.c

index 61d3cc2283dc844689e33ef4632eeda81a6592c5..498cb70c2c0d0d6e8c3e45166d58abd0f42ea075 100644 (file)
@@ -634,7 +634,7 @@ nlmsvc_testlock(struct svc_rqst *rqstp, struct nlm_file *file,
        conflock->caller = "somehost";  /* FIXME */
        conflock->len = strlen(conflock->caller);
        conflock->oh.len = 0;           /* don't return OH info */
-       conflock->svid = ((struct nlm_lockowner *)lock->fl.fl_owner)->pid;
+       conflock->svid = lock->fl.fl_pid;
        conflock->fl.fl_type = lock->fl.fl_type;
        conflock->fl.fl_start = lock->fl.fl_start;
        conflock->fl.fl_end = lock->fl.fl_end;