fchmodat2 System Call Submitted For Linux 6.6

Written by Michael Larabel in Linux Kernel on 27 August 2023 at 11:46 AM EDT. 5 Comments
LINUX KERNEL
Ahead of the Linux 6.5 stable kernel being released there have already been a few pull requests submitted of new feature material for Linux 6.6. Among the early pulls for v6.6 is one from prominent Linux developer Christian Brauner at Microsoft that introduces the fchmodat2() system call as an evolution of fchmodat().

The fchmodat2() submitted for Linux 6.6 is an evolution of the fchmodat() call for changing permissions of a file relative to a directory file descriptor. The new system call adds a flag argument that allows support for the AT_SYMLINK_NOFOLLOW and AT_EMPTY_PATH flags. With AT_SYMLINK_NOFOLLOW, it a symbolic path is used it will not dereference it but operate on the link itself.

fchmodat2() system call


Christian Brauner explained of fchmodat2() and how it will improve the experience for C library (libc) implementations in user-space:
"This adds the fchmodat2() system call. It is a revised version of the fchmodat() system call, adding a missing flag argument. Support for both AT_SYMLINK_NOFOLLOW and AT_EMPTY_PATH are included.

Adding this system call revision has been a longstanding request but so far has always fallen through the cracks. While the kernel implementation of fchmodat() does not have a flag argument the libc provided POSIX-compliant fchmodat(3) version does. Both libcs have to implement a workaround in order to support AT_SYMLINK_NOFOLLOW.

The workaround is brittle because it relies not just on O_PATH and O_NOFOLLOW semantics and procfs magic links but also on our rather inconsistent symlink semantics.

This pull request gives userspace a proper fchmodat2() system call that libcs can use to properly implement fchmodat(3) and allows them to get rid of their hacks. In this case it will immediately benefit them as the current workaround is already defunct because of aformentioned inconsistencies.

In addition to AT_SYMLINK_NOFOLLOW, give userspace the ability to use AT_EMPTY_PATH with fchmodat2(). This is already possible with fchownat() so there's no reason to not also support it for fchmodat2()."

Barring Linus Torvalds finding any faults in this basic system call update, this pull request should land once the Linux 6.6 merge window is officially underway.
Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.

Popular News This Week