memfd_secret introduced in kernel 5.14. According to https://lwn.net/Articles/865256/, "memfd_secret() was disabled by default and a command-line option (secretmem_enable=) was added to enable it at boot time." $ cat /proc/cmdline BOOT_IMAGE=(hd0,msdos1)/vmlinuz-5.15.0-0.rc4.33.fc36.x86_64 root=UUID=6fd107e8-438a-48a2-915e-651e43fb438e ro rootflags=subvol=root rhgb quiet secretmem.enable=y $ cat memfd_secret.c #define _GNU_SOURCE #include <unistd.h> #include <sys/syscall.h> #include <fcntl.h> #include <err.h> #include <stdio.h> #include <errno.h> int main(void){ printf("memfd_secret demo prog\n"); int fd; fd = syscall(SYS_memfd_secret, O_CLOEXEC); printf("fd = %d\n", fd); printf("errno = %d\n", errno); return 0; } $ gcc -o test memfd_secret.c $ ./test memfd_secret demo prog fd = 3 errno = 0
Created attachment 147839 [details] [patch] memfd test should be memfd_create test memfd test should be memfd_create test Currently, syscall memfd_create was tested by this: $ perl tests/vg_regtest memcheck/tests/linux/memfd.vgtest Since memfd_secret introduced in kernel 5.14, valgrind should rename the "memfd" test to "memfd_create" test to avoid the ambiguity, so that user will not get confused with the "memfd_secret" test. After this change, syscall memfd_create will be tested by: $ perl tests/vg_regtest memcheck/tests/linux/memfd_create.vgtest
Looks like my email about this to your @outlook.com address bounced. So just in case you didn't see it: Thanks, that applied fine. And I admit having been confused by memfd_create vs memfd_secret before. I have pushed this. Hope that helps creating a separate memfd_secret. But we are very close to the 3.19.0 release. So that might have to wait till after the release.
Created attachment 148223 [details] [patch v1] Support new memfd_secret linux syscall (447) This patch supports memfd_secret across these arches: arm64, amd64(x86_64), x86(i386) according to this link[1]. This patch does not contain a corresponding test case. [1] https://marcin.juszkiewicz.com.pl/download/tables/syscalls.html
I can see how adding a testcase is somewhat tricky if it depends on whether it is enabled by a boot flag. But the code looks correct. Pushed as: commit fca4a3d8e59c29bc7d239ff4de72b1260c0c23ee Author: Di Chen <dichen@redhat.com> Date: Fri Apr 15 00:08:17 2022 +0800 Support new memfd_secret linux syscall (447) memfd_secret is a new syscall in linux 5.14. memfd_secret() is disabled by default and a command-line option needs to be added to enable it at boot time. $ cat /proc/cmdline [...] secretmem.enable=y https://bugs.kde.org/451878 https://lwn.net/Articles/865256/ Thanks