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=1796383668; b=Z3LTDp3dLx1RsPpIjmTfoAELazmZNSErSmNj6XpquFLYG6JsR0cMp3VfoN2STMrgd8P1 VAdu5cLbg4PvuipL3g/+Qecp/B41MYy42rs5ydWSRJVx5vGaSMhnRrBzaoPkE1iUW/RC0 zvKbL/kcgBkG0uWbvPE0sXJ4lRmlRkXYltOLAYLUV/qfJa0N+PdjgxCDhzMrYgKTXcHoq Ylt+qYm/WmBpeYXCfRZD49N4KBHGZN3iABcBTyAomx/mW5FguSGUMeEUq3XD5dscmqgCZ Ekt5hxY8I1JJO+LuGTJQBnBGXixXsuCuNNYMeRxxwoqXWroFnmB7TBUhYuxhsTvzcCA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796383668; 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=7kx5kI6VMYy2cdDlE4IQ3WdrrI9oUkNDIxHf5/hlxi0=; b=hJsm/I2GL86bbEDXazx/Vpx7WoCsL4cXZIRDHUk3O73ABxs8qbnCW74uIHMqkli52u4+ DKfq+Qi5fx47166eZXy9unfxeisgG+8pfnR1sJYjayb+Xnp0TeK7zJLylUod56OOPFJtV u+vbD1PIfQk8H3W+tOsmpjKX/axabTt9v3xBP7+EZoRU5OlvaXcKkcgGA4MGlQaAr1DXs ziBGaFEuTixq2P4in2AfzpcS++41Q5DQ1MZydThyEWd2YrdqOIrps8agYuFRGDT0oOGLQ TnR5N9tlhomcZtPMpQXpoZNhEPt50XsXh8unHaTyCb4XG+1rWRcpwuAKF/XBMXkMGgA== 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=lvbPmZnk; 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 E574B606A322; Fri, 4 Dec 2026 11:27: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=lvbPmZnk Received: by smtp.kernel.org (Postfix) with ESMTPSA id 46D1C1F000C2; Fri, 4 Dec 2026 11:27:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796383667; bh=7kx5kI6VMYy2cdDlE4IQ3WdrrI9oUkNDIxHf5/hlxi0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=lvbPmZnkStSEduKzcPVSSXQya/FsqCKWbGuIPTHCFrs4UNunu7nWbO2fOVHKeo/28 6PeQt8V472KeltDwWWHAVcVyOsDSre7nwneJn62lD/unwjwcUoA0saG2fD937dOva7 XLYtGDwnx1FnNJiflPZgFLZ237FyYfEYRqgxNLNU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Sechang Lim , Alexei Starovoitov , Jiayuan Chen , Sasha Levin Subject: [PATCH 6.12 319/555] bpf, sockmap: Clear the redirect target after the stream parser runs Date: Fri, 4 Dec 2026 19:06:02 +0900 Message-ID: <20261204100621.724403212@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: Sechang Lim [ Upstream commit 14f6b10422d640695803c621687f790f6f3d2401 ] A stream parser can call bpf_sk_redirect_{map,hash}(), which store the target socket in skb->_sk_redir. sk_psock_strp_parse() never clears it, and it shares storage with skb->_skb_refdst, so skb_dst_drop() later passes the socket to dst_release(): KASAN: null-ptr-deref in range [0x0000000000000128-0x000000000000012f] RIP: 0010:percpu_counter_add_batch+0x24/0x220 Call Trace: dst_release.part.0+0xc9/0x180 skb_release_head_state+0x1cc/0x2f0 sk_skb_reason_drop+0xbc/0x420 strp_done+0xcf/0x150 sk_psock_destroy+0x85e/0xb10 Drop the dst before the parser runs, as the verdict paths do, and clear the redirect after it. The parser's redirect was never used. Fixes: e3526bb92a20 ("skmsg: Move sk_redir from TCP_SKB_CB to skb") Signed-off-by: Sechang Lim Signed-off-by: Alexei Starovoitov Reviewed-by: Jiayuan Chen Link: https://patch.msgid.link/20261126101950.1682160-1-rhkrqnwk98@gmail.com Signed-off-by: Sasha Levin --- net/core/skmsg.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/core/skmsg.c b/net/core/skmsg.c index d8589771a504a..a2fca0051cdb2 100644 --- a/net/core/skmsg.c +++ b/net/core/skmsg.c @@ -1155,7 +1155,9 @@ static int sk_psock_strp_parse(struct strparser *strp, struct sk_buff *skb) prog = READ_ONCE(psock->progs.stream_parser); if (likely(prog)) { skb->sk = psock->sk; + skb_dst_drop(skb); ret = bpf_prog_run_pin_on_cpu(prog, skb); + skb_bpf_redirect_clear(skb); skb->sk = NULL; } rcu_read_unlock(); -- 2.53.0