Re: [PATCH 01/14] VFS: Add additional RESOLVE_* flags [ver #18]
flat view
From: Linus Torvalds <torvalds@linux-foundation.org>
Date: 2020-03-12 16:25:13
Also in:
linux-fsdevel, linux-security-module, lkml
On Thu, Mar 12, 2020 at 2:08 AM Stefan Metzmacher [off-list ref] wrote:
The whole discussion was triggered by the introduction of a completely new fsinfo() call: Would you propose to have 'at_flags' and 'resolve_flags' passed in here?
Yes, I think that would be the way to go.
quoted
If we need linkat2() and friends, so be it. Do we?Yes, I'm going to propose something like this, as it would make the life much easier for Samba to have the new features available on all path based syscalls.
Will samba actually use them? I think we've had extensions before that weren't worth the non-portability pain? But yes, if we have a major package like samba use it, then by all means let's add linkat2(). How many things are we talking about? We have a number of system calls that do *not* take flags, but do do pathname walking. I'm thinking things like "mkdirat()"?)
In addition I'll propose to have a way to specify the source of removeat and unlinkat also by fd in addition to the the source parent fd and relative path, the reason are also to detect races of path recycling.
Would that be basically just an AT_EMPTY_PATH kind of thing? IOW,
you'd be able to remove a file by doing
fd = open(path.., O_PATH);
unlinkat(fd, "", AT_EMPTY_PATH);
Hmm. We have _not_ allowed filesystem changes without that last
component lookup. Of course, with our dentry model, we *can* do it,
but this smells fairly fundamental to me.
It might avoid some of the extra system calls (ie you could use
openat2() to do the path walking part, and then
unlinkat(AT_EMPTY_PATH) to remove it, and have a "fstat()" etc in
between the verify that it's the right type of file or whatever - and
you'd not need an unlinkat2() with resolve flags).
I think Al needs to ok this kind of change. Maybe you've already
discussed it with him and I just missed it.
Linus