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=1796064326; b=nTK1iZUOaRIci89h43ZkYacYg0aA25qA5SIVmq6tX1C/v5mGwWnQaugUEgfVvdxaRdNk RjBj0Zs7ixrawHgedIx+in34OOGAA81b/TZsRg8ddr6syCL53U0uG1vcuqv0VfpUj5QaJ kVWJHF+rBdhNQRwhzkFwX2KYsNrtlyB5/94j1nL8RW5tNBtdOt6es5Ij8uN2wnw0fV1PJ d132Obk69z5bFQ3sZuF5C9Dy/p7dp/vZpuMxlZOLGrpvv7PbarW/f0T9cuMR4EMvof4rl Q11oo7VbKwzocglDycNX/JSzq+g3b9ulExkwKzybxnFlrQ3oe17rHfuc1G9O7rDVhJQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796064326; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=LkGLiF6rDyJeYFuonbeL0l4uzdO1c0QYnTP3CFtvyxQ=; b=p2aJvS3vPk5rVLpSE+h+cplUjF4eDiGICu3qQY1Q+X8jY40x2UqAMut139somsH+IUb+ cMRTZ/UVsQUCg8BcaKpAT6BRrWLibUIdXfNQnL28Ux1E0wpC5yzwKOq37zDqaSLRpEqwS 1LIy+g4qzKLopKQ84Dd0+5j7PVtwNUSgCRqCYObzOePUAAeW9hg3mxq0ibRwFrp8+09LJ hTf/bfRk96RxGDgUmjCWEWUimOklblrSHLS0XhTYkZ61JfuWrFhCsuXjLMpee4pFpg4sx oczwHaZWzbxiJnvy3+9L9aozUBbh03IYWlxrzjDu6mUjOGObexLnVFDeJN2SiAQqFFg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=JD4gQ3Zp; 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 CF57C606A320 for ; Mon, 30 Nov 2026 18:45:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=JD4gQ3Zp Received: by smtp.kernel.org (Postfix) with ESMTPSA id F210C1F00925; Mon, 30 Nov 2026 18:45:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796064326; bh=LkGLiF6rDyJeYFuonbeL0l4uzdO1c0QYnTP3CFtvyxQ=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=JD4gQ3ZpsB6ePOWSNtVdekupAFOu44N+Tx51UUF7EfFNuv7Vmd5y/4Xs2RpsiPXBp eLOhwfRwOBIUmMDO6xN0XKZjI/g/VQ+8Fokex8/cXNXBTC7T1bdU+gZ9cNXHLCJZwM kT5KaZujcqqSLiDb1syqh1iDgCc2glHDswz1iALUtOjciVnY/UjmCqFkUfm6A/deRm YP/GfjSXGMZe+Dtf8xlA8e9QgEw3J26DCnBHCuB0av2yQO2JobqiGhnF6dRst5nm7T /fc8F8Ap5SyiT5rUawNe5qggu2xdVPyMQiw60dhMcOgwH6U/f9EOkOzir3CHK0fIrc m4xrABmy7BO3g== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH bpf] bpf: orphan unsafe prefetched sockets in skb_do_redirect Reply-To: sashiko-reviews@lists.linux.dev To: "Nikolay Aleksandrov" , bpf@vger.kernel.org In-Reply-To: <20261130182424.2879469-1-razor@blackwall.org> References: <20261130182424.2879469-1-razor@blackwall.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Mon, 30 Nov 2026 18:45:25 +0000 X-Mailing-List: bpf@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found no new issues in this patch, but noticed 1 related pre-existing issue it does not introduce: - [High] netfilter: nf_queue: use-after-free of syncookie reqsk listener in __nf_queue() [1] -- commit db64d3de9cb065fcc63cc9c7da578879d98b49a3 Author: Nikolay Aleksandrov bpf: orphan unsafe prefetched sockets in skb_do_redirect This commit orphans prefetched sockets in skb_do_redirect() unless the redirect is tc ingress-to-ingress within the socket's netns and the skb holds a reference to a full socket. > diff --git a/net/core/filter.c b/net/core/filter.c > index ea20fd2be65c0..9e7d6c03e5420 100644 > --- a/net/core/filter.c > +++ b/net/core/filter.c > @@ -2553,6 +2553,21 @@ static struct net_device *skb_get_peer_dev(struct = net_device *dev) > return NULL; > } > =20 > +static void skb_redirect_prefetched_sk(struct sk_buff *skb, > + const struct net_device *dev, u32 flags) > +{ > + struct sock *sk; > + > + if (!skb_sk_is_prefetched(skb)) > + return; > + > + sk =3D skb->sk; > + if (!skb_at_tc_ingress(skb) || flags !=3D BPF_F_INGRESS || > + !net_eq(sock_net(sk), dev_net(dev)) || !sk_fullsock(sk) || > + !sk_is_refcounted(sk)) > + skb_orphan(skb); > +} [Severity: High] This problem wasn't introduced by this patch, but can __nf_queue() hit a similar use-after-free on req->rsk_listener [1] when queuing a packet whose skb->sk was set by bpf_sk_assign_tcp_reqsk()? bpf_sk_assign_tcp_reqsk() attaches a syncookie request_sock with an unreferenced req->rsk_listener and sets skb->destructor to sock_pfree. When __nf_queue() queues the packet to userspace, it only checks !sk_is_refcounted(sk): net/netfilter/nf_queue.c:__nf_queue() { ... if (skb_sk_is_prefetched(skb)) { struct sock *sk =3D skb->sk; if (!sk_is_refcounted(sk)) { if (!refcount_inc_not_zero(&sk->sk_refcnt)) return -ENOTCONN; /* drop refcount on skb_orphan */ skb->destructor =3D sock_edemux; } } ... } Because sk_fullsock(sk) is false for a request_sock, sk_is_refcounted(sk) returns true and __nf_queue() leaves the skb unchanged across RCU grace periods. If the listener closes before nf_reinject() runs, skb_steal_sock() in tcp_v4_rcv() or tcp_v6_rcv() returns the freed req->rsk_listener pointer. [1] https://sashiko.dev/#/bug/linux-e38dcdd4-fc77-4d07-a948-1840d055aa09 --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261130182424.2879= 469-1-razor@blackwall.org?part=3D1