From: sashiko-bot@kernel.org
To: "Willem Ferguson" <wferguson@cloudflare.com>
Cc: bpf@vger.kernel.org
Subject: Re: [RFC PATCH net-next 3/4] tcp: add TCP_TS_ID socket option
Date: Wed, 14 Oct 2026 10:39:23 +0000 [thread overview]
Message-ID: <sashiko-outbox-171147@kernel.org> (raw)
In-Reply-To: <20261013103906.2660384-4-wferguson@cloudflare.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] tcp: lockless data race in do_tcp_getsockopt for TCP_TS_ID
--
commit 7c66b48d6e891deb8097ef54e673d4be713fb65b
Author: Willem Ferguson <wferguson@cloudflare.com>
tcp: add TCP_TS_ID socket option
Add a read-only TCP_TS_ID socket option so applications and tests can see
which TSval identifier was assigned to a connection. The value packs the
identifier width and the identifier itself, chosen by BPF when the SYN
arrives.
> diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
> index af994edde7f73..5991b16396b9f 100644
> --- a/net/ipv4/tcp.c
> +++ b/net/ipv4/tcp.c
> @@ -4711,6 +4711,9 @@ int do_tcp_getsockopt(struct sock *sk, int level,
> else
> val &= ~1;
> break;
> + case TCP_TS_ID:
> + val = ((u32)tp->ts_id_bits << TCP_TS_ID_BITS_SHIFT) | tp->ts_id;
> + break;
[Severity: Low]
Is it possible for tp->ts_id and tp->ts_id_bits to be concurrently modified
here without the socket lock?
Looking at do_tcp_getsockopt(), these fields are read locklessly.
If the socket is concurrently disconnected (for example, by calling
connect() with AF_UNSPEC, which calls tcp_disconnect()), the fields are
zeroed out:
net/ipv4/tcp.c:tcp_disconnect() {
...
tp->ts_id = 0;
tp->ts_id_bits = 0;
...
}
Could this concurrent modification trigger a KCSAN data race warning or
result in returning an inconsistent or torn value to userspace?
Other locklessly accessed fields in this switch statement use READ_ONCE(),
like tp->notsent_lowat right below this. Would it make sense to use
READ_ONCE() here and WRITE_ONCE() in tcp_disconnect() to prevent this?
> case TCP_NOTSENT_LOWAT:
> val = READ_ONCE(tp->notsent_lowat);
> break;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261013103906.2660384-1-wferguson@cloudflare.com?part=3
next prev parent reply other threads:[~2026-10-14 10:39 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-13 10:39 [RFC PATCH net-next 0/4] tcp: carry a BPF-chosen identifier in TSval low bits Willem Ferguson
2026-10-13 10:39 ` [RFC PATCH net-next 1/4] tcp: add plumbing to carry an " Willem Ferguson
2026-10-13 10:39 ` [RFC PATCH net-next 2/4] tcp: add BPF_SOCK_OPS_TCP_TS_ID_CB to assign a TSval identifier Willem Ferguson
2026-10-14 10:39 ` sashiko-bot
2026-10-14 17:50 ` Jakub Sitnicki
2026-10-13 10:39 ` [RFC PATCH net-next 3/4] tcp: add TCP_TS_ID socket option Willem Ferguson
2026-10-14 10:39 ` sashiko-bot [this message]
2026-10-13 10:39 ` [RFC PATCH net-next 4/4] selftests/bpf: add tcp_ts_id test Willem Ferguson
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-171147@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=wferguson@cloudflare.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.