All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Octavian Purdila" <tavip@google.com>
Cc: bpf@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 21:09:38 +0000	[thread overview]
Message-ID: <sashiko-outbox-250676@kernel.org> (raw)
In-Reply-To: <52f84807018ab3f05cc1b55e58aef6feeba01d50.1796329894.git.tavip@google.com>

Thank you for your contribution! Sashiko AI review found 6 potential
issues to consider:
- [Low] selftests/drv-net: missing ksft_disruptive on check_tcp_auth()
- [Low] selftests: drv-net: run_tcp_auth() uses remote socat without
  require_cmd()
- [Low] selftests: drv-net: hardcoded asm-generic SO_ZEROCOPY and
  SCM_DEVMEM_DMABUF
- [Low] selftests: devmem: run_tcp_auth() aborts sender below
  TCP_RTO_MIN (150ms)
- [Low] selftests: devmem: run_tcp_auth() sends local-endian structs to
  remote
- [Low] selftests: drv-net: devmem: TCP_CORK 200ms probe timer races
  run_tcp_auth()
--

commit 7c6c1d51d9efdb69a8ea4cff34ab61665639eca4
Author: Octavian Purdila <tavip@google.com>

selftests: drv-net: devmem: test unreadable skbs on TCP-MD5 and TCP-AO

This commit adds a devmem.py test case for TCP-MD5 and TCP-AO sockets,
verifying that devmem TX sends and key additions with queued unreadable
skbs fail with EOPNOTSUPP while unreadable incoming authenticated
segments are dropped.

> diff --git a/tools/testing/selftests/drivers/net/hw/devmem.py b/tools/testing/selftests/drivers/net/hw/devmem.py
> index d15118060d261..d7e3915e4ee36 100755
> --- a/tools/testing/selftests/drivers/net/hw/devmem.py
> +++ b/tools/testing/selftests/drivers/net/hw/devmem.py

[ ... ]

> @@ -41,12 +41,18 @@ def check_rx_tls(cfg) -> None:
>      run_rx_tls(cfg)
>  
>  
> +@ksft_variants(["md5", "ao"])
> +def check_tcp_auth(cfg, mode) -> None:
> +    """Run the TCP-MD5 or TCP-AO unreadable RX/TX test."""
> +    run_tcp_auth(cfg, mode)

[Severity: Low]
Should check_tcp_auth() carry @ksft_disruptive below @ksft_variants()?

run_tcp_auth() calls _setup_devmem_rx_queue(), which reconfigures HDS
rings via ethnl.rings_set(), changes the RSS indirection table, and binds
a devmem RX queue.  Without @ksft_disruptive, running devmem.py with
DISRUPTIVE=False on a single-interface system will still execute this
test and can disconnect NETIF.

> 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

[ ... ]

> @@ -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

[Severity: Low]
Will these hardcoded asm-generic values break on SPARC and PA-RISC?

On SPARC, SO_ZEROCOPY is 0x003e (62) and SCM_DEVMEM_DMABUF is 0x0058 (88),
while 60 is SCM_TIMESTAMPING_PKTINFO; PA-RISC uses 0x4035 and 0x404f.
Passing the wrong constants makes setsockopt() and _sendmsg_devmem_tx()
target unrelated options or fail instead of exercising devmem TX.

[ ... ]

> +    try:
> +        if mode == "md5":
> +            opt = _pack_md5sig(af, cfg.remote_addr, key)
> +            remote_opt = _pack_md5sig(af, cfg.addr, key)
> +            opt_num = TCP_MD5SIG_EXT
> +        else:
> +            opt = _pack_tcp_ao_add(af, cfg.remote_addr, key)
> +            remote_opt = _pack_tcp_ao_add(af, cfg.addr, key)
> +            opt_num = TCP_AO_ADD_KEY
> +        srv.setsockopt(socket.IPPROTO_TCP, opt_num, opt)
> +    except OSError as e:
> +        if e.errno in (errno.ENOPROTOOPT, errno.EOPNOTSUPP, errno.ENOENT):
> +            raise KsftSkipEx(f"{mode} unsupported on local kernel") from e
> +        raise
> +
> +    opt_hex = remote_opt.hex()
> +    probe_script = (
> +        f"import socket\n"
> +        f"with socket.socket({int(af)}, socket.SOCK_STREAM) as s:\n"
> +        f"    s.setsockopt(socket.IPPROTO_TCP, {opt_num}, "
> +        f"bytes.fromhex('{opt_hex}'))\n"
> +    )
> +    if _remote_py(cfg, probe_script, fail=False).ret != 0:
> +        raise KsftSkipEx(f"{mode} unsupported on remote kernel")

[Severity: Low]
Can remote_opt fail with EINVAL when the local and remote hosts have
different endianness?

_pack_md5sig() and _pack_tcp_ao_add() serialize sa_family, tcpm_keylen,
and the _TcpAoAdd bitfields in local host byte and bit order.  On a
mixed-endian SSH setup (for example, a big-endian DUT with a
little-endian remote endpoint), the remote kernel rejects the swapped
option with EINVAL and probe_script silently turns that into a skip.
Packing the struct inside the remote Python script avoids the mismatch.

[ ... ]

> +s.recv(1)
> +s.sendall(b"authenticated-payload")
> +time.sleep(0.15)
> +s.setsockopt(socket.SOL_SOCKET, socket.SO_LINGER, struct.pack("ii", 1, 0))
> +s.close()

[Severity: Low]
Could this 0.15s sleep cause ksft_busy_wait() to time out if the payload
segment is dropped?

Linux TCP_RTO_MIN is 200ms, so neither the normal RTO nor a single-packet
tail loss probe can fire before sender_script aborts the socket with
SO_LINGER (1, 0) and purges the retransmit queue.  Blocking on s.recv(1)
with a safety timeout until the local side closes conn, as run_rx_tls()
does, allows retransmissions and avoids the fixed 150ms idle delay.

[ ... ]

> +    cork_port = rand_port()
> +    with bkg(socat_listen(cfg, cork_port), host=cfg.remote):
> +        wait_port_listen(cork_port, host=cfg.remote)

[Severity: Low]
Is cfg.require_cmd("socat", local=False, remote=True) missing here?

Neither run_tcp_auth() nor socat_listen() checks for socat on the remote
host, so if socat is not installed on cfg.remote the test fails with a
5-second wait_port_listen() timeout instead of skipping cleanly.

[ ... ]

> +        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)

[Severity: Low]
Can the TCP_CORK probe timer flush the 64-byte skb before the final
setsockopt() runs?

Holding back the partial skb under TCP_CORK arms ICSK_TIME_PROBE0 for
200ms via __tcp_push_pending_frames() -> tcp_check_probe_timer(), and
TCP_REPAIR_ON does not cancel that timer:

test thread                        <softirq>
_sendmsg_devmem_tx(..., 64)
  tcp_check_probe_timer()
  [>= 200ms delay]
                                   tcp_probe_timer()
                                     tcp_write_wakeup()
                                       tcp_transmit_skb()  <-- flushes skb
                                   [peer ACKs, tcp_clean_rtx_queue() frees]
setsockopt(..., opt_num, opt)
  tcp_tx_has_unreadable_skb() == false  <-- succeeds instead of EOPNOTSUPP

Under a loaded CI VM or debug kernel, setsockopt() then succeeds, leaving
cm.exception as None and failing on cm.exception.errno with
AttributeError.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1796329894.git.tavip@google.com?part=10

  reply	other threads:[~2026-12-04 21:09 UTC|newest]

Thread overview: 42+ 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 21:09   ` sashiko-bot
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 21:09   ` sashiko-bot
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 21:09   ` sashiko-bot
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 21:09   ` sashiko-bot
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 21:09   ` sashiko-bot
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 21:09   ` sashiko-bot
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 21:09   ` sashiko-bot
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 21:09   ` sashiko-bot [this message]
2026-12-04 22:08   ` netdev-bot+sashiko

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=sashiko-outbox-250676@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=tavip@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.