All of lore.kernel.org
 help / color / mirror / Atom feed
From: Amir Goldstein <amir73il@gmail.com>
To: Drew DeVault <sir@cmpwn.com>
Cc: Matthew Wilcox <willy@infradead.org>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>,
	Linux API <linux-api@vger.kernel.org>,
	Aleksa Sarai <cyphar@cyphar.com>,
	"J. Bruce Fields" <bfields@fieldses.org>,
	Steve French <smfrench@gmail.com>
Subject: Re: [RFC PATCH] fs: introduce mkdirat2 syscall for atomic mkdir
Date: Tue, 2 Mar 2021 09:13:28 +0200	[thread overview]
Message-ID: <CAOQ4uxgbt5fdx=5_QKJZm1y7hZn5-84NkBzcLWjHL3eAzdML0Q@mail.gmail.com> (raw)
In-Reply-To: <C9L7SV0Z2GZR.K2C3O186WDJ7@taiga>

On Sun, Feb 28, 2021 at 4:02 PM Drew DeVault <sir@cmpwn.com> wrote:
>
> On Sat Feb 27, 2021 at 11:03 PM EST, Matthew Wilcox wrote:
> > > 1. Program A creates a directory
> > > 2. Program A is pre-empted
> > > 3. Program B deletes the directory
> > > 4. Program A creates a file in that directory
> > > 5. RIP
> >
> > umm ... program B deletes the directory. program A opens it in order to
> > use openat(). program A gets ENOENT and exits, confused. that's the
> > race you're removing here -- and it seems fairly insignificant to me.
>
> Yes, that is the race being eliminated here. Instead of this, program A
> has an fd which holds a reference to the directory, so it just works. A
> race is a race. It's an oversight in the API.

I think you mixed in confusion with "program B deletes the directory".
That will result, as Matthew wrote in ENOENT because that dir is now
IS_DEADDIR().

I think I understand what you mean with the oversight in the API, but
the use case should involve mkdtemp(3) - make it more like tmpfile(3).
Not that *I* can think of the races this can solve, but I am pretty sure
that people with security background will be able to rationalize this.

You start your pitch by ruling out the option of openat2() with
O_CREAT | O_DIRECTORY, because you have strong emotions
against it (loathe).
I personally do not share this feeling with you, because:
1. The syscall is already used to open directories as well as files
2. The whole idea of openat2() is that you can add new behaviors
    with new open_how flags, so no existing app will be surprised from
    behavior change of  O_CREAT | O_DIRECTORY combination.

For your consideration.

Thanks,
Amir.

  parent reply	other threads:[~2021-03-02 12:06 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-28  0:25 [RFC PATCH] fs: introduce mkdirat2 syscall for atomic mkdir Drew DeVault
2021-02-28  2:13 ` Al Viro
2021-02-28  2:21   ` Drew DeVault
2021-02-28  2:58     ` Al Viro
2021-02-28 13:56       ` Drew DeVault
2021-03-01 19:02       ` J. Bruce Fields
2021-03-08 13:50         ` Stefan Metzmacher
2021-02-28  2:24 ` Matthew Wilcox
2021-02-28  2:26   ` Drew DeVault
2021-02-28  4:03     ` Matthew Wilcox
2021-02-28 13:57       ` Drew DeVault
2021-03-01 19:09         ` J. Bruce Fields
2021-03-01 19:35           ` Matthew Wilcox
2021-03-01 20:10             ` J. Bruce Fields
2021-03-02  8:24             ` Miklos Szeredi
2021-03-02  7:13         ` Amir Goldstein [this message]
2021-03-03  2:39           ` Aleksa Sarai

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='CAOQ4uxgbt5fdx=5_QKJZm1y7hZn5-84NkBzcLWjHL3eAzdML0Q@mail.gmail.com' \
    --to=amir73il@gmail.com \
    --cc=bfields@fieldses.org \
    --cc=cyphar@cyphar.com \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=sir@cmpwn.com \
    --cc=smfrench@gmail.com \
    --cc=willy@infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.