* [PATCH] ARM: ptrace: fix scno of -1 cause SIGILL
@ 2023-07-24 12:16 Lecopzer Chen
2023-08-07 7:53 ` Lecopzer Chen
0 siblings, 1 reply; 2+ messages in thread
From: Lecopzer Chen @ 2023-07-24 12:16 UTC (permalink / raw)
To: arnd, linux-arm-kernel, linux-kernel
Cc: linux, linus.walleij, yj.chiang, Lecopzer Chen
In commit [1], the -1 scno is used as a special scno when the task's
syscall is traced.
After commit [2], PTRACE_SET_SYSCALL will always mask syscall with
__NR_SYSCALL_MASK, this makes the condition `cmp scno, #-1` broken,
and some test like Android VTS[3] is also failed because SIGILL
interrupt the test program.
Let's test with `and` logic with #0x0ff000. Instead of #__NR_SYSCALL_MASK
because of the constraint of ARM Operand2 rules and avoid conflicting
with ARM private syscall.
[1] commit ad75b51459ae ("ARM: 7579/1: arch/allow a scno of -1 to not cause a SIGILL")
[2] commit 4e57a4ddf6b0 ("ARM: 9107/1: syscall: always store thread_info->abi_syscall")
[3] vts_linux_kselftest_arm_32 seccomp_seccomp_bpf_arm_32#seccomp_seccomp_bpf_arm_32
Fixes: 4e57a4ddf6b0 ("ARM: 9107/1: syscall: always store thread_info->abi_syscall")
Signed-off-by: Lecopzer Chen <lecopzer.chen@mediatek.com>
---
arch/arm/kernel/entry-common.S | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
index bcc4c9ec3aa4..8ff3ff476266 100644
--- a/arch/arm/kernel/entry-common.S
+++ b/arch/arm/kernel/entry-common.S
@@ -298,8 +298,15 @@ __sys_trace:
bl syscall_trace_enter
mov scno, r0
invoke_syscall tbl, scno, r10, __sys_trace_return, reload=1
- cmp scno, #-1 @ skip the syscall?
- bne 2b
+ /*
+ * We'd like to skip scno=-1 for avoiding SIGILL for tracer,
+ * however, tracer or seccomp may have changed syscall and masked
+ * with __NR_SYSCALL_MASK, make sure -1 is compared with correct
+ * masked syscall number.
+ */
+ and r10, scno, #0x0ff000
+ cmp r10, #0x0ff000
+ bne 2b
add sp, sp, #S_OFF @ restore stack
__sys_trace_return_nosave:
--
2.18.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ARM: ptrace: fix scno of -1 cause SIGILL
2023-07-24 12:16 [PATCH] ARM: ptrace: fix scno of -1 cause SIGILL Lecopzer Chen
@ 2023-08-07 7:53 ` Lecopzer Chen
0 siblings, 0 replies; 2+ messages in thread
From: Lecopzer Chen @ 2023-08-07 7:53 UTC (permalink / raw)
To: lecopzer.chen
Cc: arnd, linus.walleij, linux-arm-kernel, linux-kernel, linux, yj.chiang
> In commit [1], the -1 scno is used as a special scno when the task's
> syscall is traced.
> After commit [2], PTRACE_SET_SYSCALL will always mask syscall with
> __NR_SYSCALL_MASK, this makes the condition `cmp scno, #-1` broken,
> and some test like Android VTS[3] is also failed because SIGILL
> interrupt the test program.
> Let's test with `and` logic with #0x0ff000. Instead of #__NR_SYSCALL_MASK
> because of the constraint of ARM Operand2 rules and avoid conflicting
> with ARM private syscall.
...
Please follow the commit from Kees below and ignore this patch, thanks.
https://lore.kernel.org/all/20230804071045.never.134-kees@kernel.org/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-08-07 7:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-24 12:16 [PATCH] ARM: ptrace: fix scno of -1 cause SIGILL Lecopzer Chen
2023-08-07 7:53 ` Lecopzer Chen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).