From: Murphy Zhou <jencce.kernel@gmail.com>
To: Jeff Layton <jlayton@kernel.org>
Cc: Murphy Zhou <jencce.kernel@gmail.com>,
linux-cifs@vger.kernel.org, Steve French <smfrench@gmail.com>
Subject: Re: [PATCH] CIFS: unlock file across process
Date: Fri, 14 Feb 2020 22:28:36 +0800 [thread overview]
Message-ID: <20200214142836.2rhitx3jfa5nxada@xzhoux.usersys.redhat.com> (raw)
In-Reply-To: <370134c148a5f4d12df31a3a9020b66ef316a004.camel@kernel.org>
On Fri, Feb 14, 2020 at 07:26:46AM -0500, Jeff Layton wrote:
> On Fri, 2020-02-14 at 12:35 +0800, Murphy Zhou wrote:
> > Now child can't unlock the same file that has been locked by
> > parent. Fix this by not skipping unlock if requesting from
> > different process.
> >
> > Patch tested by LTP and xfstests using samba server.
> >
> > Signed-off-by: Murphy Zhou <jencce.kernel@gmail.com>
> > ---
> > fs/cifs/smb2file.c | 2 --
> > 1 file changed, 2 deletions(-)
> >
> > diff --git a/fs/cifs/smb2file.c b/fs/cifs/smb2file.c
> > index afe1f03aabe3..b5bca0e13d51 100644
> > --- a/fs/cifs/smb2file.c
> > +++ b/fs/cifs/smb2file.c
> > @@ -151,8 +151,6 @@ smb2_unlock_range(struct cifsFileInfo *cfile, struct file_lock *flock,
> > (flock->fl_start + length) <
> > (li->offset + li->length))
> > continue;
> > - if (current->tgid != li->pid)
> > - continue;
> > if (cinode->can_cache_brlcks) {
> > /*
> > * We can cache brlock requests - simply remove a lock
>
> I'm not as familiar with this code as I once was, but...
>
> From fork(2) manpage:
>
> * The child does not inherit process-associated record locks from its
> parent (fcntl(2)). (On the other hand, it does inherit fcntl(2)
> open file description locks and flock(2) locks from its parent.)
>
> It looks like cifs_setlk calls mand_unlock_range, and that gets called
> from both fcntl and flock codepaths.
>
> So, I'm not sure about just removing this. It seems like the pid check
> is probably correct for traditional posix locks, but probably not for
> OFD and flock locks? What ensures that completely unrelated tasks can't
> unlock your locks?
You are right Jeff. Just removing this is not right. We need to handle
at least 3 types of locks: posix, OFD and flock.
Thanks very much for reviewing! I'll try to sort this out.
> --
> Jeff Layton <jlayton@kernel.org>
>
next prev parent reply other threads:[~2020-02-14 14:28 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-14 4:35 [PATCH] CIFS: unlock file across process Murphy Zhou
2020-02-14 5:32 ` Steve French
2020-02-14 12:26 ` Jeff Layton
2020-02-14 14:28 ` Murphy Zhou [this message]
2020-02-14 19:03 ` Pavel Shilovsky
2020-02-19 2:10 ` Murphy Zhou
2020-02-24 19:39 ` Pavel Shilovsky
2020-02-25 5:15 ` Murphy Zhou
2020-02-25 19:21 ` Pavel Shilovsky
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=20200214142836.2rhitx3jfa5nxada@xzhoux.usersys.redhat.com \
--to=jencce.kernel@gmail.com \
--cc=jlayton@kernel.org \
--cc=linux-cifs@vger.kernel.org \
--cc=smfrench@gmail.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;
as well as URLs for NNTP newsgroup(s).