From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CC0EE5437C7; Wed, 9 Sep 2026 14:15:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788963309; cv=none; b=Khs3D5J5BwJEW4urp/jewtO0j3sET/Perffb+XWh1pprnyx+wA5fmzEBd0/5pL3WKn+EK9uDOoOAhIj3w//3i/TamfHO5bUSO5bPBDLRPT+fQ2BkVOpm4/MqsqQhZ3tHQR/9SiB6xZBJ4lGu8NWPFcBSfelcFbA3oygTozZW9eY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788963309; c=relaxed/simple; bh=/j7hpLz/0FTsoucNPM46k9LjlG8UeazddgJW5DygFMw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XgKouVlDGQR57bqLPB/nWczuM36H6W0BX9UIXmBYCkRIHAVI9wYZ2XLqsU7qzRgquczrFyICVX1pKcHRWK/GEnb612PRz4K7wYzHtVVRzD3avbYDi4UTOWsuDQtYnfipl92ziM4Px9QrrApuM+nJUoHjXXdAcV0zarr2zVHznkM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=FPiGsbJ4; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="FPiGsbJ4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 308A21F00A3A; Wed, 9 Sep 2026 14:15:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1788963307; bh=wCoNcgKhSOSG4zA7MfJ6na/6Q9MS13uB8u82pbuV8zM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=FPiGsbJ4UpEOdC2pBYig8Ie9Argab3KF2BuHXPiOC3F5pQ33koTxuMxxNTRHx9fW8 WoSs+icxtIeFgRl65Jx2TTYzALN8Frz83LVrO8WSxQTRH71IrMxln/16hTcuifpe66 o0Gqqqb9Bvrx9RZgcTYz8gsth6SLgldNP10Wrd7A= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jinjie Ruan , Thomas Gleixner , Sasha Levin Subject: [PATCH 6.18 004/583] entry: Fix seccomp bypass after ptrace with TSYNC Date: Wed, 9 Sep 2026 15:34:49 +0200 Message-ID: <20260909134237.943148593@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260909134237.773280130@linuxfoundation.org> References: <20260909134237.773280130@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jinjie Ruan 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. Fixes: 142781e108b1 ("entry: Provide generic syscall entry functionality") Signed-off-by: Jinjie Ruan Signed-off-by: Thomas Gleixner Cc: stable@vger.kernel.org Link: https://lore.kernel.org/all/20260629132914.1135C1F000E9@smtp.kernel.org/ Link: https://patch.msgid.link/20260713025712.416366-1-ruanjinjie@huawei.com Signed-off-by: Sasha Levin --- kernel/entry/syscall-common.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/entry/syscall-common.c b/kernel/entry/syscall-common.c index 66e6ba7fa80c8..dbc5551935f78 100644 --- a/kernel/entry/syscall-common.c +++ b/kernel/entry/syscall-common.c @@ -37,6 +37,9 @@ long syscall_trace_enter(struct pt_regs *regs, long syscall, ret = ptrace_report_syscall_entry(regs); if (ret || (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. */ -- 2.53.0