From: Christian Brauner <brauner@kernel.org>
To: Jori Koolstra <jkoolstra@xs4all.nl>
Cc: "Aleksa Sarai" <cyphar@cyphar.com>,
"Andy Lutomirski" <luto@kernel.org>,
"Thomas Gleixner" <tglx@kernel.org>,
"Ingo Molnar" <mingo@redhat.com>,
"Borislav Petkov" <bp@alien8.de>,
"Dave Hansen" <dave.hansen@linux.intel.com>,
"Alexander Viro" <viro@zeniv.linux.org.uk>,
"Arnd Bergmann" <arnd@arndb.de>,
"H . Peter Anvin" <hpa@zytor.com>, "Jan Kara" <jack@suse.cz>,
"Peter Zijlstra" <peterz@infradead.org>,
"Andrey Albershteyn" <aalbersh@redhat.com>,
"Masami Hiramatsu" <mhiramat@kernel.org>,
"Jiri Olsa" <jolsa@kernel.org>,
"Thomas Weißschuh" <thomas.weissschuh@linutronix.de>,
"Mathieu Desnoyers" <mathieu.desnoyers@efficios.com>,
cmirabil@redhat.com,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Jeff Layton" <jlayton@kernel.org>,
linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-api@vger.kernel.org, linux-arch@vger.kernel.org
Subject: Re: [RFC PATCH v2 1/2] vfs: syscalls: add mkdirat2() that returns an O_DIRECTORY fd
Date: Fri, 15 May 2026 15:49:15 +0200 [thread overview]
Message-ID: <20260515-gezeugt-noten-465fda1e9df9@brauner> (raw)
In-Reply-To: <1805140959.1362290.1778842523425@kpc.webmail.kpnmail.nl>
On Fri, May 15, 2026 at 12:55:23PM +0200, Jori Koolstra wrote:
> Sorry for the double email, this keyboard is so finicky, I really need to fix it.
>
> > Op 11-05-2026 14:00 CEST schreef Christian Brauner <brauner@kernel.org>:
> >
> > mkdirat2() is objectively the worse api. It forces userspace to use a
> > separate system call without any reason whatsoever. If you can to
> > O_CREAT you should also be able to to O_DIRECTORY in the same system
> > call. If we support O_DIRECTORY | O_CREAT we get all the lookup
> > restriction niceties RESOLVE_* for free. Plus, it is supportable both in
> > openat() and openat2() because I made that combo return an errno.
>
> I don't disagree. I know that some of the UAPI feature requests are not fully
> flashed out, but at least it gives a basis to get the discussion going.
>
> In fact I already have a O_DIRECTORY | O_CREAT patch that at least passes
> the initial tests. However, I need to sit on it a little bit to think whether
> I am not leaving something out. Also, I understand why vfs_create() wasn't used
> in the O_CREAT path, for instance because you cannot just make use of may_create_dentry()
> there. But now that we are going to string another path through lookup_open() it
> would be great if we could reuse some of the logic from vfs_create() and vfs_mkdir().
>
> Perhaps we could move may_create_dentry() out of the vfs_* calls and let the caller
> take care of that. Then again, this is the pattern for all those calls. You could also
> just accept some redundancies with may_o_create(), or have something like
> static vfs_mkdir/create_common() functions.
>
> There are also some minor things. If i_op->mkdir is missing this is an EPERM, but with
> i_op->create it is EACCESS (and suggesting ENOSYS). Should this not be a consistent error
ENOSYS is worse because it would indicate to userspace that the whole
system call they're using isn't available. So we can't ever use that.
This is probably just historical baggage. EACCES is especially wrong
because userspace would expect that particular error code to stem from
an LSM.
In both cases the correct error code would be EOPNOTSUPP and we should
aim to be very consistent in such cases and only reserve this for
missing support for a specific functionality.
I would be very surprised if userspace depended on EACCES being returned
though. So I would say let's try and see whether we can correct this and
return EOPNOTSUPP. The amount of filesystems that have no ->create
should be dwarved by those that do.
> code? I also wonder whether there is a nicer way to handle error being returned from
> vfs_mkdir et al. If I am reading
>
> if (!error) {
> dentry = vfs_mkdir(mnt_idmap(path.mnt), path.dentry->d_inode,
> dentry, mode, &delegated_inode);
> if (IS_ERR(dentry))
> error = PTR_ERR(dentry);
> }
> end_creating_path(&path, dentry);
>
> it feels like there is a missing return inside the if (IS_ERR(dentry)) block, and I
> have to go several function deep to see that end_creating_path correctly deals with
> error values being passed instead of a dentry. Then again, probably not worth the
> churn...
Not without it being a major clarity win at least.
> > UAPI design often is a nasty mix of performance (context switches),
> > separation of concerns and privileges, tastefulness, and compromises you
> > never thought or wanted to make.
> >
>
> Yes, thanks for suggestion this back at FOSDEM. It is quite fun, and lots
> to learn :)
Thanks for working on this. It's helpful.
next prev parent reply other threads:[~2026-05-15 13:49 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-12 13:54 [RFC PATCH v2 0/2] vfs: syscalls: add mkdirat2() that returns an O_DIRECTORY fd Jori Koolstra
2026-04-12 13:54 ` [RFC PATCH v2 1/2] " Jori Koolstra
2026-04-24 10:09 ` Mateusz Guzik
2026-04-27 15:14 ` Christian Brauner
2026-04-27 16:30 ` Mateusz Guzik
2026-04-28 8:55 ` Christian Brauner
2026-04-28 14:39 ` Mateusz Guzik
2026-04-27 15:48 ` Christian Brauner
2026-04-28 1:14 ` Aleksa Sarai
2026-04-28 6:39 ` Jeff Layton
2026-04-28 7:01 ` Jeff Layton
2026-04-28 13:39 ` Stefan Metzmacher
2026-04-28 13:49 ` Stefan Metzmacher
2026-04-28 14:01 ` Paulo Alcantara
2026-05-04 17:41 ` Jori Koolstra
2026-05-11 12:00 ` Christian Brauner
2026-05-12 17:11 ` Aleksa Sarai
2026-05-15 10:27 ` Jori Koolstra
2026-05-15 10:55 ` Jori Koolstra
2026-05-15 13:49 ` Christian Brauner [this message]
2026-04-12 13:54 ` [RFC PATCH v2 2/2] selftest: add tests for mkdirat2() Jori Koolstra
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=20260515-gezeugt-noten-465fda1e9df9@brauner \
--to=brauner@kernel.org \
--cc=aalbersh@redhat.com \
--cc=arnd@arndb.de \
--cc=bp@alien8.de \
--cc=cmirabil@redhat.com \
--cc=cyphar@cyphar.com \
--cc=dave.hansen@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=hpa@zytor.com \
--cc=jack@suse.cz \
--cc=jkoolstra@xs4all.nl \
--cc=jlayton@kernel.org \
--cc=jolsa@kernel.org \
--cc=linux-api@vger.kernel.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=tglx@kernel.org \
--cc=thomas.weissschuh@linutronix.de \
--cc=viro@zeniv.linux.org.uk \
/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