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=1796380547; b=EcFGlZBjWTCR81zDegx1CsikSSYrnXOUmYE582cwtwMn62pyXPaLoscYqJaXPSbWdleZ 5B/mIqIKSeqop20dFZFEIdJr/x7L8C+NrLJJ4K0ozkhV8DQRtP8Rnm5U5O/mMil/3nhHy /YXez9blkKNy4ualoVF0so3TwxprE7hKlCxdYytpPvsoylewLMJGuYqZn1MSKNxpCHfm1 qw87rUso7YENa1Vn/7iMdvQmzs+mfdf3MthUiFezIXZE3UGwC3EFL3QQ7Iy/VYGXX16+S nbqFZdWLgO9TEVXCXkryYGvxS4RDF1jREl0wjuiL73tKbNmvX2Bgmiuu1eVPZju7ggw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380547; 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=TH3jj/Nt19fNmwup8YdEggHddMvaUHWc7RcYF1c8KI4=; b=FvGo5NVGcbk4m1Ct0sQ5iKjXLWHOt3F6EBZCFm8XMc1rREaRLxqe1YuySJALarZzTPba zspg1+0LfAdjhKWOQVgfeSqVyDpufa/GeNYsQCQtW1p0vj5efhJdFnS2FHsvk+GA/oq6C x6f3b7bKeFDL6wHtVbDLZ3D8Md9UfPw7TJoyie8/AmHm8vqj27oX4GNIwr7Z6uPumaRLw IWElcdAo52Qh3KTDf4d0jlIoF4JeACoZHyKsO09rs7LY4fdYS45/n0KiVgsBsF+chnYXM PuesJEb7kBfULFIh0E2QhSmEOZamzQNKyTqT6cc1+qOE/VD72f7DTgn6Drvcc0I93Pw== 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=TFKICGQc; 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 9D1D7606A681; Fri, 4 Dec 2026 10:35:47 +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=TFKICGQc Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1752B1F000C2; Fri, 4 Dec 2026 10:35:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796380547; bh=TH3jj/Nt19fNmwup8YdEggHddMvaUHWc7RcYF1c8KI4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=TFKICGQc5ky9BnVVehosBrs0EUQ6XRMM5EAcVkKek2DHnQHIGdfA2/i6LG3ochqUU LIaKYgNzjOLX8HOwX7tRbi1CdUYvcukJ69PjNOkX6OCVE+XIA3A9TtmNGwyt5GYv0E QDbQ4YU5qqWQei+5Lb9u4dhZ5Ap5ValI3WS1nRIE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Alexei Starovoitov , Sasha Levin Subject: [PATCH 7.3 322/742] bpf: Undo insn aux changes of a failed speculative path Date: Fri, 4 Dec 2026 19:03:06 +0900 Message-ID: <20261204100643.579342157@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@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 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Alexei Starovoitov [ Upstream commit fa84f87e42af9ffa3f777d4ea3b8c4f82a5a7436 ] If a check fails on a speculative path, do_check() adds a nospec before the insn and ends the path. The check can have written nospec_result and ctx_field_size of the insn already. The other paths can use the insn with another type of pointer, so these values do not apply to them. Save both fields before the check and restore them. Fixes: d6f1c85f2253 ("bpf: Fall back to nospec for Spectre v1") Signed-off-by: Alexei Starovoitov Link: https://patch.msgid.link/20261126033816.4124847-2-alexei.starovoitov@gmail.com Signed-off-by: Sasha Levin --- kernel/bpf/verifier.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index 073b7594d3980..a65af36e2b1c9 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -18667,7 +18667,8 @@ static int do_check(struct bpf_verifier_env *env) for (;;) { struct bpf_insn *insn; struct bpf_insn_aux_data *insn_aux; - int err; + int err, ctx_field_size; + bool nospec_result; /* reset current history entry on each new instruction */ env->cur_hist_ent = NULL; @@ -18805,6 +18806,8 @@ static int do_check(struct bpf_verifier_env *env) if (state->speculative && insn_aux->nospec) goto process_bpf_exit; + nospec_result = insn_aux->nospec_result; + ctx_field_size = insn_aux->ctx_field_size; err = do_check_insn(env, &do_print_state); if (error_recoverable_with_nospec(err) && state->speculative) { /* Prevent this speculative path from ever reaching the @@ -18815,6 +18818,8 @@ static int do_check(struct bpf_verifier_env *env) * markings for alu sanitization. */ insn_aux->alu_state = 0; + insn_aux->nospec_result = nospec_result; + insn_aux->ctx_field_size = ctx_field_size; goto process_bpf_exit; } else if (err < 0) { return err; -- 2.53.0