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=1796386524; b=nxp7ft7fvMQa6yihnJ3vGzP3DAIgaPqdzHk5YdeKl/sFqWq6Jyo4qcU3L7+XTC9aOJ3D LmiXbvOMBy9faDnxN1nQKPLrYYrYDEBQhHVJykFUizskEw45oGoVZUV7jD7XKCw7nuRy5 jKP4THLLMQrCL/B1gzZzusiBmECasnG8T5+wuObl2Ktcuu3V2KfGyQTH2kLM8oiWq+agm 2CBt0YPMPlIV2yi+6zYLVTsXTcj9kcs2xi8s4LzBDZynLMfcLr2aSo/3wcHFvuv50io25 pR4kuugLF5w2oLYZsPUcHC1YcV2baH+0bgLV5p6CCx1B790aF44Z1tEkBw4lQGjGBYQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796386524; 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=og34mNUWxVhGt2AgvUBZDTh9MBmgA8VsCmyrY8l6wTg=; b=BFLUxoIOEfBzATKPp/PeF93XAZ3fRPJZtHcWi2aU1X5C6xS+GMFa3BCMadS0aYvfUgFC X0XGeEJDu1oFXuGUErlAvZ6yP4ga52UK5J88dB9GUVSGQvs/yfIBz9hd6oLs+6A872gr2 wxY13N5LdzP7wmlIZ0eNfNIc3hjX+3kqD++kVF4aK+0v5xmtxoc14SAh4yBHkFXE5zPaN To7HxN3pIqCD4RK8Y7KbpGk5nmMnzFQ5ig7oau3WXmTJn/dN9H+6OdAwKw3Di5zgTXDzF r8dBCUFaqr7MopazYTq3zLtxSYaglDx9LrsKVlUGySHZodmL6abxYI36faAwA4pbPxw== 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="HS/rz3KR"; 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 48C83606A332; Fri, 4 Dec 2026 12:15:24 +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=HS/rz3KR Received: by smtp.kernel.org (Postfix) with ESMTPSA id AF4ED1F00897; Fri, 4 Dec 2026 12:15:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796386524; bh=og34mNUWxVhGt2AgvUBZDTh9MBmgA8VsCmyrY8l6wTg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=HS/rz3KRQHYmwwS+AMayD5Zzqa7Au5rWs5TYk98M8iaQEHWO475102bhbNRa6siyS TMBGhFPWyRn2mLIADJfGLduYg9V7cvTBKDLntD9Xr+zOHRxSSK1chWcXuf1LeXy9Cd l+tYSkTp/aPA/cQSokxe6ke+1HxvK0NsroRmgKOo= 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.6 0982/1167] bpf, sockmap: Clear the redirect target after the stream parser runs Date: Fri, 4 Dec 2026 19:06:49 +0900 Message-ID: <20261204100727.779124407@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@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.6-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 3791405b49acb..68e6ae176174c 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