From: Miklos Szeredi <miklos@szeredi.hu>
To: Amir Goldstein <amir73il@gmail.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
Miklos Szeredi <mszeredi@redhat.com>,
Xavier Roche <xavier.roche@algolia.com>,
linux-fsdevel <linux-fsdevel@vger.kernel.org>
Subject: Re: [PATCH v2] vfs: fix link vs. rename race
Date: Tue, 13 Sep 2022 12:03:14 +0200 [thread overview]
Message-ID: <CAJfpegvw02yrWE3xWPtp7JLmbw9U236c6vqtpakUYbPH1SdHeg@mail.gmail.com> (raw)
In-Reply-To: <CAOQ4uxiz32Srdg=c7g_49TFnxT9VN-j_V9u2ZHsxU10gCDXWVA@mail.gmail.com>
On Tue, 13 Sept 2022 at 10:02, Amir Goldstein <amir73il@gmail.com> wrote:
>
> On Tue, Sep 13, 2022 at 7:38 AM Al Viro <viro@zeniv.linux.org.uk> wrote:
> >
> > On Tue, Sep 13, 2022 at 03:04:17AM +0100, Al Viro wrote:
> > > On Mon, Feb 21, 2022 at 09:20:02AM +0100, Miklos Szeredi wrote:
> > >
> > > [digging through the old piles of mail]
> > >
> > > Eyes-watering control flow in do_linkat() aside (it's bound to rot; too
> > > much of it won't get any regression testing and it's convoluted enough
> > > to break easily), the main problem I have with that is the DoS potential.
> > >
> > > You have a system-wide lock, and if it's stuck you'll get every damn
> > > rename(2) stuck as well. Sure, having it taken only upon the race
> > > with rename() (or unlink(), for that matter) make it harder to get
> > > stuck with lock held, but that'll make the problem harder to reproduce
> > > and debug...
> >
> > FWIW, how much trouble would we have if link(2) would do the following?
> >
> > find the parent of source
>
> Well, only if source is not AT_EMPTY_PATH
The problem is not AT_EMPTY_PATH, but a disconnected dentry gotten
through magic symlink. Theoretically link(2) should work for those,
but I didn't try.
>
> > lock it
> > look the child up
> > verify it's a non-directory
> > bump child's i_nlink
> > all failure exits past that point decrement child's i_nlink
>
> No need to bump i_nlink.
> Sufficient to set I_LINKABLE.
> and clean it up on failure if i_nlink > 0.
Bumping i_nlink seems hackish enough, currently all i_nlink
modification is done by filesystem code.
Setting I_LINKABLE seems safe for filesystems that have tmpfile, not otherwise.
Thanks,
Miklos
next prev parent reply other threads:[~2022-09-13 10:04 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-21 8:20 [PATCH v2] vfs: fix link vs. rename race Miklos Szeredi
2022-02-21 8:56 ` Xavier Roche
2022-09-13 2:04 ` Al Viro
2022-09-13 4:29 ` Al Viro
2022-09-13 8:02 ` Amir Goldstein
2022-09-13 10:03 ` Miklos Szeredi [this message]
2022-09-13 4:41 ` NeilBrown
2022-09-13 5:20 ` Al Viro
2022-09-13 5:40 ` Al Viro
2022-09-14 0:14 ` NeilBrown
2022-09-14 1:30 ` Al Viro
2022-09-13 23:52 ` NeilBrown
2022-09-14 0:13 ` Al Viro
2022-09-16 6:13 ` [PATCH RFC] VFS: lock source directory for link to avoid " NeilBrown
2022-09-16 6:28 ` Miklos Szeredi
2022-09-16 6:45 ` NeilBrown
2022-09-16 6:49 ` Al Viro
2022-09-16 14:32 ` Amir Goldstein
2022-09-19 8:28 ` Christian Brauner
2022-09-19 22:56 ` NeilBrown
2022-09-23 3:02 ` [VFS] 3fb4ec6faa: ltp.linkat02.fail kernel test robot
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=CAJfpegvw02yrWE3xWPtp7JLmbw9U236c6vqtpakUYbPH1SdHeg@mail.gmail.com \
--to=miklos@szeredi.hu \
--cc=amir73il@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=mszeredi@redhat.com \
--cc=viro@zeniv.linux.org.uk \
--cc=xavier.roche@algolia.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).