From nobody Tue Dec 16 09:30:02 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 B429521A447; Mon, 21 Apr 2025 21:48:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745272113; cv=none; b=Yq8H6Fd3rnnGlqILP3aJ3s/GHMtcshH6b5x5bUs42AFE2NDy0LhhPqNTMkSKQpRCVIBEjd4ECPEdbQHw9+moaiI4m8tz4y/i3X8w+FpuAHBmVARuUcNB9fPSjldQwCSOjA27mD1N6BmwHpdjOfhAQeeF4vWfeeD+/A1rizxDmuo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745272113; c=relaxed/simple; bh=WTDVIR1+sFTx9ueUq/qHOJEPSPM0tSDVTCdHHw99xKw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=B3DbrW+kEhDKWOc7VCCCy4/YYCSCcUHHU3PIDAyfFo7snw71Qn1Va2smeFXzEyVWkNYK9HuqSPfIr0kPqUtna7eags0Xa8WyMce11gFY5k7TFs1OM08DSWLewZQLjfK0ink+PDJ6ChJP/bEOjJrzJM0SpB3S3RApaFASVUkeMQI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lizAADCN; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lizAADCN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2FF86C4CEE4; Mon, 21 Apr 2025 21:48:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1745272113; bh=WTDVIR1+sFTx9ueUq/qHOJEPSPM0tSDVTCdHHw99xKw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lizAADCNR30JhZPRnLaVJhGe31MiWbCb8B72Slt2A5PWzV8PY5tZmq2jwWirgWoIq aF1Vuv6KhOzU8OdCvjcduBwnhHFnXwLTH0AuPknbjrOsDxZ438tnXXXhEdPwiv36ZS Dx8lpTTE4OlricBbbUp0D66ftimMLGwf5yaXZoGgSGMODxLRBPFQo3nhkk0UYTBMHn UQfzWD4WllKMZNao4eNT09pJllx9sXLxCAk4iCU1xgLQoxkWG/4NHiRbW7/r/mg49t hI3a3uGPDt81kI/dWXLDLIYlSZMp84zeKvMUqNRB0Fkp70msPJ3e83mmu0RW3gpVHW v/iMvMAHhT4Wg== From: Jiri Olsa To: Oleg Nesterov , Peter Zijlstra , Andrii Nakryiko Cc: Kees Cook , Eyal Birger , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, x86@kernel.org, Song Liu , Yonghong Song , John Fastabend , Hao Luo , Steven Rostedt , Masami Hiramatsu , Alan Maguire , David Laight , =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , Ingo Molnar Subject: [PATCH perf/core 20/22] seccomp: passthrough uprobe systemcall without filtering Date: Mon, 21 Apr 2025 23:44:20 +0200 Message-ID: <20250421214423.393661-21-jolsa@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250421214423.393661-1-jolsa@kernel.org> References: <20250421214423.393661-1-jolsa@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Adding uprobe as another exception to the seccomp filter alongside with the uretprobe syscall. Same as the uretprobe the uprobe syscall is installed by kernel as replacement for the breakpoint exception and is limited to x86_64 arch and isn't expected to ever be supported in i386. Cc: Kees Cook Cc: Eyal Birger Signed-off-by: Jiri Olsa Reviewed-by: Kees Cook --- kernel/seccomp.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/kernel/seccomp.c b/kernel/seccomp.c index 41aa761c7738..7daf2da09e8e 100644 --- a/kernel/seccomp.c +++ b/kernel/seccomp.c @@ -741,6 +741,26 @@ seccomp_prepare_user_filter(const char __user *user_fi= lter) } =20 #ifdef SECCOMP_ARCH_NATIVE +static bool seccomp_uprobe_exception(struct seccomp_data *sd) +{ +#if defined __NR_uretprobe || defined __NR_uprobe +#ifdef SECCOMP_ARCH_COMPAT + if (sd->arch =3D=3D SECCOMP_ARCH_NATIVE) +#endif + { +#ifdef __NR_uretprobe + if (sd->nr =3D=3D __NR_uretprobe) + return true; +#endif +#ifdef __NR_uprobe + if (sd->nr =3D=3D __NR_uprobe) + return true; +#endif + } +#endif + return false; +} + /** * seccomp_is_const_allow - check if filter is constant allow with given d= ata * @fprog: The BPF programs @@ -758,13 +778,8 @@ static bool seccomp_is_const_allow(struct sock_fprog_k= ern *fprog, return false; =20 /* Our single exception to filtering. */ -#ifdef __NR_uretprobe -#ifdef SECCOMP_ARCH_COMPAT - if (sd->arch =3D=3D SECCOMP_ARCH_NATIVE) -#endif - if (sd->nr =3D=3D __NR_uretprobe) - return true; -#endif + if (seccomp_uprobe_exception(sd)) + return true; =20 for (pc =3D 0; pc < fprog->len; pc++) { struct sock_filter *insn =3D &fprog->filter[pc]; @@ -1042,6 +1057,9 @@ static const int mode1_syscalls[] =3D { __NR_seccomp_read, __NR_seccomp_write, __NR_seccomp_exit, __NR_seccomp_si= greturn, #ifdef __NR_uretprobe __NR_uretprobe, +#endif +#ifdef __NR_uprobe + __NR_uprobe, #endif -1, /* negative terminated */ }; --=20 2.49.0