From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796379759; b=5RSJyE+yNhU8VJOr+nqh4b6U6SV7VBCiJPcmzVbuMCW7VcDtVu5/zScGHmkSdwv8EkDb QRe3VUL11K8+UmHda5PlHlp0m5uEJOjsB1o/b9qsAHT+fFQHBp8OBs7xSSrV4WJa3smhl AzNOGBl3x5jGnS3XmWTPmW5CgkOnxlkzZTWaTxWRtr76YYJpMh7TPW8abH/W51HCWhPPR Hva96YbOUH8dwm58JqRqizNLuD/e9vIzTKd2x3LoVeYT1sA/JQ+JiaAPN8avv5eyHL2Lh BXidqtlFXIK6ZZKHvY0ZzpWqjnznzIpzUTurPKa+hvswptK30uem4dMtn8DoeDhTHiQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796379759; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=ZhEDqVl1ZswosI3DTbmo5pFG1CxhGISwgprzq7XOJxQ=; b=vKaq6sARrNto0A1zldfLszTEmE6Wm6FQOZuxOtOS+W/F9kA08Q6plUr0mk2KkRDp01eQ bEDbq2mrQiJ5t/KymPeVU+56E64f9U3DCr2aVWn4ynCq9RbpaABjLpeJ62QSpflc2XxPM 7QXWeD85NRitREuSkL1KiMQRhY8Z1+ExzfkjJPQIxAsQPN4z9x/prtTgFzTHR5qs7GkK5 neNO/kymAyCBeo58lrbRpduec/AikVyyvgtGeAdUJaD1kQno27++E7Y7Q3i3Kr1qDXFae vIAvh/ri9bo/NHjIUQOfQMEUGpQW7FmHK4SzxsvQAyYboZluNmiwJDDpzYRUO4BN5mg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=dpgye7n6; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3C16C606A32D; Fri, 4 Dec 2026 10:22:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=dpgye7n6 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8AA0A1F000CE; Fri, 4 Dec 2026 10:22:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796379759; bh=ZhEDqVl1ZswosI3DTbmo5pFG1CxhGISwgprzq7XOJxQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=dpgye7n6VbuGcxCs6wRAtoDv9aDtvqt4G3oE9HixMfMseeK/LufwlkXBoYBeik/wA NtBTO3fDHJsWF+YeeCFlhWcNzTb6nL7HPv6Hbm5c/M/hVoSCJ1O7c4ak+kB7+0hxqz DK0Kaljw7KFaDvH6NcJEgde/4V4O9a8yDFg0Jlm4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Alexei Starovoitov , KaFai Wan , Leon Hwang , Tiezhu Yang , Eduard Zingerman , Sasha Levin Subject: [PATCH 6.12 039/555] bpf: Reject programs with inlined helpers if JIT is not available Date: Fri, 4 Dec 2026 19:01:22 +0900 Message-ID: <20261204100607.341791589@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100603.988357525@linuxfoundation.org> References: <20261204100603.988357525@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Tiezhu Yang [ Upstream commit f1c27922576edccb99d0257827d09bd05c0304a6 ] When an architecture (such as LoongArch, ARM64, and RISC-V) implements bpf_jit_inlines_helper_call(), the verifier skips rewriting the helper call offset (insn->imm) in bpf_do_misc_fixups(). This is because the helper is expected to be inlined by the JIT compiler later. Therefore, insn->imm remains as the raw helper enum ID. However, if JIT is disabled at runtime (net.core.bpf_jit_enable=0) or if JIT compilation fails dynamically (e.g., due to OOM), the program falls back to the BPF interpreter. When the interpreter executes (__bpf_call_base + insn->imm) with the unpatched raw ID, it jumps into an invalid address space, triggering an instruction alignment fault or a kernel panic. Although these helpers have valid C implementations in the kernel, the omission of offset rewriting makes runtime interpreter fallback fatal. Fix this by setting 'prog->jit_required = 1' when helper call rewriting is skipped for JIT inlining. This ensures that such programs are safely rejected if JIT is not available, preventing the runtime kernel panic. Fixes: 2ddec2c80b44 ("riscv, bpf: inline bpf_get_smp_processor_id()") Suggested-by: Alexei Starovoitov Suggested-by: KaFai Wan Acked-by: Leon Hwang Signed-off-by: Tiezhu Yang Signed-off-by: Eduard Zingerman [edit] Apply the bpf_do_misc_fixups() change from kernel/bpf/fixups.c to do_misc_fixups() in kernel/bpf/verifier.c. Signed-off-by: Leon Hwang Signed-off-by: Sasha Levin --- kernel/bpf/verifier.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index f25dfaecb3732..4b1d89ec02a8f 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -21546,8 +21546,10 @@ static int do_misc_fixups(struct bpf_verifier_env *env) } /* Skip inlining the helper call if the JIT does it. */ - if (bpf_jit_inlines_helper_call(insn->imm)) + if (bpf_jit_inlines_helper_call(insn->imm)) { + prog->jit_required = 1; goto next_insn; + } if (insn->imm == BPF_FUNC_get_route_realm) prog->dst_needed = 1; -- 2.53.0