🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #27161

Re: [PATCH net 10/10] selftests: drv-net: devmem: test unreadable skbs on TCP-MD5 and TCP-AO

#27161
From: netdev-bot+sashiko
Date: Fri, 04 Dec 2026 22:08
183 lines
15362 bytes
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
Technical Details
Message-ID: <179642208364.3146.15155256690085962316@kernel.org>
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377694-linux-kernel-netdev=dewy.ru
References: <52f84807018ab3f05cc1b55e58aef6feeba01d50.1796329894.git.tavip@google.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377694-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
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
Organization: Usenet Network
Message-ID: <179642208364.3146.15155256690085962316@kernel.org>
References: <52f84807018ab3f05cc1b55e58aef6feeba01d50.1796329894.git.tavip@google.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2883864"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:fJ8gRa8arGPzjPSI06RiRTbZUj8= sha256:jM72I1z80lJYzChgKnG70tWku2BagmkhYJUdYaK4HjM=
	sha1:9LvQ7CtwNC5zlryAKuVTKNw6Bj8= sha256:zjFRYiTj92cFBz4OmyiOGQK0w7B1aXwi9GgdbyM7ljs=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id E76E7117D0C; Sat,  5 Dec 2026 01:08:23 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.641
X-Spam-Status: No, score=-3.641 tagged_above=-9999 required=6.31
	tests=[DKIMWL_WL_HIGH=-0.142, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
	URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id nXeP1gkEWiKJ;
	Sat,  5 Dec 2026 01:08:21 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-377694-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id EF974117D00; Sat,  5 Dec 2026 01:08:12 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id 8EDCF600951; Fri,  4 Dec 2026 22:08:12 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796422091;
	b=Me8ZELMNkt/fkXLBFFatvN0FzUjsX4jQfCHPya2PvL0IFL8M6+BfWl1QVw2Eed3nFuMA
	 p8rZ//hMuQ92LK2Bu5UiRGr12fkDpxpeFhQ/or1StJXOEaT9BFCMpd84PsmVNtHJab+vM
	 27tveSIwfSJb6Vt+tw7tume6pM0ILNDiUSjI9pe631fQWDe0322eLRBcCcKXizGlxHkrY
	 xIu70mEBMc6XjUT9yLV/fTDG+aphrTh5kl/riwpWY+wbk2u5YgYP4s5WiHDPd82C1HB/z
	 WokbjiyIynJejt9f2cFYskvszSIZFeDmybxhFn8wRnypbH+Jmk2UGeZ+X76jKNYWtuQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796422091;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=2kGqxMpXfF+Y75RsudhaGs95g5m2hGvERy2GxvTqwJE=;
	b=bh0Jmy7DItJZnqtddTBDUbqDz1lKOxJmZI+nl3Xbof+KY0S+gOuDs8hhMEvhXaoeO5pl
	 Xr4HRVqE+kYcehhZSvVkv9jlgoBCuORMMBK5uOx3a7QRqU91cDvCTRWWGvjwKXcBx9MY4
	 bwuRdZlCs4zCxJFtQHtvCTqKEPWwKYYV4moavps5atjqTdFwbMRKkxIV4j3i+QP5Ul6ZJ
	 sYtGj3xbTOnDA00wiDOaQO5LVVVeMcECuRCJ7vqzfcjXQjvhU74s9foekkXRvPheVEcVm
	 HJHUPNBILHv3Yd7JUz1UmSDX46VOywx3V8XorlABwxPW9+P0owCb/n3vmqQZXgxMsVA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=UQAD7XXz;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id C211F606A33F;
	Fri,  4 Dec 2026 22:08:11 +0000 (UTC)
X-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=UQAD7XXz
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796422086;
	b=QsnHNKPfM6IE6qIVCTxtg0eELJLyxSqjGzxWv7Tm3Zrbi4OBzaqiGSCKpXYdtG8Sa0jq
	 nkaks+0DbvQfNnLVqI06xOWuuUKC529qTABJ9R6nUY218LzajrBYNfsmttc85LeYptILV
	 9wGED5yZv8booPQF1qvrqySacjzJn/ieixBXMIJvw42H6gySDE9VuS2ar90ebcm6V8dgO
	 UIMKAQDh1Lw5cAKVN84wrcuLNN45lStG3eE1E7Rqsv03hU5fltvqDc9BVP5vkDvEQ1cwE
	 IaXFaAYI+vFmf5WYrPRwfb49pM9JK+qbinUUrG4G8pCjoQbjnujE69A3k2T8gygp3HA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796422086;
	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=2kGqxMpXfF+Y75RsudhaGs95g5m2hGvERy2GxvTqwJE=;
	b=gjdX4006sUkqfQn9IFPxxVwwMymLl+yfDtRHPcK/e2zT1vxtDOBoN/fdpirE/BCCYEAV
	 bNefgXKNQfUdLB9rXtohBPlCo1aW+fS094ZidYG26a/1X1x74y7lTrohftcnfqOWsszzw
	 f3DZ6oLxq2AaQhnnv8SOuquYA3Vr99btoIChiHcaU4Y60m7EQQ9YAGMo7rIBipReCNNXw
	 Fm3gd6wI0lwuqMgchTAqzSXAvuPACZ4/ZdkoOIwFeIn39TXfjFC9Ei1ha0V5Q9zdeGTzB
	 9lXUz0JhPnPx1tIkBhm6m+ryw7+wTCnAcHm+djc6NwnWJFTvEfwZZRgLAmPbaXlHjyQ==
X-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=UQAD7XXz;
	arc=none smtp.remote-ip=100.103.45.18
X-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 E42FB606A332;
	Fri,  4 Dec 2026 22:08:05 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1832A1F00A07;
	Fri,  4 Dec 2026 22:08:04 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796422085;
	bh=2kGqxMpXfF+Y75RsudhaGs95g5m2hGvERy2GxvTqwJE=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=UQAD7XXzzQc/tiBcwFcytdsljNFRENu8tzS8O9YmQKn5prJw0ufX+As6vcKWz8ubc
	 36aZYAYD3Ve7mDKsq/Fy/9NAJHYEEYdoKeYd24gzCuTxuMDM6wytpbcY884gza8qjI
	 4oxQYJnny6/6UDJNPJaPvbwBQHXKqvOMGqIBSuoB0MHUwf8JJsV3Pp98r+zgVgBW9q
	 3347QpYgf9hVQfyU+uM943Iz2egtDIwzXe8nZXwtTwKyx6jcQctj5604jGfdbkshRH
	 pBngJQ0pmh5z0lO1U0wZNP2lvJvXONEJ0i4NTRKpdSzfVwyXkjnPErPcUcI/A00KkC
	 MERwTpO3sjmqQ==
X-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
X-In-Reply-To: <52f84807018ab3f05cc1b55e58aef6feeba01d50.1796329894.git.tavip@google.com>
X-sashiko-severity: Medium
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list