From: netdev-bot+sashiko@kernel.org
To: tavip@google.com
Cc: netdev@vger.kernel.org, davem@davemloft.net, edumazet@kernel.org,
kuba@kernel.org, pabeni@redhat.com, willemb@google.com,
horms@kernel.org, andrew+netdev@lunn.ch, ncardwell@google.com,
kuniyu@google.com, dsahern@kernel.org, idosch@nvidia.com,
john.fastabend@gmail.com, jakub@cloudflare.com,
jiayuan.chen@linux.dev, sd@queasysnail.net, shuah@kernel.org,
almasrymina@google.com, sdf@fomichev.me, kaiyuanz@google.com,
ilias.apalodimas@linaro.org, hawk@kernel.org,
mcroce@microsoft.com, herbert@gondor.apana.org.au,
ecree.xilinx@gmail.com, bpf@vger.kernel.org,
linux-kselftest@vger.kernel.org
Subject: Re: [PATCH net 10/10] selftests: drv-net: devmem: test unreadable skbs on TCP-MD5 and TCP-AO
Date: Fri, 04 Dec 2026 22:08:03 +0000 [thread overview]
Message-ID: <179642208364.3146.15155256690085962316@kernel.org> (raw)
In-Reply-To: <52f84807018ab3f05cc1b55e58aef6feeba01d50.1796329894.git.tavip@google.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 1
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 corked TX part of run_tcp_auth()
(tools/testing/selftests/drivers/net/hw/devmem_lib.py) can fail…
- [Low] selftests: drv-net: hardcoded asm-generic SO_ZEROCOPY and
SCM_DEVMEM_DMABUF
--
selftests: drv-net: devmem: test unreadable skbs on TCP-MD5 and TCP-AO
This adds a devmem.py test for TCP-MD5 and TCP-AO sockets. It checks that
devmem TX sends on authenticated sockets fail with EOPNOTSUPP. It also
checks that adding an MD5 or AO key fails with EOPNOTSUPP while unreadable
TX skbs are queued. Finally, it checks that authenticated segments landing
in unreadable net_iov frags are dropped and counted in TCPMD5Failure or
TCPAOBad.
> diff --git a/tools/testing/selftests/drivers/net/hw/devmem_lib.py b/tools/testing/selftests/drivers/net/hw/devmem_lib.py
> index 75199a01ca3fc..13dd2c9482683 100644
> --- a/tools/testing/selftests/drivers/net/hw/devmem_lib.py
> +++ b/tools/testing/selftests/drivers/net/hw/devmem_lib.py
[ ... ]
> @@ -520,3 +530,230 @@ s.close()
[ ... ]
> +def run_tcp_auth(cfg, mode):
> + """Verify TCP-MD5 or TCP-AO rejects unreadable devmem RX and TX skbs."""
[ ... ]
> + cork_port = rand_port()
> + with bkg(socat_listen(cfg, cork_port), host=cfg.remote):
> + wait_port_listen(cork_port, host=cfg.remote)
> + conn = socket.socket(af, socket.SOCK_STREAM)
> + defer(conn.close)
> + conn.settimeout(5.0)
> + conn.bind((cfg.addr, 0))
> + conn.connect((cfg.remote_addr, cork_port))
> + conn.setsockopt(socket.SOL_SOCKET, SO_ZEROCOPY, 1)
> + conn.setsockopt(socket.IPPROTO_TCP, socket.TCP_CORK, 1)
> + ksft_eq(_sendmsg_devmem_tx(conn, tx_dmabuf_id, 64), 64)
> + if opt_num == TCP_AO_ADD_KEY:
> + with ksft_raises(OSError) as cm:
> + conn.setsockopt(socket.IPPROTO_TCP, opt_num, opt)
> + ksft_eq(cm.exception.errno, errno.EISCONN)
> + conn.setsockopt(socket.IPPROTO_TCP, TCP_REPAIR, TCP_REPAIR_ON)
> + try:
> + with ksft_raises(OSError) as cm:
> + conn.setsockopt(socket.IPPROTO_TCP, opt_num, opt)
> + ksft_eq(cm.exception.errno, errno.EOPNOTSUPP)
> + finally:
> + conn.setsockopt(socket.IPPROTO_TCP, TCP_REPAIR,
> + TCP_REPAIR_OFF_NO_WP)
> + else:
> + with ksft_raises(OSError) as cm:
> + conn.setsockopt(socket.IPPROTO_TCP, opt_num, opt)
> + ksft_eq(cm.exception.errno, errno.EOPNOTSUPP)
[Severity: Medium]
Can this corked TX check in run_tcp_auth() fail intermittently? TCP_CORK
alone doesn't seem to keep the 64 byte devmem skb queued for good.
By the time _sendmsg_devmem_tx() returns, tcp_push() has already called
__tcp_push_pending_frames(). Nothing is in flight and the write queue is
not empty, so tcp_write_xmit() returns true and the probe timer is armed:
net/ipv4/tcp_output.c:__tcp_push_pending_frames() {
...
if (tcp_write_xmit(sk, cur_mss, nonagle, 0,
sk_gfp_mask(sk, GFP_ATOMIC)))
tcp_check_probe_timer(sk);
}
ICSK_TIME_PROBE0 is armed at tcp_probe0_base(), which is
max(RTO, TCP_RTO_MIN), so about 200ms. When it fires, the call chain
tcp_probe_timer()->tcp_send_probe0()->tcp_write_wakeup() sends the send
head without checking TCP_CORK:
net/ipv4/tcp_output.c:tcp_write_wakeup() {
...
skb = tcp_send_head(sk);
if (skb && before(TCP_SKB_CB(skb)->seq, tcp_wnd_end(tp))) {
...
err = tcp_transmit_skb(sk, skb, 1, GFP_ATOMIC);
...
}
The remote socat then ACKs the segment, which frees it from tcp_rtx_queue.
After that, tcp_tx_has_unreadable_skb() no longer finds an unreadable skb:
include/net/tcp.h:tcp_tx_has_unreadable_skb() {
...
skb_queue_walk(&sk->sk_write_queue, skb) {
if (!skb_frags_readable(skb))
return true;
}
skb_rbtree_walk(skb, &sk->tcp_rtx_queue) {
...
}
At that point tcp_md5_do_add() or tcp_ao_add_cmd() would accept the key.
The ksft_raises(OSError) check would then fail because no exception is
raised.
Nothing in the test keeps the skb queued. The peer reads normally, there
is no zero window, and TCP_REPAIR is not entered before the send. So the
result depends on the following setsockopt() calls running within about
one RTO, which may not happen on a loaded CI host.
The AO branch makes the window longer. It does the EISCONN setsockopt()
and turns TCP_REPAIR on before the setsockopt() that is expected to fail
with EOPNOTSUPP.
Could the test hold the unreadable skb in the queue in a deterministic way,
so the result doesn't depend on timing?
> + conn.setsockopt(socket.SOL_SOCKET, socket.SO_LINGER,
> + struct.pack("ii", 1, 0))
> + conn.close()
[ ... ]
> @@ -322,11 +324,19 @@ def run_rx_hds(cfg):
> ksft_eq(ncdevmem.ret, 0, f"HDS failed for payload size {size}")
>
>
> +MSG_ZEROCOPY = 0x4000000
> +SO_ZEROCOPY = 60
> +SCM_DEVMEM_DMABUF = 79
> SOL_TLS = 282
> TLS_RX = 2
> TLS_1_2_VERSION = 0x0303
> TLS_CIPHER_AES_GCM_128 = 51
> +TCP_REPAIR = 19
> +TCP_REPAIR_ON = 1
> +TCP_REPAIR_OFF_NO_WP = -1
> TCP_ULP = 31
> +TCP_MD5SIG_EXT = 32
> +TCP_AO_ADD_KEY = 38
> UDMABUF_FLAGS_CLOEXEC = 0x01
> UDMABUF_CREATE = 0x40187542
> NUM_DEVMEM_PAGES = 16000
[Severity: Low]
Are these values correct on every architecture? They come from
include/uapi/asm-generic/socket.h, but the SOL_SOCKET option and cmsg
numbers are arch specific.
On sparc, arch/sparc/include/uapi/asm/socket.h defines SO_ZEROCOPY as
0x003e and SCM_DEVMEM_DMABUF as 0x0058. There, 0x003c (60) is
SCM_TIMESTAMPING_PKTINFO. On parisc,
arch/parisc/include/uapi/asm/socket.h uses 0x4035 and 0x404f.
On those hosts, conn.setsockopt(socket.SOL_SOCKET, SO_ZEROCOPY, 1) in
run_tcp_auth() would pass a different option number. The cmsg built by
_sendmsg_devmem_tx() would also carry a type the kernel does not treat
as a devmem dmabuf binding. So the TX checks would fail with an
unrelated errno, or at least would not exercise devmem TX on an
authenticated socket at all.
This is unlikely to matter much, since devmem capable NICs are rarely
tested on sparc or parisc. Still, could these be taken from the socket
module where it exports them, with the asm-generic numbers as a
fallback? Alternatively, the test could skip on architectures where
the asm-generic values don't apply, so it doesn't report a misleading
failure there.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cover.1796329894.git.tavip%40google.com
prev parent reply other threads:[~2026-12-04 22:08 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 21:09 [PATCH net 00/10] net: fix unreadable net_iov skb handling across networking paths Octavian Purdila
2026-12-03 21:09 ` [PATCH net 01/10] net: gro: free skb on napi_frags_skb() header pull failure Octavian Purdila
2026-12-04 18:31 ` Mina Almasry
2026-12-03 21:09 ` [PATCH net 02/10] net: gro: reset unreadable and pp_recycle in napi_reuse_skb Octavian Purdila
2026-12-04 18:32 ` Mina Almasry
2026-12-04 21:07 ` Octavian Purdila
2026-12-04 22:07 ` netdev-bot+sashiko
2026-12-03 21:09 ` [PATCH net 03/10] inet: frag: reject fragments with mixed readability in reassembly Octavian Purdila
2026-12-04 18:38 ` Mina Almasry
2026-12-04 21:09 ` Octavian Purdila
2026-12-04 22:07 ` netdev-bot+sashiko
2026-12-03 21:09 ` [PATCH net 04/10] net: skbuff, skmsg, strparser: reject unreadable frags Octavian Purdila
2026-12-04 18:58 ` Mina Almasry
2026-12-04 21:25 ` Octavian Purdila
2026-12-04 22:07 ` netdev-bot+sashiko
2026-12-03 21:09 ` [PATCH net 05/10] tls: reject unreadable skbs in tls_strp Octavian Purdila
2026-12-04 18:44 ` Mina Almasry
2026-12-04 22:24 ` Octavian Purdila
2026-12-04 22:07 ` netdev-bot+sashiko
2026-12-03 21:09 ` [PATCH net 06/10] tcp: reject unreadable skbs on TCP-MD5 and TCP-AO Octavian Purdila
2026-12-04 18:46 ` Mina Almasry
2026-12-04 22:26 ` Octavian Purdila
2026-12-04 22:07 ` netdev-bot+sashiko
2026-12-03 21:09 ` [PATCH net 07/10] net: kunit: test unreadable net_iov napi_gro_frags Octavian Purdila
2026-12-04 18:47 ` Mina Almasry
2026-12-04 22:07 ` netdev-bot+sashiko
2026-12-03 21:09 ` [PATCH net 08/10] net: kunit: test unreadable net_iov defrag and skb helpers Octavian Purdila
2026-12-04 22:07 ` netdev-bot+sashiko
2026-12-03 21:09 ` [PATCH net 09/10] selftests: drv-net: devmem: test unreadable kTLS RX Octavian Purdila
2026-12-04 18:48 ` Mina Almasry
2026-12-04 22:28 ` Octavian Purdila
2026-12-04 22:08 ` netdev-bot+sashiko
2026-12-03 21:09 ` [PATCH net 10/10] selftests: drv-net: devmem: test unreadable skbs on TCP-MD5 and TCP-AO Octavian Purdila
2026-12-04 22:08 ` netdev-bot+sashiko [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179642208364.3146.15155256690085962316@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=almasrymina@google.com \
--cc=andrew+netdev@lunn.ch \
--cc=bpf@vger.kernel.org \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=ecree.xilinx@gmail.com \
--cc=edumazet@kernel.org \
--cc=hawk@kernel.org \
--cc=herbert@gondor.apana.org.au \
--cc=horms@kernel.org \
--cc=idosch@nvidia.com \
--cc=ilias.apalodimas@linaro.org \
--cc=jakub@cloudflare.com \
--cc=jiayuan.chen@linux.dev \
--cc=john.fastabend@gmail.com \
--cc=kaiyuanz@google.com \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=linux-kselftest@vger.kernel.org \
--cc=mcroce@microsoft.com \
--cc=ncardwell@google.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sd@queasysnail.net \
--cc=sdf@fomichev.me \
--cc=shuah@kernel.org \
--cc=tavip@google.com \
--cc=willemb@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox