From: Martin Cermak Date: Thu, 27 Nov 2025 08:25:07 +0000 (+0100) Subject: Provide missing syswraps for file_getattr and file_setattr X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3275a177f99d36836107a425b46c84964f1ad354;p=thirdparty%2Fvalgrind.git Provide missing syswraps for file_getattr and file_setattr The syscalls take fd and path. If path is absolute, fd is not used. If path is empty, fd can be AT_FDCWD or any valid fd which will be used to get/set attributes on. https://bugs.kde.org/show_bug.cgi?id=510169 --- diff --git a/NEWS b/NEWS index 3b76257d6..b944b1fb9 100644 --- a/NEWS +++ b/NEWS @@ -28,6 +28,7 @@ are not entered into bugzilla tend to get forgotten about or ignored. 510864 Add SSE4.1 PMAXSD and PMINSD instructions support for 32-bit x86 413369 unhandled amd64-darwin syscall: unix:151 (getpgid) 487055 memcheck/tests/x86-linux/scalar fails running in Docker +510416 Missing syswraps for file_getattr and file_setattr 511329 Darwin and FreeBSD: Move setting of carry flag out of ML_(do_syscall_for_client_WRK) 511713 Refactor syscall argument handling diff --git a/coregrind/m_syswrap/priv_syswrap-linux.h b/coregrind/m_syswrap/priv_syswrap-linux.h index 21cb32829..2c878c8c5 100644 --- a/coregrind/m_syswrap/priv_syswrap-linux.h +++ b/coregrind/m_syswrap/priv_syswrap-linux.h @@ -373,6 +373,10 @@ DECL_TEMPLATE(linux, sys_statmount); // Since Linux 6.10 DECL_TEMPLATE(linux, sys_mseal); +// Since Linux 6.17-rc1 +DECL_TEMPLATE(linux, sys_file_getattr); +DECL_TEMPLATE(linux, sys_file_setattr); + /* --------------------------------------------------------------------- Wrappers for sockets and ipc-ery. These are split into standalone procedures because x86-linux hides them inside multiplexors diff --git a/coregrind/m_syswrap/syswrap-amd64-linux.c b/coregrind/m_syswrap/syswrap-amd64-linux.c index 234b056e5..5dccb47b3 100644 --- a/coregrind/m_syswrap/syswrap-amd64-linux.c +++ b/coregrind/m_syswrap/syswrap-amd64-linux.c @@ -910,6 +910,8 @@ static SyscallTableEntry syscall_table[] = { LINXY(__NR_statmount, sys_statmount), // 457 LINXY(__NR_listmount, sys_listmount), // 458 LINX_(__NR_mseal, sys_mseal), // 462 + LINXY(__NR_file_getattr, sys_file_getattr), // 468 + LINX_(__NR_file_setattr, sys_file_setattr), // 469 }; SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno ) diff --git a/coregrind/m_syswrap/syswrap-arm-linux.c b/coregrind/m_syswrap/syswrap-arm-linux.c index 9e1b2efb4..af3ec18dd 100644 --- a/coregrind/m_syswrap/syswrap-arm-linux.c +++ b/coregrind/m_syswrap/syswrap-arm-linux.c @@ -1080,6 +1080,8 @@ static SyscallTableEntry syscall_main_table[] = { LINXY(__NR_statmount, sys_statmount), // 457 LINXY(__NR_listmount, sys_listmount), // 458 LINX_(__NR_mseal, sys_mseal), // 462 + LINXY(__NR_file_getattr, sys_file_getattr), // 468 + LINX_(__NR_file_setattr, sys_file_setattr), // 469 }; diff --git a/coregrind/m_syswrap/syswrap-arm64-linux.c b/coregrind/m_syswrap/syswrap-arm64-linux.c index 418c78443..05a39ed07 100644 --- a/coregrind/m_syswrap/syswrap-arm64-linux.c +++ b/coregrind/m_syswrap/syswrap-arm64-linux.c @@ -861,6 +861,8 @@ static SyscallTableEntry syscall_main_table[] = { LINXY(__NR_statmount, sys_statmount), // 457 LINXY(__NR_listmount, sys_listmount), // 458 LINX_(__NR_mseal, sys_mseal), // 462 + LINXY(__NR_file_getattr, sys_file_getattr), // 468 + LINX_(__NR_file_setattr, sys_file_setattr), // 469 }; diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c index 8bf0bab56..e17aff6a4 100644 --- a/coregrind/m_syswrap/syswrap-linux.c +++ b/coregrind/m_syswrap/syswrap-linux.c @@ -4482,6 +4482,44 @@ POST(sys_listmount) } } +PRE(sys_file_getattr) +{ + // SYSCALL_DEFINE5(file_getattr, int, dfd, const char __user *, filename, + // struct file_attr __user *, ufattr, size_t, usize, + // unsigned int, at_flags) + // in: dfd, filename, at_flags + // out: ufattr, usize + *flags |= SfMayBlock; + PRINT("sys_file_getattr ( %ld, %#" FMT_REGWORD "x(%s), %#" + FMT_REGWORD "x, %" FMT_REGWORD "u, %#" FMT_REGWORD "x )" , + SARG1, ARG2, (HChar*)(Addr)ARG2, ARG3, ARG4, ARG5); + PRE_REG_READ5(int, "file_getattr", int, dfd, const char*, filename, + struct vki_file_attr *, ufattr, vki_size_t, usize, int, at_flags); + ML_(fd_at_check_allowed)(SARG1, (const HChar*)ARG2, "file_getattr", tid, status); + PRE_MEM_WRITE("file_getattr(ufattr)", ARG3, ARG4); +} + +POST(sys_file_getattr) +{ + POST_MEM_WRITE(ARG3, ARG4); +} + +PRE(sys_file_setattr) +{ + // SYSCALL_DEFINE5(file_setattr, int, dfd, const char __user *, filename, + // struct file_attr __user *, ufattr, size_t, usize, + // unsigned int, at_flags) + // in: dfd, filename, ufattr, usize, at_flags + *flags |= SfMayBlock; + PRINT("sys_file_setattr ( %ld, %#" FMT_REGWORD "x(%s), %#" + FMT_REGWORD "x, %" FMT_REGWORD "u, %#" FMT_REGWORD "x )" , + SARG1, ARG2, (HChar*)(Addr)ARG2, ARG3, ARG4, ARG5); + PRE_REG_READ5(int, "file_setattr", int, dfd, const char*, filename, + struct vki_file_attr *, ufattr, vki_size_t, usize, int, at_flags); + ML_(fd_at_check_allowed)(SARG1, (const HChar*)ARG2, "sys_file_setattr", tid, status); + PRE_MEM_READ("file_setattr(ufattr)", ARG3, ARG4); +} + PRE(sys_syncfs) { *flags |= SfMayBlock; diff --git a/coregrind/m_syswrap/syswrap-mips32-linux.c b/coregrind/m_syswrap/syswrap-mips32-linux.c index 6132c9ff1..126244925 100644 --- a/coregrind/m_syswrap/syswrap-mips32-linux.c +++ b/coregrind/m_syswrap/syswrap-mips32-linux.c @@ -1189,6 +1189,8 @@ static SyscallTableEntry syscall_main_table[] = { LINXY(__NR_statmount, sys_statmount), // 457 LINXY(__NR_listmount, sys_listmount), // 458 LINX_(__NR_mseal, sys_mseal), // 462 + LINXY(__NR_file_getattr, sys_file_getattr), // 468 + LINX_(__NR_file_setattr, sys_file_setattr), // 469 }; SyscallTableEntry* ML_(get_linux_syscall_entry) (UInt sysno) diff --git a/coregrind/m_syswrap/syswrap-mips64-linux.c b/coregrind/m_syswrap/syswrap-mips64-linux.c index 238b1cda0..f39bb58cc 100644 --- a/coregrind/m_syswrap/syswrap-mips64-linux.c +++ b/coregrind/m_syswrap/syswrap-mips64-linux.c @@ -800,6 +800,8 @@ static SyscallTableEntry syscall_main_table[] = { LINX_ (__NR_mseal, sys_mseal), LINX_ (__NR_futex_waitv, sys_futex_waitv), LINX_ (__NR_quotactl_fd, sys_quotactl_fd), + LINXY(__NR_file_getattr, sys_file_getattr), + LINX_(__NR_file_setattr, sys_file_setattr), }; SyscallTableEntry * ML_(get_linux_syscall_entry) ( UInt sysno ) diff --git a/coregrind/m_syswrap/syswrap-nanomips-linux.c b/coregrind/m_syswrap/syswrap-nanomips-linux.c index bb20cd7d3..00bd2e756 100644 --- a/coregrind/m_syswrap/syswrap-nanomips-linux.c +++ b/coregrind/m_syswrap/syswrap-nanomips-linux.c @@ -825,6 +825,8 @@ static SyscallTableEntry syscall_main_table[] = { LINXY (__NR_listmount, sys_listmount), LINX_ (__NR_mseal, sys_mseal), LINX_ (__NR_futex_waitv, sys_futex_waitv), + LINXY (__NR_file_getattr, sys_file_getattr), + LINX_ (__NR_file_setattr, sys_file_setattr), }; SyscallTableEntry* ML_(get_linux_syscall_entry) (UInt sysno) diff --git a/coregrind/m_syswrap/syswrap-ppc32-linux.c b/coregrind/m_syswrap/syswrap-ppc32-linux.c index 4d7e43130..99f71b7a6 100644 --- a/coregrind/m_syswrap/syswrap-ppc32-linux.c +++ b/coregrind/m_syswrap/syswrap-ppc32-linux.c @@ -1088,6 +1088,8 @@ static SyscallTableEntry syscall_table[] = { LINXY (__NR_statmount, sys_statmount), // 457 LINXY (__NR_listmount, sys_listmount), // 458 LINX_ (__NR_mseal, sys_mseal), // 462 + LINXY (__NR_file_getattr, sys_file_getattr), // 468 + LINX_ (__NR_file_setattr, sys_file_setattr), // 469 }; SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno ) diff --git a/coregrind/m_syswrap/syswrap-ppc64-linux.c b/coregrind/m_syswrap/syswrap-ppc64-linux.c index 826c87937..e8996b6b7 100644 --- a/coregrind/m_syswrap/syswrap-ppc64-linux.c +++ b/coregrind/m_syswrap/syswrap-ppc64-linux.c @@ -1066,6 +1066,8 @@ static SyscallTableEntry syscall_table[] = { LINXY (__NR_statmount, sys_statmount), // 457 LINXY (__NR_listmount, sys_listmount), // 458 LINX_ (__NR_mseal, sys_mseal), // 462 + LINXY (__NR_file_getattr, sys_file_getattr), // 468 + LINX_ (__NR_file_setattr, sys_file_setattr), // 469 }; SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno ) diff --git a/coregrind/m_syswrap/syswrap-riscv64-linux.c b/coregrind/m_syswrap/syswrap-riscv64-linux.c index 78b1b6b42..3dbae3cb6 100644 --- a/coregrind/m_syswrap/syswrap-riscv64-linux.c +++ b/coregrind/m_syswrap/syswrap-riscv64-linux.c @@ -609,6 +609,8 @@ static SyscallTableEntry syscall_main_table[] = { LINXY(__NR_statmount, sys_statmount), /* 457 */ LINXY(__NR_listmount, sys_listmount), /* 458 */ LINX_(__NR_mseal, sys_mseal), /* 462 */ + LINXY(__NR_file_getattr, sys_file_getattr), /* 468 */ + LINX_(__NR_file_setattr, sys_file_setattr), /* 469 */ }; SyscallTableEntry* ML_(get_linux_syscall_entry)(UInt sysno) diff --git a/coregrind/m_syswrap/syswrap-s390x-linux.c b/coregrind/m_syswrap/syswrap-s390x-linux.c index c16b69731..d96adecde 100644 --- a/coregrind/m_syswrap/syswrap-s390x-linux.c +++ b/coregrind/m_syswrap/syswrap-s390x-linux.c @@ -901,6 +901,8 @@ static SyscallTableEntry syscall_table[] = { LINXY (__NR_statmount, sys_statmount), // 457 LINXY (__NR_listmount, sys_listmount), // 458 LINX_ (__NR_mseal, sys_mseal), // 462 + LINXY (__NR_file_getattr, sys_file_getattr), // 468 + LINX_ (__NR_file_setattr, sys_file_setattr), // 469 }; SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno ) diff --git a/coregrind/m_syswrap/syswrap-x86-linux.c b/coregrind/m_syswrap/syswrap-x86-linux.c index 423feac56..a83c02b04 100644 --- a/coregrind/m_syswrap/syswrap-x86-linux.c +++ b/coregrind/m_syswrap/syswrap-x86-linux.c @@ -1691,6 +1691,8 @@ static SyscallTableEntry syscall_table[] = { LINXY(__NR_statmount, sys_statmount), // 457 LINXY(__NR_listmount, sys_listmount), // 458 LINX_(__NR_mseal, sys_mseal), // 462 + LINXY(__NR_file_getattr, sys_file_getattr), // 468 + LINX_(__NR_file_setattr, sys_file_setattr), // 469 }; SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno ) diff --git a/include/vki/vki-linux.h b/include/vki/vki-linux.h index 59c4d57c8..48aacea22 100644 --- a/include/vki/vki-linux.h +++ b/include/vki/vki-linux.h @@ -5598,6 +5598,18 @@ struct vki_statmount { char str[]; /* Variable size part containing strings */ }; +//---------------------------------------------------------------------- +// From uapi/linux/fs.h +//---------------------------------------------------------------------- + +struct vki_file_attr { + __vki_u64 fa_xflags; /* xflags field value (get/set) */ + __vki_u32 fa_extsize; /* extsize field value (get/set)*/ + __vki_u32 fa_nextents; /* nextents field value (get) */ + __vki_u32 fa_projid; /* project identifier (get/set) */ + __vki_u32 fa_cowextsize; /* CoW extsize field value (get/set) */ +}; + /*--------------------------------------------------------------------*/ /*--- end ---*/ /*--------------------------------------------------------------------*/ diff --git a/include/vki/vki-scnums-shared-linux.h b/include/vki/vki-scnums-shared-linux.h index 8efba6169..704e6378c 100644 --- a/include/vki/vki-scnums-shared-linux.h +++ b/include/vki/vki-scnums-shared-linux.h @@ -61,5 +61,7 @@ #define __NR_statmount 457 #define __NR_listmount 458 #define __NR_mseal 462 +#define __NR_file_getattr 468 +#define __NR_file_setattr 469 #endif