]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Provide missing syswraps for file_getattr and file_setattr
authorMartin Cermak <mcermak@redhat.com>
Thu, 27 Nov 2025 08:25:07 +0000 (09:25 +0100)
committerMartin Cermak <mcermak@redhat.com>
Thu, 27 Nov 2025 08:25:07 +0000 (09:25 +0100)
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

16 files changed:
NEWS
coregrind/m_syswrap/priv_syswrap-linux.h
coregrind/m_syswrap/syswrap-amd64-linux.c
coregrind/m_syswrap/syswrap-arm-linux.c
coregrind/m_syswrap/syswrap-arm64-linux.c
coregrind/m_syswrap/syswrap-linux.c
coregrind/m_syswrap/syswrap-mips32-linux.c
coregrind/m_syswrap/syswrap-mips64-linux.c
coregrind/m_syswrap/syswrap-nanomips-linux.c
coregrind/m_syswrap/syswrap-ppc32-linux.c
coregrind/m_syswrap/syswrap-ppc64-linux.c
coregrind/m_syswrap/syswrap-riscv64-linux.c
coregrind/m_syswrap/syswrap-s390x-linux.c
coregrind/m_syswrap/syswrap-x86-linux.c
include/vki/vki-linux.h
include/vki/vki-scnums-shared-linux.h

diff --git a/NEWS b/NEWS
index 3b76257d659ae82c2118baa9d2d570759035702e..b944b1fb989878f6fb0dd55060d668b42c37f882 100644 (file)
--- 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
index 21cb32829a370877191249484edcc17732ade7d5..2c878c8c56918542094a049bec8d6517e5bfc54e 100644 (file)
@@ -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
index 234b056e58a8db6c53d16f80e8286f1f0976d56a..5dccb47b3e71688bbe116ba50b635b8084a0dacf 100644 (file)
@@ -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 )
index 9e1b2efb485b20f6850a0b3543dbff35f3380934..af3ec18ddf4132a08217b5d8ea99a45f727dfc5e 100644 (file)
@@ -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
 };
 
 
index 418c78443fc8bbcf21ff66f0cec0eff370678198..05a39ed07f5805333f19469b74737ce010b04bfc 100644 (file)
@@ -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
 };
 
 
index 8bf0bab56d7249968565a3815afb065a9558de3a..e17aff6a432cceaeab5b25d489302965435f4b9e 100644 (file)
@@ -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;
index 6132c9ff1abfa237f73b32a8bf4ef7bedaa4ec29..12624492502f9ac7b4c000e47ea5ac3cfe74d425 100644 (file)
@@ -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)
index 238b1cda0d95a7abaeeaf855363b944e2f94c191..f39bb58cc140053d4fe9245ba98c3cc68629e9c0 100644 (file)
@@ -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 )
index bb20cd7d3b98446773e91347545430e114c685c5..00bd2e756ed39e87b1e3b3efa31b9684f1fb664d 100644 (file)
@@ -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)
index 4d7e43130c466209cabd0244ecc5b9d42b95fff9..99f71b7a666f12d66a951b6c56f46b4610952ec0 100644 (file)
@@ -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 )
index 826c87937f041586f4e3da4b0218a7547d91f7b2..e8996b6b7834fb119d1a027c15f5e6649095baed 100644 (file)
@@ -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 )
index 78b1b6b42dbbdff20bc134a27de8e2383fc18291..3dbae3cb67c4e0abffa0aa366568c60478b2239f 100644 (file)
@@ -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)
index c16b69731ae4e8cdc13dd411632e4e73b659a466..d96adecde3092d3e02dc982157c11a822e84f559 100644 (file)
@@ -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 )
index 423feac56866dfd6390d00729c3e82c946bf7c4a..a83c02b046ff3797d97575658ff07acc97180e85 100644 (file)
@@ -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 )
index 59c4d57c8af6c68262fca7c9a3af15d48794d6d8..48aacea22f75c56ac0a35151bbdc282cdf1d5bb7 100644 (file)
@@ -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                                                          ---*/
 /*--------------------------------------------------------------------*/
index 8efba61690536a5778a6ba65cd4da9d1fffee1d6..704e6378cc251c20b2cc110b4e0a5a9ab36be2ad 100644 (file)
@@ -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