Skip to content

Commit 9bc0f52

Browse files
Terry TrittonMa Wupeng
authored andcommitted
selftests/seccomp: Change the syscall used in KILL_THREAD test
stable inclusion from stable-v6.6.30 commit f4b1e2cc9fd4c87adca18cc5efa0470c8d976c51 bugzilla: https://gitee.com/openeuler/kernel/issues/I9MPZ8 Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=f4b1e2cc9fd4c87adca18cc5efa0470c8d976c51 -------------------------------- commit 471dbc547612adeaa769e48498ef591c6c95a57a 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> Signed-off-by: ZhangPeng <zhangpeng362@huawei.com>
1 parent 86ed652 commit 9bc0f52

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
@@ -791,7 +791,7 @@ void *kill_thread(void *data)
791791
bool die = (bool)data;
792792

793793
if (die) {
794-
prctl(PR_GET_SECCOMP, 0, 0, 0, 0);
794+
syscall(__NR_getpid);
795795
return (void *)SIBLING_EXIT_FAILURE;
796796
}
797797

@@ -810,11 +810,11 @@ void kill_thread_or_group(struct __test_metadata *_metadata,
810810
{
811811
pthread_t thread;
812812
void *status;
813-
/* Kill only when calling __NR_prctl. */
813+
/* Kill only when calling __NR_getpid. */
814814
struct sock_filter filter_thread[] = {
815815
BPF_STMT(BPF_LD|BPF_W|BPF_ABS,
816816
offsetof(struct seccomp_data, nr)),
817-
BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_prctl, 0, 1),
817+
BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_getpid, 0, 1),
818818
BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_KILL_THREAD),
819819
BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW),
820820
};
@@ -826,7 +826,7 @@ void kill_thread_or_group(struct __test_metadata *_metadata,
826826
struct sock_filter filter_process[] = {
827827
BPF_STMT(BPF_LD|BPF_W|BPF_ABS,
828828
offsetof(struct seccomp_data, nr)),
829-
BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_prctl, 0, 1),
829+
BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, __NR_getpid, 0, 1),
830830
BPF_STMT(BPF_RET|BPF_K, kill),
831831
BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW),
832832
};

0 commit comments

Comments
 (0)