From: sashiko-bot@kernel.org
To: "Jason Xing" <kerneljasonxing@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH net-next v2 2/6] net: export sock_disable_timestamp() declaration
Date: Sat, 30 May 2026 00:46:01 +0000 [thread overview]
Message-ID: <20260530004602.5C1951F0089A@smtp.kernel.org> (raw)
In-Reply-To: <20260521135244.40869-3-kerneljasonxing@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Critical] Lockless modification of `sk->sk_flags` from a BPF context will race with user context socket modifications, corrupting critical socket flags.
- [High] Concurrent lockless calls to `sock_disable_timestamp` result in a Time-of-Check to Time-of-Use (TOCTOU) race that unbalances the global timestamp reference counter.
--
commit 070236e8d76283be57936f36bb4d9ae98296d6e1
Author: Jason Xing <kerneljasonxing@gmail.com>
net: export sock_disable_timestamp() declaration
This commit removes the static label from sock_disable_timestamp() and
exports its declaration. This change allows the BPF timestamping RX feature
to dynamically turn off the global time record function.
> diff --git a/net/core/sock.c b/net/core/sock.c
> index f362e3ce1efb6..f3d78da3aeba3 100644
> --- a/net/core/sock.c
> +++ b/net/core/sock.c
> @@ -474,7 +474,7 @@ static bool sock_needs_netstamp(const struct sock *sk)
> }
> }
>
> -static void sock_disable_timestamp(struct sock *sk, unsigned long flags)
> +void sock_disable_timestamp(struct sock *sk, unsigned long flags)
> {
> if (sk->sk_flags & flags) {
> sk->sk_flags &= ~flags;
[Severity: Critical]
Since this function is being exported for use by the BPF timestamping rx
feature, will it be called from a lockless context?
If the BPF_SOCK_OPS_TSTAMP_RCV_CB hook calls this outside the socket lock
(for instance, after tcp_recvmsg() drops lock_sock(sk)), this non-atomic
read-modify-write of sk->sk_flags could race with user context socket
modifications like setsockopt().
Could this concurrent access cause torn reads and writes, permanently
corrupting sk_flags and potentially leading to use-after-free issues if
lifecycle flags like SOCK_DEAD are lost?
[Severity: High]
Could exporting this for lockless BPF contexts also result in a Time-of-Check
to Time-of-Use race that unbalances the global network timestamping reference
count?
If multiple threads execute recvmsg() on the same socket concurrently without
the socket lock, they might both evaluate "if (sk->sk_flags & flags)" as true,
clear the flags, and then subsequently call net_disable_timestamp().
Would this double-decrement unbalance the global counter and prematurely
disable network timestamping for all sockets on the system?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260521135244.40869-1-kerneljasonxing@gmail.com?part=2
next prev parent reply other threads:[~2026-05-30 0:46 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-21 13:52 [PATCH net-next v2 0/6] bpf-timestamp: support rx side Jason Xing
2026-05-21 13:52 ` [PATCH net-next v2 1/6] bpf: Add bpf_ktime_get_real_ns() kfunc Jason Xing
2026-05-21 13:52 ` [PATCH net-next v2 2/6] net: export sock_disable_timestamp() declaration Jason Xing
2026-05-30 0:46 ` sashiko-bot [this message]
2026-05-21 13:52 ` [PATCH net-next v2 3/6] bpf: support bpf_setsockopt for bpf timestamping rx feature Jason Xing
2026-05-23 4:02 ` Kuniyuki Iwashima
2026-05-30 0:46 ` sashiko-bot
2026-05-21 13:52 ` [PATCH net-next v2 4/6] bpf: add BPF_SOCK_OPS_TSTAMP_RCV_CB callback Jason Xing
2026-05-30 0:46 ` sashiko-bot
2026-05-21 13:52 ` [PATCH net-next v2 5/6] bpf: enable bpf timestamping rx in TCP layer Jason Xing
2026-05-23 3:45 ` Kuniyuki Iwashima
2026-05-28 0:50 ` Jason Xing
2026-05-21 13:52 ` [PATCH net-next v2 6/6] selftests/bpf: Add RX latency tests for bpf timestamping Jason Xing
2026-05-30 0:46 ` sashiko-bot
2026-05-23 3:47 ` [PATCH net-next v2 0/6] bpf-timestamp: support rx side Kuniyuki Iwashima
2026-05-28 0:50 ` Jason Xing
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=20260530004602.5C1951F0089A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=kerneljasonxing@gmail.com \
--cc=sashiko-reviews@lists.linux.dev \
/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.