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 67A673DEFE7; Wed, 30 Sep 2026 19:32:43 +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=1790796764; cv=none; b=JINFMfYI+l76kxhIcgNs+YSpf70PMMoT86KmmuhBieUS3GP6X+A52EB5yQBArEfEQWolo41YnP4UL5cZEjG0VpWRRxj+60ScPaFSBgb5mPfa6Vi1iVmqA9utgjIyucnizMLwyevuQN/lOf+8FKfRfQwxNkZWZO+WiLWCd60x02w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790796764; c=relaxed/simple; bh=NldFUKf4EGTw9WTi5rOo/ItjgeGp6zUEEsez2haZZVw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ww6dVePAacSkVWOi69QzogYJtSx7DPVmWtR4iTIW4ivZtH664nG3zvnQT+SleivJJlvVU4OaLoXsnE0ReUYol7j/ScgGMCeBIrqQ+h5XnLbhqBJYl0f4Jk74xWGiNEXBBTEQngT3TLCTP9hcI0TShalkp7/XOD5mDYK+uGssXe8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Ztad7GzI; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Ztad7GzI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C39EF1F000FF; Wed, 30 Sep 2026 19:32:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1790796763; bh=weO7FdZGe/qYcoiiqcFHDuqSqDI6r89NZCCmPIuG1iw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Ztad7GzIdtlp5zxisIy8yKsaL2SH5i4etafbMWKB9qxAiPOsKim/15LY/HqTXeyti XhNJhO7Fg9L+mVkV1huWDglDi4AIoFk5I9GXCbDvuycjnvpjHmUZN4fkHI5uv7cQZS twhL2Pd8OVuD6LBjBuhNAlmkzdv/Hgm6nawrsrLU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Nicholas Carlini , Emil Tsalapatis , Alexei Starovoitov , Jiayuan Chen , Sasha Levin Subject: [PATCH 6.6 1027/1193] bpf: Fix bpf_sock context code generation Date: Wed, 30 Sep 2026 17:28:31 +0200 Message-ID: <20260930152457.048805348@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930152434.301151190@linuxfoundation.org> References: <20260930152434.301151190@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Emil Tsalapatis [ Upstream commit 4a4852376e3a2727ea40e61143d6d7c22bb6dfad ] Currently, the ctx access code reads the rx_queue_mapping field with either a 4-byte or 2-byte load. The rest of the bits in the register are marked known zero by the verifier. However, the emitted ctx access code places in the register on certain the special value (-1) using BPF_MOV_IMM64, which gets sign-extended to turn on all the bits in the register. By shifting this value right, the program ends up with a value at runtime above what the verifier assumes is possible. Fix this by ensuring the read value is as wide as the assumed size. Use MOV32 instructions instead of MOV64 instructions to keep the upper bits zero as assumed by the verifier. Also properly report the size of the destination variable (the bpf_sock field, 4 bytes) instead of the source (the socket field, 2 bytes). Fixes: c3c16f2ea6d2 ("bpf: Add rx_queue_mapping to bpf_sock") Reported-by: Nicholas Carlini Suggested-by: Nicholas Carlini Signed-off-by: Emil Tsalapatis Signed-off-by: Alexei Starovoitov Reviewed-by: Jiayuan Chen Link: https://patch.msgid.link/20260922172028.6269-4-emil@etsalapatis.com Signed-off-by: Sasha Levin --- net/core/filter.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/net/core/filter.c b/net/core/filter.c index d9c8eb40a1dbf..7fa77ae230edc 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -10107,11 +10107,12 @@ u32 bpf_sock_convert_ctx_access(enum bpf_access_type type, target_size)); *insn++ = BPF_JMP_IMM(BPF_JNE, si->dst_reg, NO_QUEUE_MAPPING, 1); - *insn++ = BPF_MOV64_IMM(si->dst_reg, -1); + *insn++ = BPF_MOV32_IMM(si->dst_reg, -1); #else - *insn++ = BPF_MOV64_IMM(si->dst_reg, -1); - *target_size = 2; + *insn++ = BPF_MOV32_IMM(si->dst_reg, -1); #endif + *target_size = sizeof_field(struct bpf_sock, rx_queue_mapping); + break; } -- 2.53.0