Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

selftests/seccomp: Change the syscall used in KILL_THREAD test

The Bionic version of pthread_create used on Android calls the prctl
function to give the stack and thread local storage a useful name. This
will cause the KILL_THREAD test to fail as it will kill the thread as
soon as it is created.

change the test to use getpid instead of prctl.

Signed-off-by: Terry Tritton <terry.tritton@linaro.org>
Link: https://lore.kernel.org/r/20240124141357.1243457-3-terry.tritton@linaro.org
Signed-off-by: Kees Cook <keescook@chromium.org>

authored by

Terry Tritton and committed by
Kees Cook
471dbc54 ecaaa55c

+4 -4
+4 -4
tools/testing/selftests/seccomp/seccomp_bpf.c
··· 784 784 bool die = (bool)data; 785 785 786 786 if (die) { 787 - prctl(PR_GET_SECCOMP, 0, 0, 0, 0); 787 + syscall(__NR_getpid); 788 788 return (void *)SIBLING_EXIT_FAILURE; 789 789 } 790 790 ··· 803 803 { 804 804 pthread_t thread; 805 805 void *status; 806 - /* Kill only when calling __NR_prctl. */ 806 + /* Kill only when calling __NR_getpid. */ 807 807 struct sock_filter filter_thread[] = { 808 808 BPF_STMT(BPF_LD|BPF_W|BPF_ABS, 809 809 offsetof(struct seccomp_data, nr)), 810 - BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_prctl, 0, 1), 810 + BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_getpid, 0, 1), 811 811 BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_KILL_THREAD), 812 812 BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW), 813 813 }; ··· 819 819 struct sock_filter filter_process[] = { 820 820 BPF_STMT(BPF_LD|BPF_W|BPF_ABS, 821 821 offsetof(struct seccomp_data, nr)), 822 - BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_prctl, 0, 1), 822 + BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_getpid, 0, 1), 823 823 BPF_STMT(BPF_RET|BPF_K, kill), 824 824 BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW), 825 825 };