linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] lockd: Fix invalid lockowner cast after vfs_test_lock
@ 2021-07-25 12:49 Benjamin Coddington
  2021-07-26 13:33 ` [PATCH V2] " Benjamin Coddington
  0 siblings, 1 reply; 3+ messages in thread
From: Benjamin Coddington @ 2021-07-25 12:49 UTC (permalink / raw)
  To: bfields, chuck.lever; +Cc: linux-nfs

After calling vfs_test_lock() the pointer to a conflicting lock can be
returned, and that lock is not garunteed to 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>
---
 fs/lockd/svclock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/lockd/svclock.c b/fs/lockd/svclock.c
index 61d3cc2283dc..498cb70c2c0d 100644
--- a/fs/lockd/svclock.c
+++ b/fs/lockd/svclock.c
@@ -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;
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH V2] lockd: Fix invalid lockowner cast after vfs_test_lock
  2021-07-25 12:49 [PATCH] lockd: Fix invalid lockowner cast after vfs_test_lock Benjamin Coddington
@ 2021-07-26 13:33 ` Benjamin Coddington
  2021-07-26 14:42   ` Chuck Lever III
  0 siblings, 1 reply; 3+ messages in thread
From: Benjamin Coddington @ 2021-07-26 13:33 UTC (permalink / raw)
  To: bfields, chuck.lever; +Cc: linux-nfs

V2: fix typos in patch header

8<-------------------------------------------------------

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>
---
 fs/lockd/svclock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/lockd/svclock.c b/fs/lockd/svclock.c
index 61d3cc2283dc..498cb70c2c0d 100644
--- a/fs/lockd/svclock.c
+++ b/fs/lockd/svclock.c
@@ -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;
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH V2] lockd: Fix invalid lockowner cast after vfs_test_lock
  2021-07-26 13:33 ` [PATCH V2] " Benjamin Coddington
@ 2021-07-26 14:42   ` Chuck Lever III
  0 siblings, 0 replies; 3+ messages in thread
From: Chuck Lever III @ 2021-07-26 14:42 UTC (permalink / raw)
  To: Benjamin Coddington; +Cc: Bruce Fields, Linux NFS Mailing List

Hi Ben-

> On Jul 26, 2021, at 9:33 AM, Benjamin Coddington <bcodding@redhat.com> wrote:
> 
> V2: fix typos in patch header
> 
> 8<-------------------------------------------------------
> 
> 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>

I've added this change provisionally to

https://git.kernel.org/pub/scm/linux/kernel/git/cel/linux.git/log/?h=for-next


> ---
> fs/lockd/svclock.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/lockd/svclock.c b/fs/lockd/svclock.c
> index 61d3cc2283dc..498cb70c2c0d 100644
> --- a/fs/lockd/svclock.c
> +++ b/fs/lockd/svclock.c
> @@ -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;
> -- 
> 2.30.2
> 

--
Chuck Lever




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-07-26 14:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-25 12:49 [PATCH] lockd: Fix invalid lockowner cast after vfs_test_lock Benjamin Coddington
2021-07-26 13:33 ` [PATCH V2] " Benjamin Coddington
2021-07-26 14:42   ` Chuck Lever III

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).