[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YgvS1XOJMn5CjQyw@zeniv-ca.linux.org.uk>
Date: Tue, 15 Feb 2022 16:20:37 +0000
From: Al Viro <viro@...iv.linux.org.uk>
To: Matthew Wilcox <willy@...radead.org>
Cc: Miklos Szeredi <miklos@...redi.hu>,
Xavier Roche <xavier.roche@...olia.com>,
linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org,
"Aneesh Kumar K.V" <aneesh.kumar@...ux.vnet.ibm.com>
Subject: Re: race between vfs_rename and do_linkat (mv and link)
On Tue, Feb 15, 2022 at 04:17:11PM +0000, Matthew Wilcox wrote:
> On Tue, Feb 15, 2022 at 04:06:06PM +0000, Al Viro wrote:
> > On Tue, Feb 15, 2022 at 01:37:40PM +0000, Al Viro wrote:
> > > On Tue, Feb 15, 2022 at 10:56:29AM +0100, Miklos Szeredi wrote:
> > >
> > > > Doing "lock_rename() + lookup last components" would fix this race.
> >
> > "Fucking ugly" is inadequate for the likely results of that approach.
> > It's guaranteed to be a source of headache for pretty much ever after.
> >
> > Does POSIX actually make any promises in that area? That would affect
> > how high a cost we ought to pay for that - I agree that it would be nicer
> > to have atomicity from userland point of view, but there's a difference
> > between hard bug and QoI issue.
>
> As I understand the original report, it relies on us hitting the nlink ==
> 0 at exactly the wrong moment. Can't we just restart the entire path
> resolution if we find a target with nlink == 0? Sure, it's a lot of
> extra work, but you've got to be trying hard to hit it in the first place.
touch /tmp/blah
exec 42</tmp/blah
rm /tmp/blah
... call linkat() with AT_SYMLINK_FOLLOW and /proc/self/fd/42 for source
Your variant will loop indefinitely on that...
Powered by blists - more mailing lists