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=1796379330; b=eaT6hl/I+853MCxmoU7PBKMOcBG+soZMykQr8StagFboFzdefp4ZI5GvQ2d4aQHZFk1k vovshaXYEPW1APXablqmhyB1ylmgNnCp3esDR8Hhu4O7190zYUj2gnIKBFYW4U7Rt/Utf k8rPL1rAMnkM6xkito295gm9unoRb5ZkUY8d9w86wT+2Ozc3NKpk2moopMCnh+W6/BkTo PTyGSjpFQQokGdxt44NYYQ7zjHV5JMXYcNLZ+1xJleJl0MW1GZnDzP/Weg6KuKTmGM3g6 0tvST+EKVBmU7qgfMZTfGH3Jhr3Wx5fWpiAGFTb2K9CwDh/QsjX4u8Zh5wwg2NIy+SA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796379330; 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=9naCfzBi8mJsg9I1LON4+WKIKwAbSShyLfu2qvgdY+o=; b=Dbnf0MItjQkn6hJQfKhGeN0cx/YySnZ8I/7n4rZ/gkRqC8+Fb8RClIxGa6MKjQwaZyKO PRTzQzdXF+/1HbKOrGBXWnEB2U2dHhGxxkbegEwsfi9Goong/otYrAGRzikJBsgUkbyEs 0jE0L52abvJ0DtctbcZB3pHpSEVCoh3MtnszGogW5zicPwE4up3ZeDorYv/eeQCIbRNUn +p2m3A7QfhaogljMypEluGiXXiswuS/b9jN77dBkRWPSs7UMwV2ZHRqunZ4Dfjm+R9MRm arWYlChBXWNBC3wZ6S6S8fusSyqodGwe4vbk+JDut7lMXS1q2cHuuA4M6xb0Sm5mJBQ== 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=a5hhTaXU; 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 3EE8E606A332; Fri, 4 Dec 2026 10:15:30 +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=a5hhTaXU Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB6FA1F00897; Fri, 4 Dec 2026 10:15:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796379330; bh=9naCfzBi8mJsg9I1LON4+WKIKwAbSShyLfu2qvgdY+o=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=a5hhTaXUX9htYk+04Tiio2pP/TXRF5kFuAUWh8HJJifo+L6TBX5opUfypxPRgtoFi olScjUDdHFBaVTNHSU49/DoYY3fNBTZIbkGhPg9gdtiHmnYwrxS1h0S9+X8CBqnuLs TEfNfGYqV3/qVli1c5ZAkSpoojXrB5nDRcE2tYWo= 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.18 015/703] bpf: Reject programs with inlined helpers if JIT is not available Date: Fri, 4 Dec 2026 18:58:34 +0900 Message-ID: <20261204100627.956900083@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@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.18-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 32bb4c3f70fba..d62d844ae3f86 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -23155,8 +23155,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