From: Jeff Layton <jlayton@kernel.org>
To: chuck.lever@oracle.com
Cc: trond.myklebust@hammerspace.com, linux-nfs@vger.kernel.org,
Trond Myklebust <trondmy@hammerspace.com>
Subject: Re: [PATCH 4/4] filelock: WARN_ON_ONCE when ->fl_file and filp don't match
Date: Fri, 11 Nov 2022 14:43:01 -0500 [thread overview]
Message-ID: <e5782930e8aea3cfbb14d47989b0556cce17f137.camel@kernel.org> (raw)
In-Reply-To: <20221111193639.346992-5-jlayton@kernel.org>
On Fri, 2022-11-11 at 14:36 -0500, Jeff Layton wrote:
> vfs_lock_file, vfs_test_lock and vfs_cancel_lock all take both a struct
> file argument and a file_lock. The file_lock has a fl_file field in it
> howevever and it _must_ match the file passed in.
>
> While most of the locks.c routines use the separately-passed file
> argument, some filesystems rely on fl_file being filled out correctly.
>
> I'm working on a patch series to remove the redundant argument from
> these routines, but for now, let's ensure that the callers always set
> this properly by issuing a WARN_ON_ONCE if they ever don't match.
>
> Cc: Chuck Lever <chuck.lever@oracle.com>
> Cc: Trond Myklebust <trondmy@hammerspace.com>
> Signed-off-by: Jeff Layton <jlayton@kernel.org>
> ---
> fs/locks.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/fs/locks.c b/fs/locks.c
> index 607f94a0e789..5876c8ff0edc 100644
> --- a/fs/locks.c
> +++ b/fs/locks.c
> @@ -2146,6 +2146,7 @@ SYSCALL_DEFINE2(flock, unsigned int, fd, unsigned int, cmd)
> */
> int vfs_test_lock(struct file *filp, struct file_lock *fl)
> {
> + WARN_ON_ONCE(filp != fl->fl_file);
> if (filp->f_op->lock)
> return filp->f_op->lock(filp, F_GETLK, fl);
> posix_test_lock(filp, fl);
> @@ -2295,6 +2296,7 @@ int fcntl_getlk(struct file *filp, unsigned int cmd, struct flock *flock)
> */
> int vfs_lock_file(struct file *filp, unsigned int cmd, struct file_lock *fl, struct file_lock *conf)
> {
> + WARN_ON_ONCE(filp != fl->fl_file);
> if (filp->f_op->lock)
> return filp->f_op->lock(filp, cmd, fl);
> else
> @@ -2663,6 +2665,7 @@ void locks_remove_file(struct file *filp)
> */
> int vfs_cancel_lock(struct file *filp, struct file_lock *fl)
> {
> + WARN_ON_ONCE(filp != fl->fl_file);
> if (filp->f_op->lock)
> return filp->f_op->lock(filp, F_CANCELLK, fl);
> return 0;
Oops, I meant to cc linux-fsdevel here too. I'll plan to do that on the
next posting (assuming that I need to do one).
Cheers,
--
Jeff Layton <jlayton@kernel.org>
next prev parent reply other threads:[~2022-11-11 19:43 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-11 19:36 [PATCH 0/4] filelock: WARN when @filp and fl_file don't match Jeff Layton
2022-11-11 19:36 ` [PATCH 1/4] lockd: set missing fl_flags field when retrieving args Jeff Layton
2022-11-11 19:36 ` [PATCH 2/4] lockd: ensure we use the correct file description when unlocking Jeff Layton
2022-11-11 19:36 ` [PATCH 3/4] lockd: fix file selection in nlmsvc_cancel_blocked Jeff Layton
2022-11-11 20:29 ` Chuck Lever III
2022-11-11 21:52 ` Jeff Layton
2022-11-14 18:38 ` Jeff Layton
2022-11-14 18:52 ` Chuck Lever III
2022-11-11 19:36 ` [PATCH 4/4] filelock: WARN_ON_ONCE when ->fl_file and filp don't match Jeff Layton
2022-11-11 19:43 ` Jeff Layton [this message]
-- strict thread matches above, loose matches on Subject: below --
2022-11-11 21:55 [PATCH 0/4] filelock: WARN when @filp and fl_file " Jeff Layton
2022-11-11 21:55 ` [PATCH 4/4] filelock: WARN_ON_ONCE when ->fl_file and filp " Jeff Layton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e5782930e8aea3cfbb14d47989b0556cce17f137.camel@kernel.org \
--to=jlayton@kernel.org \
--cc=chuck.lever@oracle.com \
--cc=linux-nfs@vger.kernel.org \
--cc=trond.myklebust@hammerspace.com \
--cc=trondmy@hammerspace.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox