From: sashiko-bot@kernel.org
To: "Octavian Purdila" <tavip@google.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH net 06/10] tcp: reject unreadable skbs on TCP-MD5 and TCP-AO
Date: Fri, 04 Dec 2026 21:09:36 +0000 [thread overview]
Message-ID: <sashiko-outbox-250672@kernel.org> (raw)
In-Reply-To: <961d3d81ff49e8dd5829a298c8d3a1a11a1e9bfc.1796329894.git.tavip@google.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] tcp: TOCTOU race in tcp_sendmsg_locked() queues devmem skb
with MD5/AO
- [Low] tcp: missing mac_ctx zeroization on error path in
tcp_ao_hash_skb()
--
commit f478e860f2e25eba93883680fd5a2e35c2811f91
Author: Octavian Purdila <tavip@google.com>
tcp: reject unreadable skbs on TCP-MD5 and TCP-AO
This commit rejects unreadable devmem skbs in TCP-MD5 and TCP-AO digest
calculation and checks the hash helper errors on receive and reset paths.
On transmit, it blocks devmem sends when a TCP-MD5 or TCP-AO key is active,
rejects adding keys while unreadable skbs are queued, and guards
__tcp_transmit_skb().
> diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
> index 80de376a9d2ef..f0ab18b589872 100644
> --- a/net/ipv4/tcp.c
> +++ b/net/ipv4/tcp.c
> @@ -1226,6 +1226,16 @@ int tcp_sendmsg_locked(struct sock *sk, struct msghdr *msg, size_t size)
> /* 'common' sending to sendq */
> }
>
> + if (unlikely(binding)) {
> + struct tcp_key key;
> +
> + tcp_get_current_key(sk, &key);
> + if (tcp_key_is_md5(&key) || tcp_key_is_ao(&key)) {
> + err = -EOPNOTSUPP;
> + goto out_err;
> + }
> + }
> +
> if (sockc_err) {
> err = sockc_err;
> goto out_err;
[Severity: Medium]
Can a concurrent setsockopt(TCP_MD5SIG) race with sk_stream_wait_memory()
and bypass this check?
tcp_sendmsg_locked() only checks tcp_get_current_key() once before the send
loop, while sk_stream_wait_memory() drops and reacquires lock_sock(sk):
CPU0 CPU1
tcp_sendmsg_locked()
tcp_get_current_key() -> none
sk_stream_wait_memory()
release_sock(sk)
setsockopt(TCP_MD5SIG)
lock_sock(sk)
tcp_md5_do_add()
tcp_tx_has_unreadable_skb() -> false
install MD5 key
release_sock(sk)
lock_sock(sk)
queue unreadable devmem skb <-- bypasses check
Once tcp_sendmsg_locked() queues the unreadable skb and returns success,
__tcp_transmit_skb() rejects it with -EOPNOTSUPP without freeing it when
clone_it is set. tcp_write_xmit() then breaks out leaving the skb stuck at
tcp_send_head(sk), wedging TX until timeout, key removal, or socket close.
Re-checking tcp_get_current_key() for binding after sk_stream_wait_memory()
returns would close this window.
[ ... ]
> diff --git a/net/ipv4/tcp_ao.c b/net/ipv4/tcp_ao.c
> index 857b8684e01d9..34c69dfcedd04 100644
> --- a/net/ipv4/tcp_ao.c
> +++ b/net/ipv4/tcp_ao.c
[ ... ]
> @@ -726,7 +733,8 @@ int tcp_ao_hash_skb(unsigned short int family,
> tcp_ao_hash_header(&mac_ctx, th,
> !!(key->keyflags & TCP_AO_KEYF_EXCLUDE_OPT),
> ao_hash, hash_offset, tcp_ao_maclen(key));
> - tcp_ao_hash_skb_data(&mac_ctx, skb, th->doff << 2);
> + if (tcp_ao_hash_skb_data(&mac_ctx, skb, th->doff << 2))
> + goto clear_hash;
> tcp_ao_mac_final(&mac_ctx, hash_buf);
>
> memcpy(ao_hash, hash_buf, tcp_ao_maclen(key));
[Severity: Low]
Does this error path leave mac_ctx unzeroized on the kernel stack?
Jumping to clear_hash skips tcp_ao_mac_final(), which normally clears the
stack-local mac_ctx holding derived TCP-AO traffic-key state. Zeroizing
mac_ctx with memzero_explicit() under clear_hash would match the crypto
library cleanup contract.
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1796329894.git.tavip@google.com?part=6
next prev parent 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 [this message]
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
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-250672@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.