Re: [PATCH v2 2/2] vfs: add fchmodat2 syscall

From: Greg KH
Date: Wed Sep 16 2020 - 02:19:19 EST


On Tue, Sep 15, 2020 at 08:23:38PM -0400, Rich Felker wrote:
> POSIX defines fchmodat as having a 4th argument, flags, that can be
> AT_SYMLINK_NOFOLLOW. Support for changing the access mode of symbolic
> links is optional (EOPNOTSUPP allowed if not supported), but this flag
> is important even on systems where symlinks do not have access modes,
> since it's the only way to safely change the mode of a file which
> might be asynchronously replaced with a symbolic link, without a race
> condition whereby the link target is changed.
>
> It's possible to emulate AT_SYMLINK_NOFOLLOW in userspace, and both
> musl libc and glibc do this, by opening an O_PATH file descriptor and
> performing chmod on the corresponding magic symlink in /proc/self/fd.
> However, this requires procfs to be mounted and accessible.
>
> Signed-off-by: Rich Felker <dalias@xxxxxxxx>

No kselftest for this new system call, or man page? How do we know this
actually works and what the expected outcome should be?

thanks,

greg k-h