Re: fchmodat(2) does support AT_SYMLINK_NOFOLLOW now, no?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Aug 26, 2024 at 3:57 PM Alejandro Colomar <alx@xxxxxxxxxx> wrote:
>
> Hi Elliott,
>
> On Mon, Aug 26, 2024 at 12:37:46PM GMT, enh wrote:
> > looks like Linux 6.6...
>
> Thanks for researching that!
>
> > commit 475d4df82719225510625b4263baa1105665f4b3
> > Merge: 511fb5bafed1 712143795327
> > Author: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
> > Date:   Mon Aug 28 11:25:27 2023 -0700
> >
> >     Merge tag 'v6.6-vfs.fchmodat2' of
> > git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs
> >
> >     Pull fchmodat2 system call from Christian Brauner:
> >      "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.
>
> Maybe we need to add a "C library/kernel differences" section?

what's your timeline for "currently interesting" vs "just historical"?
(though i guess whatever that is, Linux 6.6 is pretty new at less than
12 months old!)

>         $ grep -rh '^\.SS ' man | sort | uniq -c | sort | tail
>               5 .SS glibc
>               7 .SS Authors and copyright conditions
>               8 .SS Address format
>              11 .SS Ioctls
>              11 .SS glibc notes
>              12 .SS Socket options
>              13 .SS /proc interfaces
>              15 .SS ISO/IEC\~8859 alphabets
>              51 .SS C library/kernel differences
>              99 .SS Program source
>
> Would you mind preparing a patch?

if you just want the trivial removal of the incorrect sentence, sure
... if you want a whole new "C library/kernel differences" section
you're probably able to write that ... which is probably a good
juncture to point out that there's also a whole missing function ---
there's no mention of lchmod() which seems to have been added in
GLIBC_2.3.2 (yes, 22 years ago; not to be confused with 2.32 :-) ...
except i don't think it _worked_ on Linux until glibc sha
6b89c385d8bd0700b25bac2c2d0bebe68d5cc05d in 2020? i don't know how you
want to document that!).

> Have a lovely day!
> Alex
>
> >       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 glibc and musl
> >       have to implement a workaround in order to support AT_SYMLINK_NOFOLLOW
> >       (see [1] and [2]).
> >
> >       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 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().
> >
> >       The implementation is simple and comes with selftests. Implementation
> >       of the system call and wiring up the system call are done as separate
> >       patches even though they could arguably be one patch. But in case
> >       there are merge conflicts from other system call additions it can be
> >       beneficial to have separate patches"
> >
> >     Link: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/fchmodat.c;h=17eca54051ee28ba1ec3f9aed170a62630959143;hb=a492b1e5ef7ab50c6fdd4e4e9879ea5569ab0a6c#l35
> > [1]
> >     Link: https://git.musl-libc.org/cgit/musl/tree/src/stat/fchmodat.c?id=718f363bc2067b6487900eddc9180c84e7739f80#n28
> > [2]
> >
> >     * tag 'v6.6-vfs.fchmodat2' of
> > git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs:
> >       selftests: fchmodat2: remove duplicate unneeded defines
> >       fchmodat2: add support for AT_EMPTY_PATH
> >       selftests: Add fchmodat2 selftest
> >       arch: Register fchmodat2, usually as syscall 452
> >       fs: Add fchmodat2()
> >       Non-functional cleanup of a "__user * filename"
> >
> > On Sun, Aug 25, 2024 at 5:52 AM Alejandro Colomar <alx@xxxxxxxxxx> wrote:
> > >
> > > Hi Elliott,
> > >
> > > On Fri, Aug 23, 2024 at 02:40:16PM GMT, enh wrote:
> > > > subject says it all... the "This flag is not currently implemented."
> > > > on the man page is wrong, i think?
> > >
> > > I guess it was right when the text was written in 2006.
> > >
> > > $ git blame --follow -- man/man2/chmod.2 | grep currently
> > > 92f114db82 man2/chmod.2     (Michael Kerrisk   2014-02-21 08:35:27 +0100 207) This flag is not currently implemented.
> > > $ git blame 92f114db82^ -- man2/fchmodat.2 | grep currently
> > > a53b8cb2a0 (Michael Kerrisk  2006-05-02 00:05:06 +0000  99) This flag is not currently implemented.
> > >
> > > That might perfectly have changed in the last 18 years.  :)
> > >
> > > Would you mind writing a small program and shell session that
> > > demonstrates it?  It could be interesting for an EXAMPLES section.
> > >
> > >
> > > Have a lovely day!
> > > Alex
> > >
> > > --
> > > <https://www.alejandro-colomar.es/>
>
> --
> <https://www.alejandro-colomar.es/>





[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux