]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Wrap new lsm_list_modules syscall master
authorMartin Cermak <mcermak@redhat.com>
Tue, 16 Dec 2025 08:52:29 +0000 (09:52 +0100)
committerMartin Cermak <mcermak@redhat.com>
Tue, 16 Dec 2025 08:52:29 +0000 (09:52 +0100)
The lsm_list_modules syscall returns a list of the active LSM ids. On
success this function returns the number of @ids array elements. This
value may be zero if there are no LSMs active. If @size is insufficient
to contain the return data -E2BIG is returned and @size is set to the
minimum required size. In all other cases a negative value indicating
the error is returned.

SYSCALL_DEFINE3(lsm_list_modules, u64 __user *, ids, u32 __user *, size,
                u32, flags)

Declare lsm_list_modules wrappers in priv_syswrap-linux.h and hook it
for {amd64,arm,arm64,mips64,ppc32,ppc64,riscv64,s390x,x86}-linux.

https://bugs.kde.org/show_bug.cgi?id=513257

15 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-scnums-shared-linux.h

diff --git a/NEWS b/NEWS
index 51ba3e940a4214951071ba616e6b413a3b2bfb1b..53768ece3f98038509ae7d5379479f9f9bacd180 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -45,6 +45,7 @@ are not entered into bugzilla tend to get forgotten about or ignored.
 512030  s390x: bfp-convert testcase fails
 512037  malloc trace does not print free size or alignment
 512571  regtest problems with darwin dsymuti
+513257  Add missing syswraps for lsm_list_modules
 
 To see details of a given bug, visit
   https://bugs.kde.org/show_bug.cgi?id=XXXXXX
index b02701d27b0a9387949be8051ddabbda57430ef7..f4d3f8a7a58d91961195bd92ab2133d681f9263d 100644 (file)
@@ -374,6 +374,7 @@ DECL_TEMPLATE(linux, sys_statmount);
 DECL_TEMPLATE(linux, sys_mseal);
 DECL_TEMPLATE(linux, sys_lsm_get_self_attr);
 DECL_TEMPLATE(linux, sys_lsm_set_self_attr);
+DECL_TEMPLATE(linux, sys_lsm_list_modules);
 
 // Since Linux 6.17-rc1
 DECL_TEMPLATE(linux, sys_file_getattr);
index 0a05d7cb51b7b8865b7d2bc668bbe0e31b4bf3ff..ab24a2e8f7350e48969b358246b13667b9e9623c 100644 (file)
@@ -911,6 +911,7 @@ static SyscallTableEntry syscall_table[] = {
    LINXY(__NR_listmount,         sys_listmount),         // 458
    LINXY(__NR_lsm_get_self_attr, sys_lsm_get_self_attr), // 459
    LINX_(__NR_lsm_set_self_attr, sys_lsm_set_self_attr), // 460
+   LINXY(__NR_lsm_list_modules,  sys_lsm_list_modules),  // 461
    LINX_(__NR_mseal,             sys_mseal),             // 462
    LINXY(__NR_file_getattr,      sys_file_getattr),      // 468
    LINX_(__NR_file_setattr,      sys_file_setattr),      // 469
index e923bee9c90cbe95531b7357b819058d0ea2ff36..73e5ef1a720e7a9936e0ed8d49e0eda36e8f544f 100644 (file)
@@ -1081,6 +1081,7 @@ static SyscallTableEntry syscall_main_table[] = {
    LINXY(__NR_listmount,         sys_listmount),         // 458
    LINXY(__NR_lsm_get_self_attr, sys_lsm_get_self_attr), // 459
    LINX_(__NR_lsm_set_self_attr, sys_lsm_set_self_attr), // 460
+   LINXY(__NR_lsm_list_modules,  sys_lsm_list_modules),  // 461
    LINX_(__NR_mseal,             sys_mseal),             // 462
    LINXY(__NR_file_getattr,      sys_file_getattr),      // 468
    LINX_(__NR_file_setattr,      sys_file_setattr),      // 469
index 9b6e05dbc960f86671a2a9f9a0038bf2209a1f86..71d16739c0fb276bfb1909083d8de6cc43de962d 100644 (file)
@@ -862,6 +862,7 @@ static SyscallTableEntry syscall_main_table[] = {
    LINXY(__NR_listmount,         sys_listmount),         // 458
    LINXY(__NR_lsm_get_self_attr, sys_lsm_get_self_attr), // 459
    LINX_(__NR_lsm_set_self_attr, sys_lsm_set_self_attr), // 460
+   LINXY(__NR_lsm_list_modules,  sys_lsm_list_modules),  // 461
    LINX_(__NR_mseal,             sys_mseal),             // 462
    LINXY(__NR_file_getattr,      sys_file_getattr),      // 468
    LINX_(__NR_file_setattr,      sys_file_setattr),      // 469
index 7186cf0c4825e7f5e1e7ec5c670148b439351320..10e63348d91ba3f86eebf68b619e32b87e3b43c5 100644 (file)
@@ -4676,6 +4676,28 @@ PRE(sys_lsm_set_self_attr)
    PRE_MEM_READ("lsm_get_self_attr(ctx)", ARG2, ARG3);
 }
 
+PRE(sys_lsm_list_modules)
+{
+   //  * sys_lsm_list_modules - Return a list of the active security modules
+   //  * @ids: the LSM module ids
+   //  * @size: pointer to size of @ids, updated on return
+   //  * @flags: reserved for future use, must be zero
+   // SYSCALL_DEFINE3(lsm_list_modules, u64 __user *, ids, u32 __user *, size,
+   //                 u32, flags)
+   PRINT("sys_lsm_list_modules (  %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %#" FMT_REGWORD "x)", ARG1, ARG2, ARG3);
+   PRE_REG_READ3(long, "lsm_list_modules", __vki_u64 *, ids, __vki_u32 *, size, __vki_u32, flags);
+   PRE_MEM_READ("lsm_list_modules(size)", ARG2, sizeof(__vki_u32));
+   if (ML_(safe_to_deref)((__vki_u32 *)ARG2,sizeof(__vki_u32)))
+      PRE_MEM_READ("lsm_list_modules(ids)", ARG1, *(__vki_u32 *)ARG2);
+}
+
+POST(sys_lsm_list_modules)
+{
+   // No need to POST_MEM_WRITE((Addr)ARG2, sizeof(__vki_u32));
+   // per https://bugs.kde.org/show_bug.cgi?id=513257#c4
+   POST_MEM_WRITE(ARG1, *(__vki_u32 *)ARG2);
+}
+
 PRE(sys_syncfs)
 {
    *flags |= SfMayBlock;
index 43c9b861d9bb39eafd32001cd7aa962d7aa2a403..3854c28712bb49602e8f39535be0e43b5878c7f7 100644 (file)
@@ -1190,6 +1190,7 @@ static SyscallTableEntry syscall_main_table[] = {
    LINXY(__NR_listmount,               sys_listmount),               // 458
    LINXY(__NR_lsm_get_self_attr,       sys_lsm_get_self_attr),       // 459
    LINX_(__NR_lsm_set_self_attr,       sys_lsm_set_self_attr),       // 460
+   LINXY(__NR_lsm_list_modules,        sys_lsm_list_modules),        // 461
    LINX_(__NR_mseal,                   sys_mseal),                   // 462
    LINXY(__NR_file_getattr,            sys_file_getattr),            // 468
    LINX_(__NR_file_setattr,            sys_file_setattr),            // 469
index d78e59842b7118b7cfd6177b61f02f071a1c19d7..71adfcc6803b53f52a9aae515428e418f9a87dfa 100644 (file)
@@ -797,8 +797,9 @@ static SyscallTableEntry syscall_main_table[] = {
    LINXY (__NR_userfaultfd, sys_userfaultfd),
    LINXY (__NR_statmount, sys_statmount),
    LINXY (__NR_listmount, sys_listmount),
-   LINXY(__NR_lsm_get_self_attr, sys_lsm_get_self_attr),
-   LINX_(__NR_lsm_set_self_attr, sys_lsm_set_self_attr),
+   LINXY (__NR_lsm_get_self_attr, sys_lsm_get_self_attr),
+   LINX_ (__NR_lsm_set_self_attr, sys_lsm_set_self_attr),
+   LINXY (__NR_lsm_list_modules, sys_lsm_list_modules),
    LINX_ (__NR_mseal, sys_mseal),
    LINX_ (__NR_futex_waitv, sys_futex_waitv),
    LINXY (__NR_quotactl_fd, sys_quotactl_fd),
index e5c642572209c1c6f31ef4c241720b81dd420a13..1a2de9158504e80ad11e082d250159ce00f3f0e6 100644 (file)
@@ -823,8 +823,9 @@ static SyscallTableEntry syscall_main_table[] = {
    LINX_ (__NR_fchmodat2,              sys_fchmodat2),
    LINXY (__NR_statmount,              sys_statmount),
    LINXY (__NR_listmount,              sys_listmount),
-   LINXY(__NR_lsm_get_self_attr,       sys_lsm_get_self_attr),
-   LINX_(__NR_lsm_set_self_attr,       sys_lsm_set_self_attr),
+   LINXY (__NR_lsm_get_self_attr,      sys_lsm_get_self_attr),
+   LINX_ (__NR_lsm_set_self_attr,      sys_lsm_set_self_attr),
+   LINXY (__NR_lsm_list_modules,       sys_lsm_list_modules),
    LINX_ (__NR_mseal,                  sys_mseal),
    LINX_ (__NR_futex_waitv,            sys_futex_waitv),
    LINXY (__NR_file_getattr,           sys_file_getattr),
index 82b67afe348af2ccb7a9d2ba2125eddc0a5ec772..03773ebc99aeeeae207892ba2ed0742ccdd7c741 100644 (file)
@@ -1087,8 +1087,9 @@ static SyscallTableEntry syscall_table[] = {
    LINX_ (__NR_fchmodat2,        sys_fchmodat2),         // 452
    LINXY (__NR_statmount,        sys_statmount),         // 457
    LINXY (__NR_listmount,        sys_listmount),         // 458
-   LINXY(__NR_lsm_get_self_attr, sys_lsm_get_self_attr), // 459
-   LINX_(__NR_lsm_set_self_attr, sys_lsm_set_self_attr), // 460
+   LINXY (__NR_lsm_get_self_attr,sys_lsm_get_self_attr), // 459
+   LINX_ (__NR_lsm_set_self_attr,sys_lsm_set_self_attr), // 460
+   LINXY (__NR_lsm_list_modules, sys_lsm_list_modules),  // 461
    LINX_ (__NR_mseal,            sys_mseal),             // 462
    LINXY (__NR_file_getattr,     sys_file_getattr),      // 468
    LINX_ (__NR_file_setattr,     sys_file_setattr),      // 469
index 445ee30f39582af47a05fa6b7deac71a567dfe1f..56fe34aa5082b6dc7863bc9341dda3eb900762c2 100644 (file)
@@ -1065,8 +1065,9 @@ static SyscallTableEntry syscall_table[] = {
    LINX_ (__NR_fchmodat2,        sys_fchmodat2),         // 452
    LINXY (__NR_statmount,        sys_statmount),         // 457
    LINXY (__NR_listmount,        sys_listmount),         // 458
-   LINXY(__NR_lsm_get_self_attr, sys_lsm_get_self_attr), // 459
-   LINX_(__NR_lsm_set_self_attr, sys_lsm_set_self_attr), // 460
+   LINXY (__NR_lsm_get_self_attr,sys_lsm_get_self_attr), // 459
+   LINX_ (__NR_lsm_set_self_attr,sys_lsm_set_self_attr), // 460
+   LINXY (__NR_lsm_list_modules, sys_lsm_list_modules),  // 461
    LINX_ (__NR_mseal,            sys_mseal),             // 462
    LINXY (__NR_file_getattr,     sys_file_getattr),      // 468
    LINX_ (__NR_file_setattr,     sys_file_setattr),      // 469
index 92e279485435eb7df544170c135c35e41d82bc94..a495d09d098aeda168bca44f4759d655ba6c580d 100644 (file)
@@ -610,6 +610,7 @@ static SyscallTableEntry syscall_main_table[] = {
    LINXY(__NR_listmount, sys_listmount),                           /* 458 */
    LINXY(__NR_lsm_get_self_attr, sys_lsm_get_self_attr),           /* 459 */
    LINX_(__NR_lsm_set_self_attr, sys_lsm_set_self_attr),           /* 460 */
+   LINXY(__NR_lsm_list_modules, sys_lsm_list_modules),             /* 461 */
    LINX_(__NR_mseal, sys_mseal),                                   /* 462 */
    LINXY(__NR_file_getattr, sys_file_getattr),                     /* 468 */
    LINX_(__NR_file_setattr, sys_file_setattr),                     /* 469 */
index 0b5d436b053ca1c9b028a172815f6abd157add95..dc8b0d9e7c4b726106630f0126702a672696bf28 100644 (file)
@@ -900,8 +900,9 @@ static SyscallTableEntry syscall_table[] = {
    LINX_ (__NR_fchmodat2, sys_fchmodat2),                             // 452
    LINXY (__NR_statmount, sys_statmount),                             // 457
    LINXY (__NR_listmount, sys_listmount),                             // 458
-   LINXY(__NR_lsm_get_self_attr, sys_lsm_get_self_attr),              // 459
-   LINX_(__NR_lsm_set_self_attr, sys_lsm_set_self_attr),              // 460
+   LINXY (__NR_lsm_get_self_attr, sys_lsm_get_self_attr),             // 459
+   LINX_ (__NR_lsm_set_self_attr, sys_lsm_set_self_attr),             // 460
+   LINXY (__NR_lsm_list_modules, sys_lsm_list_modules),               // 461
    LINX_ (__NR_mseal, sys_mseal),                                     // 462
    LINXY (__NR_file_getattr, sys_file_getattr),                       // 468
    LINX_ (__NR_file_setattr, sys_file_setattr),                       // 469
index 1165304da3d67db91d7334dec5fcc131100d7807..922585a87a0caf648a89b0cd14d7d8213ef0f45c 100644 (file)
@@ -1692,6 +1692,7 @@ static SyscallTableEntry syscall_table[] = {
    LINXY(__NR_listmount,         sys_listmount),         // 458
    LINXY(__NR_lsm_get_self_attr, sys_lsm_get_self_attr), // 459
    LINX_(__NR_lsm_set_self_attr, sys_lsm_set_self_attr), // 460
+   LINXY(__NR_lsm_list_modules,  sys_lsm_list_modules),  // 461
    LINX_(__NR_mseal,             sys_mseal),             // 462
    LINXY(__NR_file_getattr,      sys_file_getattr),      // 468
    LINX_(__NR_file_setattr,      sys_file_setattr),      // 469
index 231372af4306c15e34db059e218fbe3b5af6a94e..f022c1ff3ef1c60f3db9a377d3e06c28511787a1 100644 (file)
@@ -62,6 +62,7 @@
 #define __NR_listmount         458
 #define __NR_lsm_get_self_attr 459
 #define __NR_lsm_set_self_attr 460
+#define __NR_lsm_list_modules   461
 #define __NR_mseal             462
 #define __NR_file_getattr      468
 #define __NR_file_setattr      469