FAILED: patch "[PATCH] entry: Fix seccomp bypass after ptrace with TSYNC" failed to apply to 5.10-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 5.10-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y
git checkout FETCH_HEAD
git cherry-pick -x 4a3591287fb7f808e209b4974ed337f609a2006b
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026090332-laborer-mandarin-6dec@gregkh' --subject-prefix 'PATCH 5.10.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 4a3591287fb7f808e209b4974ed337f609a2006b Mon Sep 17 00:00:00 2001
From: Jinjie Ruan <[email protected]>
Date: Mon, 13 Jul 2026 10:57:12 +0800
Subject: [PATCH] entry: Fix seccomp bypass after ptrace with TSYNC
Sashiko review pointed out the following issue.
If a thread is stopped in syscall_trace_enter() for ptrace, another thread can install a seccomp filter with SECCOMP_FILTER_FLAG_TSYNC (e.g., via seccomp_attach_filter()). This will successfully set SYSCALL_WORK_SECCOMP on the stopped thread, but syscall_trace_enter() evaluates a cached 'work' variable sampled on entry. Consequently, the subsequent check for SYSCALL_WORK_SECCOMP misses the newly assigned flag, and the filter is silently bypassed.
This race condition could allow an unprivileged process to execute a prohibited system call (e.g., execve) that the newly installed filter was intended to block, especially since the tracer might have modified the system call number during the ptrace stop.
Fix this by re-reading the syscall_work flags after ptrace handling, so that any new SYSCALL_WORK_SECCOMP flag set by another thread via TSYNC during the ptrace stop is observed before the subsequent seccomp check.
include/linux/entry-common.h +3 -0
@@ -97,6 +97,9 @@ static __always_inline long syscall_trace_enter(struct pt_regs *regs, unsigned lif (!arch_ptrace_report_syscall_permit_entry (regs) || (work &SYSCALL_WORK_SYSCALL_EMU ))return -1L ; + +/* ptrace might have changed work flags */ + work =READ_ONCE (current_thread_info ()->syscall_work); }/* Do seccomp after ptrace, to catch any tracer changes. */
Thomas Gleixner
maintainerPATCH 1/1 entry: Fix seccomp bypass after ptrace with TSYNC
From: Jinjie Ruan <[email protected]>
commit 4a3591287fb7f808e209b4974ed337f609a2006b upstream.
Sashiko review pointed out the following issue.
If a thread is stopped in syscall_trace_enter() for ptrace, another thread can install a seccomp filter with SECCOMP_FILTER_FLAG_TSYNC (e.g., via seccomp_attach_filter()). This will successfully set SYSCALL_WORK_SECCOMP on the stopped thread, but syscall_trace_enter() evaluates a cached 'work' variable sampled on entry. Consequently, the subsequent check for SYSCALL_WORK_SECCOMP misses the newly assigned flag, and the filter is silently bypassed.
This race condition could allow an unprivileged process to execute a prohibited system call (e.g., execve) that the newly installed filter was intended to block, especially since the tracer might have modified the system call number during the ptrace stop.
Fix this by re-reading the syscall_work flags after ptrace handling, so that any new SYSCALL_WORK_SECCOMP flag set by another thread via TSYNC during the ptrace stop is observed before the subsequent seccomp check.
--- kernel/entry/common.c | 3 +++ 1 file changed, 3 insertions(+)
---
kernel/entry/common.c +3 -0
@@ -51,6 +51,9 @@ static long syscall_trace_enter(struct p ret =arch_syscall_enter_tracehook (regs);if (ret || (ti_work & _TIF_SYSCALL_EMU))return -1L ; + +/* ptrace might have changed work flags */ + ti_work =READ_ONCE (current_thread_info ()->flags); }/* Do seccomp after ptrace, to catch any tracer changes. */
Re: [PATCH 5.10.y] entry: Fix seccomp bypass after ptrace with TSYNC
Quoted 6 lines
Sashiko review pointed out the following issue.
If a thread is stopped in
syscall_trace_enter()for ptrace, another thread can install a seccomp filter withSECCOMP_FILTER_FLAG_TSYNC(e.g., viaseccomp_attach_filter()). This will successfully setSYSCALL_WORK_SECCOMPon the stopped thread, butsyscall_trace_enter()
Queued for 5.10, thanks.
Signature · 2 lines
Thanks, Sasha