From mboxrd@z Thu Jan 1 00:00:00 1970 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 1D75F515964; Wed, 30 Sep 2026 16:51:35 +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=1790787096; cv=none; b=B6rRV1+/aBsrtBp29NHiTO0wDeaJnVmoNRPWcQGkbfJafWYTJ7uuJa83XsXCa4ukOhkeCQHlJRXnBLJFHpWBpj2VNJcZ10xISJQWT5ncxDURqTkZ3hhA6TLOHEzjcNdHCR43Tz1YZfujfQoaCpUbDKIQ8H/TcFFvQJJklD6AFI4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790787096; c=relaxed/simple; bh=mitsdmbSqPQRzQHuIowkV+WMbOT3sow3EcaGOEj/fmE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Z6Jkym4BHWg8/gIUsoCYh+ua0BVcilCbQYQ9KujRdZf519k2Z6ISgdvbtqp/0/oPAAKyfZgTY0/ETi5VCZkn+m8+MQd6JL0yy39SxUW22vXXzfVeUtM3wUbxT9oIZsh39DuDRKWIdrHzoGXIOQjiTbShcwT72yMRjYSBwgFefmg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Mb9ASOSU; 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="Mb9ASOSU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7C2191F000FF; Wed, 30 Sep 2026 16:51:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1790787095; bh=oHJnPo1hO16gHUu0M5yNBeU57qyJ5hluggiTzpKIn14=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Mb9ASOSUGpJMBszZza6rbXGwdTxHEUZtS1lvg7WxRDQYDEfJ6kMF61WRubghThmLU MffGLSHYPDA3WTEtOo90LKccVG2GD7MhwrGJLc/76uefTAzQS/rRuV1Xiu8ijJ0jv7 +XdVihHAd92aRHNcO4scH8j5XMcOGtVb1xq4GD30= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Vega , Zhiling Zou , Alexei Starovoitov , Emil Tsalapatis , Eduard Zingerman , Sasha Levin Subject: [PATCH 7.2 066/457] xsk: Use a 32-bit compare in xsk_map_gen_lookup Date: Wed, 30 Sep 2026 17:22:51 +0200 Message-ID: <20260930152347.468523406@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930152346.024115587@linuxfoundation.org> References: <20260930152346.024115587@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 7.2-stable review patch. If anyone has any objections, please let me know. ------------------ From: Zhiling Zou [ Upstream commit 70504de0bb627848667207bec7ccfd647deb8814 ] xsk_map_gen_lookup() loads a u32 key and compares it with max_entries using BPF_JMP_IMM. BPF immediates are sign-extended to 64 bits, so a max_entries value of 0x80000000 or higher becomes a threshold larger than every zero-extended 32-bit key. An out-of-range index then skips the bounds check and the generated lookup reads past xsk_map[]. Compare with BPF_JMP32_IMM so the check stays in 32-bit unsigned range. Fixes: e65650f291ee ("bpf: Implement map_gen_lookup() callback for XSKMAP") Reported-by: Vega Signed-off-by: Zhiling Zou Signed-off-by: Alexei Starovoitov Reviewed-by: Emil Tsalapatis Link: https://patch.msgid.link/7d2cb8e8dfaa9eb8fdff85156987a60960787dc3.1789056660.git.zhilinz@nebusec.ai Signed-off-by: Eduard Zingerman Signed-off-by: Sasha Levin --- net/xdp/xskmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/xdp/xskmap.c b/net/xdp/xskmap.c index 3bff346308d0f..bf00d6463c191 100644 --- a/net/xdp/xskmap.c +++ b/net/xdp/xskmap.c @@ -124,7 +124,7 @@ static int xsk_map_gen_lookup(struct bpf_map *map, struct bpf_insn *insn_buf) struct bpf_insn *insn = insn_buf; *insn++ = BPF_LDX_MEM(BPF_W, ret, index, 0); - *insn++ = BPF_JMP_IMM(BPF_JGE, ret, map->max_entries, 5); + *insn++ = BPF_JMP32_IMM(BPF_JGE, ret, map->max_entries, 5); *insn++ = BPF_ALU64_IMM(BPF_LSH, ret, ilog2(sizeof(struct xsk_sock *))); *insn++ = BPF_ALU64_IMM(BPF_ADD, mp, offsetof(struct xsk_map, xsk_map)); *insn++ = BPF_ALU64_REG(BPF_ADD, ret, mp); -- 2.53.0