selftests: vDSO: fix compile error for vdso_test_getrandom
Subsystems (2)
PATCH 1/1 selftests: vDSO: fix compile error for vdso_test_getrandom
When building selftests/vDSO:
$ make -C tools/testing/selftests TARGETS=vDSO I hit the following compilation error:
vdso_test_getrandom.c:260:17: error: 'CLONE_NEWTIME' undeclared (first use in this function); did you mean 'CLONE_NEWIPC'?
260 | assert(unshare(CLONE_NEWTIME) == 0);
| ^~~~~~~~~~~~~CLONE_NEWTIME is defined in linux/sched.h, so fix this by including <linux/sched.h>.
--- tools/testing/selftests/vDSO/vdso_test_getrandom.c | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/vDSO/vdso_test_getrandom.c +1 -0
@@ -19,6 +19,7 @@#include <sys/ptrace.h> #include <sys/wait.h> #include <sys/types.h> +#include <linux/sched.h> #include <linux/random.h> #include <linux/compiler.h> #include <linux/ptrace.h>
Signature · 1 line
2.33.0
Shuah Khan
maintainerQuoted 23 lines · Yu Liao
When building selftests/vDSO:
$ make -C tools/testing/selftests TARGETS=vDSO I hit the following compilation error:vdso_test_getrandom.c:260:17: error: '
CLONE_NEWTIME' undeclared (first use in this function); did you mean 'CLONE_NEWIPC'?260 | assert(unshare(CLONE_NEWTIME) == 0); | ^~~~~~~~~~~~~
CLONE_NEWTIMEis defined inlinux/sched.h, so fix this by including <linux/sched.h>.Fixes 2aec90036dcd ("selftests: vDSO: ensure vgetrandom works in a time namespace")Signed-off-by Yu Liao <[email protected]>--- tools/testing/selftests/vDSO/vdso_test_getrandom.c | 1 + 1 file changed, 1 insertion(+)tools/testing/selftests/vDSO/vdso_test_getrandom.c +0
-0
tools/testing/selftests/vDSO/vdso_test_getrandom.c line 25
Quoted 7 lines
tools/testing/selftests/vDSO/vdso_test_getrandom.c +1
-0@@ -19,6 +19,7 @@#include <sys/ptrace.h> #include <sys/wait.h> #include <sys/types.h> +#include <linux/sched.h> #include <linux/random.h> #include <linux/compiler.h> #include <linux/ptrace.h>
Do you see this error after installing headers? Installing headers is a dependency to be able to compile selftests.
thanks,
-- Shuah
Quoted 8 lines · Shuah Khan
Quoted 8 lines
tools/testing/selftests/vDSO/vdso_test_getrandom.c +0
-0@@ -19,6 +19,7 @@ #include <sys/ptrace.h> #include <sys/wait.h>
Quoted 9 lines
tools/testing/selftests/vDSO/vdso_test_getrandom.c line 25
Quoted 5 lines
tools/testing/selftests/vDSO/vdso_test_getrandom.c +1
-0#include <sys/types.h> +#include <linux/sched.h> #include <linux/random.h> #include <linux/compiler.h> #include <linux/ptrace.h>Do you see this error after installing headers? Installing headers is a dependency to be able to compile selftests.
Yes, this error still exists after installing header files. Here are my steps to reproduce:
make headers_install
make -C tools/testing/selftests TARGETS=vDSO
After applying the patch, the error no longer appears.
Best regards,
Yu
Le 20/09/2024 à 03:54, Yu Liao a écrit :
Quoted 4 lines
[Vous ne recevez pas souvent de courriers de [email protected]. Découvrez pourquoi ceci est important à https://aka.ms/LearnAboutSenderIdentification ]
On 2024/9/20 0:51, Shuah Khan wrote:
Quoted 10 lines
Quoted 10 lines
tools/testing/selftests/vDSO/vdso_test_getrandom.c line 22
Quoted 10 lines
tools/testing/selftests/vDSO/vdso_test_getrandom.c +1
-0@@ -19,6 +19,7 @@#include <sys/ptrace.h> #include <sys/wait.h> #include <sys/types.h> +#include <linux/sched.h>
This not correct. According to man page of clone(2), CLONE_ macros are in <sched.h>, you should include <sched.h> instead.
See https://man7.org/linux/man-pages/man2/clone.2.html
By the way on my environment (gcc 12.2 + glibc 2.38), <sched.h> gets already indirectly included by <phread.h>, and at the end the CLONE_NEWTIME is in glibc headers in usr/include/bits/sched.h
Quoted 18 lines
Quoted 7 lines
tools/testing/selftests/vDSO/vdso_test_getrandom.c line 25
Quoted 3 lines
tools/testing/selftests/vDSO/vdso_test_getrandom.c +0
-0#include <linux/random.h> #include <linux/compiler.h> #include <linux/ptrace.h> Do you see this error after installing headers? Installing headers is a dependency to be able to compile selftests.
Yes, this error still exists after installing header files. Here are my steps to reproduce:
make
headers_install
make -Ctools/testing/selftestsTARGETS=vDSOAfter applying the patch, the error no longer appears.
Best regards,
Yu
Indeed probably <sched.h> is what's wanted here.
Shuah - I was taking patches for this code during the 6.12 development cycle, because it all interacted with the dev work I was doing. But I think that's died down now and things can return to normal. Do you want to take these like you usually do now? Or is that annoying because your tree won't be based on them for another cycle, so I should still do it? I'm okay with doing whatever you want.
Jason
Shuah Khan
maintainerQuoted 2 lines · Jason A. Donenfeld
Indeed probably <
sched.h> is what's wanted here.
Yu Liao, Please send v2 as per the review comments.
Quoted 8 lines
Shuah - I was taking patches for this code during the 6.12 development cycle, because it all interacted with the dev work I was doing. But I think that's died down now and things can return to normal. Do you want to take these like you usually do now? Or is that annoying because your tree won't be based on them for another cycle, so I should still do it? I'm okay with doing whatever you want.
Jason
I can take this through my tree - I rebase as soon as rc1 comes out. We can also handshake as needed if there are conflicts still.
thanks,
-- Shuah
Hi,
Quoted 6 lines · Shuah Khan
Quoted 2 lines · Jason A. Donenfeld
Indeed probably <
sched.h> is what's wanted here.Yu Liao, Please send v2 as per the review comments.
CLONE_NEWTIME was introduced in glibc-2.36, which was released in August 2022. As Christophe mentioned, <sched.h> is already indirectly included by <phread.h>, so this issue does not exist if glibc version higher than 2.36.
Additionally, CLONE_NEWTIME was introduced in Linux 5.6 in March 2020, the CLONE_ macros are also defined in <linux/sched.h>, which is part of the kernel-header package.
My environment is Ubuntu 22.04 (Linux 5.15 + glibc 2.35), after upgrading to a newer version of glibc, the issue appears to be resolved.
It seems to me that including <sched.h> might be unnecessary. I would greatly appreciate your guidance on how best to handle this situation.
Best regards,
Yu
Shuah Khan
maintainerQuoted 13 lines · Yu Liao
Hi,
Quoted 6 lines · Shuah Khan
Quoted 2 lines · Jason A. Donenfeld
Indeed probably <
sched.h> is what's wanted here.Yu Liao, Please send v2 as per the review comments.
CLONE_NEWTIMEwas introduced in glibc-2.36, which was released in August 2022. As Christophe mentioned, <sched.h> is already indirectly included by <phread.h>, so this issue does not exist if glibc version higher than 2.36.
Quoted 9 lines
Additionally,
CLONE_NEWTIMEwas introduced in Linux 5.6 in March 2020, theCLONE_macros are also defined in <linux/sched.h>, which is part of the kernel-header package.My environment is Ubuntu 22.04 (Linux 5.15 + glibc 2.35), after upgrading to a newer version of glibc, the issue appears to be resolved.
It seems to me that including <sched.h> might be unnecessary. I would greatly appreciate your guidance on how best to handle this situation.
Please send me v2 with sched.h included explicitly. It is better do do so than having it come from <phread.h> indirectly.
thanks,
-- SHuah
Quoted 3 lines · Shuah Khan
Please send me v2 with
sched.hincluded explicitly. It is better do do so than having it come from <phread.h> indirectly.
Sorry for the late response, I have sent the v2 patch.
https://lore.kernel.org/all/[email protected]/
Best regards,
Yu