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=1796382159; b=Ij5FF3XrXkMXdntZfurFNduer88V0JxQpvPS4qqqJw8KDxvoujZmxlj8Izm8+/AkLQ51 fV8nupwKw0IU+SqGn9PBq/0elqh+cbj+Uq0uVvBxoul/t7VHsUGamOYQNpIv2dttlVc1Z ZjGWs9sUkvD2h5uBIOW0e9JzN+wS6mfBD3avjOzMVL6vG6VYXhH5czPHlZSEYvO6kp0ic qjOKslxTPbk2Ds5ibx7HDqC/tkgD1d2rDTjX5fG47VKnzbCmMEeJ5aS7b8tREV0QI8HZ8 9sbkYNHPgjmBmWiyOpb7otE+hZV1/Ns0mnHgTeIIwZcOkQp8/1kDjC2KJEvfvUitaXg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796382159; 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=PabBByM4OlUVAPkrwOybIcChJTw9xafjs1485XIzOyM=; b=wmyreU20xIpKPVWY2Q4z48cF/0YCrWNHmv2BBY7XLhSvekSLdcZ6zEc0ED+vZ/KkxvBG axBHdWhtymBmMB2Ro5r0fijPGSg2Q2eTBFvNeCm1/DaBsZFTPrhQQrwR96Ji/5l/+VaTV vpR2qfljlDtfRqcEFQjIxVjHEwU5yZHL07DwTPsc12k8uSlqHC0F6p8TxxfCWGAOfly2q sHKH0HFRGAlmYhL7eU/WIM2WlEd5Jh2wVsn2AHIlSBNgo4psEkOEIuVXCIZ42Cisil55r i673jG2qW1i6iiss+Ct9KxA3abr+Nr/tjic54EWEdsplacvXAyyET0qxsXtEzecIbug== 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=l8vqEIpX; 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 268E0606A32D; Fri, 4 Dec 2026 11:02:39 +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=l8vqEIpX Received: by smtp.kernel.org (Postfix) with ESMTPSA id 90A7C1F00931; Fri, 4 Dec 2026 11:02:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796382159; bh=PabBByM4OlUVAPkrwOybIcChJTw9xafjs1485XIzOyM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=l8vqEIpXJ87MXv7fSNLaczFWpniq4kjjUSL5xF6Cc8qcGU5kp8eInNM0QL8ynylwY uqZ/Img7+wb5Mmd8oQiZ12vWhA+t9XjToHyTYZPYWyCvFv6w6WCzvRAA83UI4oBaWX cACCJRs2Ugl6tomtUXd+A8N+xt16s/1FlPgP5W44= 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.18 335/703] bpf, sockmap: Clear the redirect target after the stream parser runs Date: Fri, 4 Dec 2026 19:03:54 +0900 Message-ID: <20261204100636.696451808@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: stable@vger.kernel.org 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: 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 9cc738b94209d..04cd168f919bb 100644 --- a/net/core/skmsg.c +++ b/net/core/skmsg.c @@ -1156,7 +1156,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