* Re: [PATCH net] tcp: do not BUG on an unreadable urgent byte
2026-11-25 12:42 [PATCH net] tcp: do not BUG on an unreadable urgent byte Junyoung Jang
@ 2026-11-29 13:01 ` netdev-bot+sashiko
0 siblings, 0 replies; 2+ messages in thread
From: netdev-bot+sashiko @ 2026-11-29 13:01 UTC (permalink / raw)
To: graypanda.inzag
Cc: edumazet, ncardwell, gwanhyunlee, kuniyu, davem, kuba, pabeni,
horms, almasrymina, netdev, linux-kernel
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
^ permalink raw reply [flat|nested] 2+ messages in thread