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=1796422086; b=QsnHNKPfM6IE6qIVCTxtg0eELJLyxSqjGzxWv7Tm3Zrbi4OBzaqiGSCKpXYdtG8Sa0jq nkaks+0DbvQfNnLVqI06xOWuuUKC529qTABJ9R6nUY218LzajrBYNfsmttc85LeYptILV 9wGED5yZv8booPQF1qvrqySacjzJn/ieixBXMIJvw42H6gySDE9VuS2ar90ebcm6V8dgO UIMKAQDh1Lw5cAKVN84wrcuLNN45lStG3eE1E7Rqsv03hU5fltvqDc9BVP5vkDvEQ1cwE IaXFaAYI+vFmf5WYrPRwfb49pM9JK+qbinUUrG4G8pCjoQbjnujE69A3k2T8gygp3HA== 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== 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 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) 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 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1832A1F00A07; Fri, 4 Dec 2026 22:08:04 +0000 (UTC) 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== Subject: Re: [PATCH net 10/10] selftests: drv-net: devmem: test unreadable skbs on TCP-MD5 and TCP-AO 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 Date: Fri, 04 Dec 2026 22:08:03 +0000 Message-ID: <179642208364.3146.15155256690085962316@kernel.org> In-Reply-To: <52f84807018ab3f05cc1b55e58aef6feeba01d50.1796329894.git.tavip@google.com> References: <52f84807018ab3f05cc1b55e58aef6feeba01d50.1796329894.git.tavip@google.com> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@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 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