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=1795957318; b=qApBrVyUIxQoAyIYcb6ncxkn3GGfWvg2UyAwIKa1jAC7MFTpV4IYEBukLpNRErMvIeqU +GVV70pdZ4h2VQPiS9kiQ7+ktzUrwthcBmqDvdBWIcSNqNtp4htWA2P6ku0FYhg8pt8OP MsjzU5UQoiXhwPvZ5I484BFLfKLLvRnnuNoQpQDFRxz5CX+rZvMe7hABgLCTb4fe74V+s QlRVnyTPR67YS8TLXfP23RblCmUFg41RtmXRMHgFnaZiTRkppf6QVdiArIx6Dg0pQtLLN ouwmBNEwFFKNboYJhBDbLO5keN+Xzru9UPZ0TZa0T0OxGAXIAP81u4CRxqqS7S0NXoA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795957318; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=EU8D9ve/ssG5uQMPZ+Z278qw5+jlVjB60K2BKYicl68=; b=vfWAY1qqIEAV7LpIYZQQqPENDS7nbzJRLGJBKtsuE7kHueA7pgOzApMbgYLpbxB+dWE2 yxg7XLDMHWAml+olZkFGfOw2b3YxCZUWJlrPVVRczsSc4RTU9m3fDNbiuxqCHg/N53ymX DrmXCB0VksOuR3txhogX8m8+ou7tW8rJMZI7M7M+kUSEtR4k6uIjhcttmn7HVzg7R7nf/ d7qC7T+gmweqhWeFCWGDQGB78JeeCcPYv0bKdjbl2w6eJiHqvj5twVjHn7f3KfhpYLMcf XuPGFJHyiN8lKxEUOiImT3Lsj0tHnCjQ3pRJAM1uzoLypk/luxr9WmG+fZLRo3B70ZA== 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=k0wJjlkV; 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 33271606A31C; Sun, 29 Nov 2026 13:01:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=k0wJjlkV Received: by smtp.kernel.org (Postfix) with ESMTPSA id 33E681F000C1; Sun, 29 Nov 2026 13:01:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795957317; bh=EU8D9ve/ssG5uQMPZ+Z278qw5+jlVjB60K2BKYicl68=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=k0wJjlkVPzb2nA89NKlkedJgok4lX/wMMwyIeUnwBgFE6XMvTl2WUwZNDVuqUKGFY fBd8oV/a1UIYLF0PcHRWV8btoF4unjLNT672ZHuE5jItCJpMqsnmf/RmgMa5Q1o/d1 bnEyTFHyqSEoo9dls05oCCKlORP09FJ+bOIlJMh6OgjM0KS2VQs13/v5h9cey59TDX 3xE7jqUQ+hl37F4I98QFgbp/n3esCryFDd+gIbWJvZUhDTkZEb1qfD68uVQ33/gAag BFVyi7ilsUmoDkFYOkwPAQBjk4Pfg91N+ZfTgdop39vO10VCO+iGMbaZNybimkSOTh M9mJRO6RwnSXw== Subject: Re: [PATCH net] tcp: do not BUG on an unreadable urgent byte From: netdev-bot+sashiko@kernel.org To: graypanda.inzag@gmail.com Cc: edumazet@kernel.org, ncardwell@google.com, gwanhyunlee@gmail.com, kuniyu@google.com, davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, almasrymina@google.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Date: Sun, 29 Nov 2026 13:01:56 +0000 Message-ID: <179595731672.3146.1831155978625976646@kernel.org> In-Reply-To: <20261125124212.4145820-1-graypanda.inzag@gmail.com> References: <20261125124212.4145820-1-graypanda.inzag@gmail.com> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 1 · Low: 2 If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [Medium] The commit message says TCP_URG_READ "lets the receive path skip the hole until copied_seq passes urg_seq". - [Low] The commit message describes the bug only through a synthetic reproducer (a test-only netfilter module that puts a loopback MSG_OOB… - [Low] The patch gives TCP_URG_READ a second meaning. -- tcp: do not BUG on an unreadable urgent byte tcp_urg() used to call BUG() when skb_copy_bits() could not read an urgent byte that sits in an unreadable fragment. This patch removes the BUG(). When the copy fails, it sets tp->urg_data to TCP_URG_READ and returns, so a later segment cannot retry the stale urgent pointer. > tcp_urg() checks that the urgent byte offset is within skb->len and > then calls skb_copy_bits(). The byte can still lie in an unreadable > Device Memory fragment. In that case skb_copy_bits() returns -EFAULT > and tcp_urg() calls BUG(). [Severity: Low] Could the commit message say that any remote TCP peer can reach this BUG()? Could it also say that io_uring zcrx receivers are affected, not only Device Memory? The reproducer described is a test-only netfilter module on loopback. On a header-split devmem or io_uring zcrx queue, the TCP header is in the linear area and the payload is in net_iov frags. __skb_fill_netmem_desc() marks the skb unreadable for any net_iov netmem: include/linux/skbuff.h:__skb_fill_netmem_desc() { ... skb->unreadable = true; ... } A peer that sends an in-window segment with URG set and the urgent pointer in the payload (for example with send(..., MSG_OOB)) reaches it like this: tcp_rcv_established() /* slow path */ tcp_urg() tcp_check_urg() /* sets TCP_URG_NOTYET */ skb_copy_bits() /* !skb_frags_readable() -> -EFAULT */ BUG() /* before this patch */ Backporters and security triage need both of these facts. > diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c > index d9a66a1342efd..50c0da17923e4 100644 > --- a/net/ipv4/tcp_input.c > +++ b/net/ipv4/tcp_input.c > @@ -6390,8 +6390,10 @@ static void tcp_urg(struct sock *sk, struct sk_buff *skb, const struct tcphdr *t > /* Is the urgent pointer pointing into this packet? */ > if (ptr < skb->len) { > u8 tmp; > - if (skb_copy_bits(skb, ptr, &tmp, 1)) > - BUG(); > + if (skb_copy_bits(skb, ptr, &tmp, 1)) { > + WRITE_ONCE(tp->urg_data, TCP_URG_READ); > + return; > + } [Severity: Medium] The commit message says TCP_URG_READ "lets the receive path skip the hole until copied_seq passes urg_seq". Does that hold for every receive path that can see unreadable skbs? tcp_recvmsg_locked() steps over the byte and clears urg_data later: net/ipv4/tcp.c:tcp_recvmsg_locked() { ... if (!urg_offset) { if (!sock_flag(sk, SOCK_URGINLINE)) { WRITE_ONCE(*seq, *seq + 1); urg_hole++; ... skip_copy: if (unlikely(tp->urg_data) && after(tp->copied_seq, tp->urg_seq)) { WRITE_ONCE(tp->urg_data, 0); ... } io_uring zero-copy RX also receives net_iov skbs. It reads through io_zcrx_tcp_recvmsg()->tcp_read_sock()->__tcp_read_sock(), and that path only stops at urg_seq: net/ipv4/tcp.c:__tcp_read_sock() { ... /* Stop reading if we hit a patch of urgent data */ if (unlikely(tp->urg_data)) { u32 urg_offset = tp->urg_seq - seq; if (urg_offset < len) len = urg_offset; if (!len) break; } ... } Nothing on this path steps over the byte or clears TCP_URG_READ. tcp_recv_urg() also returns -EINVAL for that state, so recv(MSG_OOB) cannot clear it either. Once copied_seq reaches urg_seq, will every zcrx read return 0? If so, io_zcrx_tcp_recvmsg() turns that into -EAGAIN, and the connection stalls after a peer sends one urgent byte into the payload. __tcp_read_sock() already stops at urg_seq for readable TCP_URG_VALID bytes, so the stall comes from an existing read_sock limitation that this new state now feeds into. The commit message does not mention the read_sock/zcrx path. The commit message also rules out clearing urg_data because it "would drop the urgent-byte hole and make ordinary recvmsg() hit -EFAULT on the unreadable byte". On a real devmem socket, wouldn't plain recvmsg() without MSG_SOCK_DEVMEM already get -EFAULT on any unreadable skb? That reason may only apply to the loopback test harness. [Severity: Low] This isn't a bug, but could this new use of TCP_URG_READ get a comment? Until now the only writer was tcp_recv_urg(), where the state means the application already took the byte with MSG_OOB. Here it means the urgent byte is in an unreadable fragment and was never delivered. Neither the urg_data state definitions in include/net/tcp.h nor this call site document that second meaning. >>From userspace, the result looks like this: tcp_check_urg() has already called sk_send_sigurg() SIOCATMARK in tcp_ioctl() reports at-mark, since urg_data != 0 tcp_poll() never sets EPOLLPRI, since that needs TCP_URG_VALID recv(MSG_OOB) returns -EINVAL under the "No URG data to read" check An application that got SIGURG but never read the byte gets the same -EINVAL as for a byte it already consumed. It cannot tell that the urgent byte was lost. The commit message says -EINVAL is intended, but the code does not document the overloaded state. -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261125124212.4145820-1-graypanda.inzag%40gmail.com