]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Provide missing syswraps for file_getattr and file_setattr users/mcermak/try-bug510416-file-getattr-file-setatr
authorMartin Cermak <mcermak@redhat.com>
Tue, 19 Jan 2038 03:36:01 +0000 (04:36 +0100)
committerMartin Cermak <mcermak@redhat.com>
Mon, 13 Oct 2025 07:23:52 +0000 (09:23 +0200)
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 b1b27e815b7d04ab3fed5016dea3c84783a59ff0..d00ab07156238b7d07c1b7302a10f9ccfa70e270 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -165,6 +165,7 @@ are not entered into bugzilla tend to get forgotten about or ignored.
 509642  Add missing ppc64-linux syswraps
 509643  Add missing s390x-linux syswraps
 510169  Update the LTP version in valgrind testsuite to 20250930
+510416  Missing syswraps for file_getattr and file_setattr
 
 To see details of a given bug, visit
   https://bugs.kde.org/show_bug.cgi?id=XXXXXX
index ca462e896f7b88d0e1501945add63d7d2ce39cac..71a7518f4eea9c1132ea6775765355575e5f16f0 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 838bf5e84801938464bc250ac4fb0b866654e08a..93fb083e6ec43342de62697329eb5bea205d093b 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 1fda7ba8a029f3ed89406ad51a604c283165af30..7a450e94e3f5cc67d5453caa588e8e158294719b 100644 (file)
@@ -1082,6 +1082,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 175002e6ba8ec6c61f324d1a289eace8f8b15d16..7b4fce6bd34442964d5a4d7b6806e0c6ed21ab1f 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 1402c3d1f5f89f5ee31735feb66e5e75bd849272..4e7356656608f6fcd7d83baa062ee9e0f27abf28 100644 (file)
@@ -4482,6 +4482,76 @@ 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;
+   Int arg_1 = (Int) ARG1;
+   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);
+   // Per https://lwn.net/Articles/1020992/ :
+   // >> 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. <<  That said, we can't use ML_(fd_at_check_allowed)() here,
+   // because there is nothing special about relative path.
+   if (ARG1 == 0)
+   {
+      if (arg_1 != VKI_AT_FDCWD && !ML_(fd_allowed)(arg_1, "file_getattr", tid, False))
+      {
+         SET_STATUS_Failure( VKI_EBADF );
+      }
+   }
+   else
+   {
+      PRE_MEM_RASCIIZ("file_getattr(filename)", ARG2);
+   }
+   PRE_MEM_WRITE("file_getattr(ufattr)", ARG3, sizeof(struct vki_file_attr));
+   PRE_MEM_WRITE("file_getattr(usize)", ARG4, sizeof(vki_size_t));
+}
+
+POST(sys_file_getattr)
+{
+   // POST_MEM_WRITE(ARG3, sizeof(struct vki_file_attr));
+   // POST_MEM_WRITE(ARG4, sizeof(vki_size_t));
+}
+
+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;
+   Int arg_1 = (Int) ARG1;
+   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_setattr", int, dfd, const char*, filename,
+                 struct vki_file_attr *, ufattr, vki_size_t, usize, int, at_flags);
+   // Per https://lwn.net/Articles/1020992/ :
+   // >> 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. <<  That said, we can't use ML_(fd_at_check_allowed)() here,
+   // because there is nothing special about relative path.
+   if (ARG1 == 0)
+   {
+      if (arg_1 != VKI_AT_FDCWD && !ML_(fd_allowed)(arg_1, "file_setattr", tid, False))
+      {
+         SET_STATUS_Failure( VKI_EBADF );
+      }
+   }
+   else
+   {
+      PRE_MEM_RASCIIZ("file_setattr(filename)", ARG2);
+   }
+   PRE_MEM_READ("file_setattr(ufattr)", ARG3, sizeof(struct vki_file_attr));
+}
+
 PRE(sys_syncfs)
 {
    *flags |= SfMayBlock;
index 4edfe8a703818b04cb6c3d6fdbe37be8be7af072..fc8b83d03a6989c02ab85f341c712e41e2923a93 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 4fb6f060e360f17981ace189242bbb1573f5a4ff..8ed8ea7b352b251d549a9558dc869543d9d6e3a3 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 f1a0b3c59376c0381adf29263306e0652360f49b..20446d2e05007b4fe1f3308f7e8b6b92f288d612 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 b1390f3aba83e724dde1dcdc7f63d3f2baa283d3..b4d8ddfbc492f05a68433648613565278617ba67 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 4a08650846e9dccf996bb238b707990113263b35..99317903470fabdf9ed5975342006c2784f43c89 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 5a1ea2553d799caf0af732bc8b5ccc7020cb0786..fce0f23fd344c7c1de37d813ae02cc4e874cc724 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 acb4aefee87e49ba72f69e4531aa81912df31719..1164200fdd2b51179c7230800d35a2362c49f761 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 f697a9e19d8ff951e480c7a591858ec0d8f6c442..d765b7624571a4f67d848973cebb50cfde68d78a 100644 (file)
@@ -1683,6 +1683,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 1b32295bf222ab64f81a7fce2182bafad2c4b6f4..e3c5fccb18615e7d47614e2dc3431bfa66a19cac 100644 (file)
@@ -5574,6 +5574,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 518131a1fd84cb6c3065518a2b52eec2751136fe..1750f592f6fbecf999e77e33e49c9279176d4683 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