[Devel] [PATCH vz10 2/3] selftests: cgroup: give the O_TMPFILE open in get_temp_fd() a mode
Eva Kurchatova
eva.kurchatova at virtuozzo.com
Tue Sep 1 01:36:23 MSK 2026
O_TMPFILE, like O_CREAT, needs the third argument. Without it glibc
refuses the call at compile time as soon as fortification is on:
In function 'open',
inlined from 'get_temp_fd' at cgroup_util.c:24:9:
/usr/include/bits/fcntl2.h:50:11: error: call to '__open_missing_mode'
declared with attribute error: open with O_CREAT or O_TMPFILE in
second argument needs 3 arguments
cgroup/Makefile builds with "-Wall -pthread" and the fortify checks
take effect only once the compiler optimises, so the cgroup target
builds. kvm includes ../cgroup/lib/libcgroup.mk and does
build with -O2, so the shared object fails there and takes the whole
kvm target with it. Building with -D_FORTIFY_SOURCE=3, as distributions
commonly do, therefore loses every kvm test rather than anything in
cgroup.
Fixes: 844934d16dbc ("selftests/cgroup: move get_temp_fd() to the shared cgroup lib")
https://virtuozzo.atlassian.net/browse/VSTOR-139672
Feature: fix selftests
Signed-off-by: Eva Kurchatova <eva.kurchatova at virtuozzo.com>
---
tools/testing/selftests/cgroup/lib/cgroup_util.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/cgroup/lib/cgroup_util.c b/tools/testing/selftests/cgroup/lib/cgroup_util.c
index 9a677fdf0bf6..8f996b54849e 100644
--- a/tools/testing/selftests/cgroup/lib/cgroup_util.c
+++ b/tools/testing/selftests/cgroup/lib/cgroup_util.c
@@ -21,7 +21,7 @@
int get_temp_fd(void)
{
- return open(".", O_TMPFILE | O_RDWR | O_EXCL);
+ return open(".", O_TMPFILE | O_RDWR | O_EXCL, 0600);
}
/* Returns read len on success, or -errno on failure. */
--
2.55.0
More information about the Devel
mailing list