From: Jan Kara <jack@suse.cz>
To: Christian Brauner <brauner@kernel.org>
Cc: Jan Kara <jack@suse.cz>, David Howells <dhowells@redhat.com>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Jeff Layton <jlayton@kernel.org>, Gao Xiang <xiang@kernel.org>,
Matthew Wilcox <willy@infradead.org>,
netfs@lists.linux.dev, linux-erofs@lists.ozlabs.org,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] vfs: Fix potential circular locking through setxattr() and removexattr()
Date: Tue, 23 Jul 2024 14:32:02 +0200 [thread overview]
Message-ID: <20240723123202.vu5tfzoblpib3nve@quack3> (raw)
In-Reply-To: <20240723-aberkennen-unruhen-61570127dc6e@brauner>
On Tue 23-07-24 13:11:51, Christian Brauner wrote:
> On Tue, Jul 23, 2024 at 12:45:33PM GMT, Jan Kara wrote:
> > On Tue 23-07-24 09:59:54, David Howells wrote:
> > > When using cachefiles, lockdep may emit something similar to the circular
> > > locking dependency notice below. The problem appears to stem from the
> > > following:
> > >
> > > (1) Cachefiles manipulates xattrs on the files in its cache when called
> > > from ->writepages().
> > >
> > > (2) The setxattr() and removexattr() system call handlers get the name
> > > (and value) from userspace after taking the sb_writers lock, putting
> > > accesses of the vma->vm_lock and mm->mmap_lock inside of that.
> > >
> > > (3) The afs filesystem uses a per-inode lock to prevent multiple
> > > revalidation RPCs and in writeback vs truncate to prevent parallel
> > > operations from deadlocking against the server on one side and local
> > > page locks on the other.
> > >
> > > Fix this by moving the getting of the name and value in {get,remove}xattr()
> > > outside of the sb_writers lock. This also has the minor benefits that we
> > > don't need to reget these in the event of a retry and we never try to take
> > > the sb_writers lock in the event we can't pull the name and value into the
> > > kernel.
> >
> > Well, it seems like you are trying to get rid of the dependency
> > sb_writers->mmap_sem. But there are other places where this dependency is
>
> Independent of this issue, I think that moving the retrieval of name and
> value out of the lock is a good thing. The commit message might need to
> get reworded of course.
Oh, absolutely. I think the change itself makes sense, just it will not fix
what David hopes to fix :)
Honza
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
next prev parent reply other threads:[~2024-07-23 12:32 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-23 8:59 [PATCH] vfs: Fix potential circular locking through setxattr() and removexattr() David Howells
2024-07-23 10:45 ` Jan Kara
2024-07-23 11:11 ` Christian Brauner
2024-07-23 12:32 ` Jan Kara [this message]
2024-07-23 13:57 ` David Howells
2024-07-23 15:40 ` Christian Brauner
2024-07-24 13:30 ` Jan Kara
2024-07-29 15:28 ` Christian Brauner
2024-07-31 18:16 ` Jan Kara
2024-07-31 18:27 ` Matthew Wilcox
2024-07-31 18:55 ` Jan Kara
2024-07-24 1:34 ` Dave Chinner
2024-07-24 2:42 ` Matthew Wilcox
2024-07-23 12:57 ` Jan Kara
2024-07-24 8:11 ` David Howells
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=20240723123202.vu5tfzoblpib3nve@quack3 \
--to=jack@suse.cz \
--cc=brauner@kernel.org \
--cc=dhowells@redhat.com \
--cc=jlayton@kernel.org \
--cc=linux-erofs@lists.ozlabs.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netfs@lists.linux.dev \
--cc=viro@zeniv.linux.org.uk \
--cc=willy@infradead.org \
--cc=xiang@kernel.org \
/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