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 B3612149C6F for ; Sun, 12 Jul 2026 10:08:56 +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=1783850937; cv=none; b=F9rj3rPjBYYhfnuyUg3ocoRGaEeVRkbEA0JfmFljKG/iyMNL5PO2Us2SqGO1kfiEYdPdAI/ueFhEt9RVSIVMiUFbsqyHs2M4oZJz8FiEGd1t3QB8tG6kSVl3Gb2mFuCIuszECz4iRpniqr3mDsMc/vrle+DX1s0PBhG6tP9yiIM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783850937; c=relaxed/simple; bh=XVgj6QsqEd7eFwH2jeBSnxYac4Do5B0Kf7yazQ3JRCI=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=a+0EWb3B2t/S1NdVAzTutWtd1VdvGcqDttsXJ5nj7S0DTrgmfeBaYHROsH8HYXNMDDrtuojfHFv++BD2W/jEoVSJnvT4ETvALiZVTC9VEdQ6+FR+8joheBQTFb7Xtpx8b1/vpIYc8UCAuFgSXMxP69Z2pi1+J4Et5Xh/r5WoGHA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Tllgwfj6; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Tllgwfj6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 97B791F000E9; Sun, 12 Jul 2026 10:08:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1783850936; bh=QowJSIstKwwo1ptfBbTyz+grtkNu6H3hGwSQGoROmQY=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=Tllgwfj6GlYkSb2p2IjYxGF510snSMmrNgeiBzvPgnz1WzpiN49YxFJRYr+hcewFE 2mqNsCT6XCeEe/EPdKKegEnn4M7FFOSwDD2tPDbw8WeGW+I4sDHZkII+TWCzt6/1m4 pw3lgLt7XLVwz7SDLZBNVnRsc/0ryg7Hyf4OMBzj1LCc1OJiNYNu1UbYdbnwYfBT43 68aLQZyIaqSs39/14EfCmuBqRTGcfpVFrLq+j9uTknbwka4QgwS88S0b/cLTKGZYUV zr2NVRtIR0iwc6FN7BuDBMhKY6SZSJLB4/abHNkjVc6WS0pvfwY56+O92X39JO5edX FqfbV9kvaRD2g== From: Thomas Gleixner To: Jinjie Ruan , peterz@infradead.org, luto@kernel.org, kees@kernel.org, wad@chromium.org, linux-kernel@vger.kernel.org Cc: ruanjinjie@huawei.com Subject: Re: [PATCH RESEND] entry: Fix seccomp bypass after ptrace with TSYNC In-Reply-To: <20260709073030.3844316-1-ruanjinjie@huawei.com> References: <20260709073030.3844316-1-ruanjinjie@huawei.com> Date: Sun, 12 Jul 2026 12:08:53 +0200 Message-ID: <874ii4r03u.ffs@fw13> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain On Thu, Jul 09 2026 at 15:30, Jinjie Ruan wrote: > Sashiko review pointed out the following issue[1]. > > 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 replacing the cached seccomp check with a call to > seccomp_permit_syscall(), which re-reads the thread's up-to-date > TIF_SECCOMP flag and thus correctly observes the flag if it was set > during the ptrace stop. No, we are not doing this unconditionally. Thanks, tglx --- --- a/include/linux/entry-common.h +++ b/include/linux/entry-common.h @@ -98,6 +98,8 @@ static __always_inline long syscall_trac ret = arch_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. */