mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [Question] About SECCOMP issue for ILP32
@ 2020-08-31 12:48 Xiongfeng Wang
  2020-08-31 18:15 ` Yury Norov
  0 siblings, 1 reply; 5+ messages in thread
From: Xiongfeng Wang @ 2020-08-31 12:48 UTC (permalink / raw)
  To: yury.norov; +Cc: bobo.shaobowang, wangxiongfeng2, Linux Kernel Mailing List

Hi Yury,

We were testing the ILP32 feature and came accross a problem. Very apperaciate
it if you could give us some help !

We compile the LTP testsuite with '-mabi=ilp32' and run it on a machine with
kernel and glibc applied with ILP32 patches. But we failed on one testcase,
prctl04. It print the following error info.
'prctl04.c:199: FAIL: SECCOMP_MODE_STRICT doesn't permit read(2) write(2) and
_exit(2)'

The testcase is like below, syscall 'prctl' followed by a syscall 'write'.
prctl(PR_SET_SECCOMP, SECCOMP_MODE_STRICT);
SAFE_WRITE(1, fd, "a", 1);

When we execute syscall 'write', we receive a SIGKILL. It's not as expected.
We track the kernel and found out it is because we failed the syscall_whitelist
check in '__secure_computing_strict'. Because flag 'TIF_32BIT_AARCH64' is set,
we falls into the 'in_compat_syscall()' branch. We compare the parameter
'this_syscall' with return value of 'get_compat_model_syscalls()'
The syscall number of '__NR_write' for ilp32 application is 64, but it is 4 for
'model_syscalls_32' returned from 'get_compat_model_syscalls()'
So '__secure_computing_strict' retuned with 'do_exit(SIGKILL)'. We have a
modification like below, but I am not sure if it correct or not.

--- a/kernel/seccomp.c
+++ b/kernel/seccomp.c
@@ -618,7 +618,7 @@ static void __secure_computing_strict(int this_syscall)
 {
        const int *syscall_whitelist = mode1_syscalls;
 #ifdef CONFIG_COMPAT
-       if (in_compat_syscall())
+       if (is_a32_compat_task())
                syscall_whitelist = get_compat_mode1_syscalls();
 #endif
        do {


Thanks,
Xiongfeng


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-12-16 12:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-31 12:48 [Question] About SECCOMP issue for ILP32 Xiongfeng Wang
2020-08-31 18:15 ` Yury Norov
2020-09-01 11:40   ` Xiongfeng Wang
2021-12-16 12:03     ` Xiongfeng Wang
2020-11-25 18:14   ` Yury Norov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®