|
|
Message-ID: <20240118000540.369070-1-gael.portay@rtone.fr>
Date: Thu, 18 Jan 2024 01:05:37 +0100
From: Gaël PORTAY <gael.portay@...ne.fr>
To: musl@...ts.openwall.com
Cc: gael.portay@...ne.fr
Subject: [PATCH 0/3] use new SYS_fchmodat2 syscall to implement fchmodat with flags
hello,
this patch serie adds the syscall SYS_fchmodat2 to implement fchmodat().
it has landed in linux v6.6.
the first patch remove the spurious flag argument from the syscall
SYS_fchmodat (linux lacks for that argument actually).
the second patch defines the syscall itself in headers.
the third patch uses the syscall SYS_fchmodat2 to implement fchmodat()
if flags are passed. the same way the syscall SYS_faccessat2 was used to
implement faccessat() with flags.
it wat tested locally on x86_64 (only), with a dummy test-fchmodat.c.
here is what strace says if no flags are passed:
gportay@...hlinux ~/src/musl $ strace ./lib/libc.so ./test-fchmodat . file 0664 0
execve("./lib/libc.so", ["./lib/libc.so", "./test-fchmodat", ".", "file", "0664", "0"], 0x7ffc172ccc68 /* 34 vars */) = 0
arch_prctl(ARCH_SET_FS, 0x765732cf7ba8) = 0
set_tid_address(0x765732cf8018) = 367709
open("./test-fchmodat", O_RDONLY|O_LARGEFILE) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\260\20\0\0\0\0\0\0"..., 960) = 960
mmap(NULL, 20480, PROT_READ, MAP_PRIVATE, 3, 0) = 0x765732c58000
mmap(0x765732c59000, 4096, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0x1000) = 0x765732c59000
mmap(0x765732c5a000, 4096, PROT_READ, MAP_PRIVATE|MAP_FIXED, 3, 0x2000) = 0x765732c5a000
mmap(0x765732c5b000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x2000) = 0x765732c5b000
close(3) = 0
brk(NULL) = 0x5555568a6000
brk(0x5555568a8000) = 0x5555568a8000
mmap(0x5555568a6000, 4096, PROT_NONE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x5555568a6000
mprotect(0x765732cf4000, 4096, PROT_READ) = 0
mprotect(0x765732c5b000, 4096, PROT_READ) = 0
fchmodat(AT_FDCWD, "file", 0664) = 0
exit_group(0) = ?
+++ exited with 0 +++
it uses the syscall fchmodat.
and what strace says if AT_SYMLINK_NOFOLLOW is passed:
gportay@...hlinux ~/src/musl $ strace ./lib/libc.so ./test-fchmodat . file 0664 0x100
execve("./lib/libc.so", ["./lib/libc.so", "./test-fchmodat", ".", "file", "0664", "0x100"], 0x7ffcd7228278 /* 34 vars */) = 0
arch_prctl(ARCH_SET_FS, 0x7318d8907ba8) = 0
set_tid_address(0x7318d8908018) = 367715
open("./test-fchmodat", O_RDONLY|O_LARGEFILE) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\260\20\0\0\0\0\0\0"..., 960) = 960
mmap(NULL, 20480, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7318d8868000
mmap(0x7318d8869000, 4096, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0x1000) = 0x7318d8869000
mmap(0x7318d886a000, 4096, PROT_READ, MAP_PRIVATE|MAP_FIXED, 3, 0x2000) = 0x7318d886a000
mmap(0x7318d886b000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x2000) = 0x7318d886b000
close(3) = 0
brk(NULL) = 0x55555563d000
brk(0x55555563f000) = 0x55555563f000
mmap(0x55555563d000, 4096, PROT_NONE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x55555563d000
mprotect(0x7318d8904000, 4096, PROT_READ) = 0
mprotect(0x7318d886b000, 4096, PROT_READ) = 0
fchmodat2(AT_FDCWD, "file", 0664, AT_SYMLINK_NOFOLLOW) = 0
exit_group(0) = ?
+++ exited with 0 +++
it uses the syscall fchmodat2!
note: I fails to subscribe to mailing list; please make sure I receive a
copy of any response, I am in cc; sorry for the inconvenience. I hope I
did everything correctly.
regards,
Gaël PORTAY (3):
remove flag argument from fchmodat syscall
bits/syscall.h: add __NR_fchmodat2 from linux v6.6
use new SYS_fchmodat2 syscall to implement fchmodat with flags
arch/arm/bits/syscall.h.in | 1 +
arch/i386/bits/syscall.h.in | 1 +
arch/m68k/bits/syscall.h.in | 1 +
arch/microblaze/bits/syscall.h.in | 1 +
arch/mips/bits/syscall.h.in | 1 +
arch/mips64/bits/syscall.h.in | 1 +
arch/mipsn32/bits/syscall.h.in | 1 +
arch/or1k/bits/syscall.h.in | 1 +
arch/powerpc/bits/syscall.h.in | 1 +
arch/powerpc64/bits/syscall.h.in | 1 +
arch/riscv64/bits/syscall.h.in | 1 +
arch/s390x/bits/syscall.h.in | 1 +
arch/sh/bits/syscall.h.in | 1 +
arch/x32/bits/syscall.h.in | 1 +
arch/x86_64/bits/syscall.h.in | 1 +
src/stat/fchmodat.c | 7 ++++++-
16 files changed, 21 insertions(+), 1 deletion(-)
--
2.43.0
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.