Skip to content

Commit 0eba298

Browse files
Terry TrittonSasha Levin
authored andcommitted
selftests/seccomp: Change the syscall used in KILL_THREAD test
commit 471dbc5 upstream. 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 8b7423a commit 0eba298

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

tools/testing/selftests/seccomp/seccomp_bpf.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ void *kill_thread(void *data)
784784
bool die = (bool)data;
785785

786786
if (die) {
787-
prctl(PR_GET_SECCOMP, 0, 0, 0, 0);
787+
syscall(__NR_getpid);
788788
return (void *)SIBLING_EXIT_FAILURE;
789789
}
790790

@@ -803,11 +803,11 @@ void kill_thread_or_group(struct __test_metadata *_metadata,
803803
{
804804
pthread_t thread;
805805
void *status;
806-
/* Kill only when calling __NR_prctl. */
806+
/* Kill only when calling __NR_getpid. */
807807
struct sock_filter filter_thread[] = {
808808
BPF_STMT(BPF_LD|BPF_W|BPF_ABS,
809809
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),
811811
BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_KILL_THREAD),
812812
BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW),
813813
};
@@ -819,7 +819,7 @@ void kill_thread_or_group(struct __test_metadata *_metadata,
819819
struct sock_filter filter_process[] = {
820820
BPF_STMT(BPF_LD|BPF_W|BPF_ABS,
821821
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),
823823
BPF_STMT(BPF_RET|BPF_K, kill),
824824
BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW),
825825
};

0 commit comments

Comments
 (0)