Commit 475d4df8 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

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.

  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"
parents 511fb5ba 71214379
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -491,3 +491,4 @@
559	common  futex_waitv                     sys_futex_waitv
560	common	set_mempolicy_home_node		sys_ni_syscall
561	common	cachestat			sys_cachestat
562	common	fchmodat2			sys_fchmodat2
+1 −0
Original line number Diff line number Diff line
@@ -465,3 +465,4 @@
449	common	futex_waitv			sys_futex_waitv
450	common	set_mempolicy_home_node		sys_set_mempolicy_home_node
451	common	cachestat			sys_cachestat
452	common	fchmodat2			sys_fchmodat2
+1 −1
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@
#define __ARM_NR_compat_set_tls		(__ARM_NR_COMPAT_BASE + 5)
#define __ARM_NR_COMPAT_END		(__ARM_NR_COMPAT_BASE + 0x800)

#define __NR_compat_syscalls		452
#define __NR_compat_syscalls		453
#endif

#define __ARCH_WANT_SYS_CLONE
+2 −0
Original line number Diff line number Diff line
@@ -909,6 +909,8 @@ __SYSCALL(__NR_futex_waitv, sys_futex_waitv)
__SYSCALL(__NR_set_mempolicy_home_node, sys_set_mempolicy_home_node)
#define __NR_cachestat 451
__SYSCALL(__NR_cachestat, sys_cachestat)
#define __NR_fchmodat2 452
__SYSCALL(__NR_fchmodat2, sys_fchmodat2)

/*
 * Please add new compat syscalls above this comment and update
+1 −0
Original line number Diff line number Diff line
@@ -372,3 +372,4 @@
449	common  futex_waitv                     sys_futex_waitv
450	common	set_mempolicy_home_node		sys_set_mempolicy_home_node
451	common	cachestat			sys_cachestat
452	common	fchmodat2			sys_fchmodat2
Loading