From: sashiko-bot@kernel.org
To: "Jason Xing" <kerneljasonxing@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH net-next 5/6] bpf: enable bpf timestamping rx in TCP layer
Date: Tue, 19 May 2026 08:25:14 +0000 [thread overview]
Message-ID: <20260519082514.AD96BC2BCC6@smtp.kernel.org> (raw)
In-Reply-To: <20260518082344.96647-6-kerneljasonxing@gmail.com>
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [High] BPF sock_ops hook is called without holding the socket lock, violating core locking rules and risking data corruption.
- [Medium] Missing BPF RX timestamping for zero-copy receive (tcp_zerocopy_receive).
- [Medium] MSG_PEEK causes event duplication, corrupting BPF statistics.
- [Medium] Data race due to lockless read of sk->sk_bpf_cb_flags.
--
commit bdfc9a5e79a8f2a8060029cde75cfb38b923754a
Author: Jason Xing <kerneljasonxing@gmail.com>
bpf: enable bpf timestamping rx in TCP layer
This commit introduces BPF RX timestamping for TCP by adding a BPF hook
to tcp_recvmsg(). It evaluates timestamping flags and conditionally
calls bpf_skops_rx_timestamping().
> diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
> index 21ece4c716121..64c69bb3578af 100644
> --- a/net/ipv4/tcp.c
> +++ b/net/ipv4/tcp.c
> @@ -2949,8 +2949,18 @@ int tcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int flags)
> release_sock(sk);
>
> if ((cmsg_flags | msg->msg_get_inq) && ret >= 0) {
> - if (cmsg_flags & TCP_CMSG_TS)
> - tcp_recv_timestamp(msg, sk, &tss);
> + if (cmsg_flags & TCP_CMSG_TS) {
> + u32 tsflags = READ_ONCE(sk->sk_tsflags);
> +
> + if (cgroup_bpf_enabled(CGROUP_SOCK_OPS) &&
> + SK_BPF_CB_FLAG_TEST(sk, SK_BPF_CB_RX_TIMESTAMPING))
Since the socket lock was released above, is it safe to read
sk->sk_bpf_cb_flags here without READ_ONCE()? It appears
bpf_sock_ops_cb_flags_set() could modify this concurrently, potentially
causing a data race.
> + bpf_skops_rx_timestamping(sk, &tss,
> + BPF_SOCK_OPS_TSTAMP_RCV_CB);
Does executing the BPF_PROG_TYPE_SOCK_OPS program here without holding the
socket lock risk data races? Since the program receives a full socket
context and can call helpers like bpf_setsockopt(), this might trigger
assertions in sock_owned_by_me(sk) or corrupt socket state.
If MSG_PEEK is passed in the flags, will this cause the BPF program to be
invoked multiple times for the same skb? The callback doesn't seem to
receive arguments indicating a peek, which might artificially inflate packet
counts and skew latency metrics.
> + if (sock_flag(sk, SOCK_RCVTSTAMP) ||
> + tsflags & SOF_TIMESTAMPING_SOFTWARE ||
> + tsflags & SOF_TIMESTAMPING_RAW_HARDWARE)
> + tcp_recv_timestamp(msg, sk, &tss);
Will packets processed via the zero-copy receive path miss these RX
timestamp events? High-performance applications using tcp_zerocopy_receive()
go through tcp_zc_finalize_rx_tstamp(), which directly calls
tcp_recv_timestamp() but seems to omit this new BPF callback.
> + }
> if ((cmsg_flags & TCP_CMSG_INQ) | msg->msg_get_inq) {
> msg->msg_inq = tcp_inq_hint(sk);
> if (cmsg_flags & TCP_CMSG_INQ)
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260518082344.96647-1-kerneljasonxing@gmail.com?part=5
next prev parent reply other threads:[~2026-05-19 8:25 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-18 8:23 [PATCH net-next 0/6] bpf-timetamp: support rx side Jason Xing
2026-05-18 8:23 ` [PATCH net-next 1/6] bpf: Add bpf_ktime_get_real_ns() kfunc Jason Xing
2026-05-18 11:57 ` Jesper Dangaard Brouer
2026-05-18 12:35 ` Jason Xing
2026-05-18 8:23 ` [PATCH net-next 2/6] net: export sock_disable_timestamp() declaration Jason Xing
2026-05-19 8:25 ` sashiko-bot
2026-05-19 11:50 ` Jason Xing
2026-05-18 8:23 ` [PATCH net-next 3/6] bpf: support bpf_setsockopt for bpf timestamping rx feature Jason Xing
2026-05-18 8:23 ` [PATCH net-next 4/6] bpf: add BPF_SOCK_OPS_TSTAMP_RCV_CB callback Jason Xing
2026-05-18 8:23 ` [PATCH net-next 5/6] bpf: enable bpf timestamping rx in TCP layer Jason Xing
2026-05-18 13:01 ` Jesper Dangaard Brouer
2026-05-18 13:53 ` Jason Xing
2026-05-18 16:40 ` Jesper Dangaard Brouer
2026-05-18 23:16 ` Jason Xing
2026-05-18 23:24 ` Jason Xing
2026-05-19 9:57 ` Toke Høiland-Jørgensen
2026-06-03 11:07 ` Toke Høiland-Jørgensen
2026-05-18 15:34 ` Stanislav Fomichev
2026-05-18 23:56 ` Jason Xing
2026-05-19 8:25 ` sashiko-bot [this message]
2026-05-19 10:31 ` Jiayuan Chen
2026-05-19 12:26 ` Jason Xing
2026-05-18 8:23 ` [PATCH net-next 6/6] selftests/bpf: Add RX latency tests for bpf timestamping Jason Xing
2026-05-19 8:25 ` sashiko-bot
2026-05-19 12:05 ` Jason Xing
2026-05-18 11:46 ` [PATCH net-next 0/6] bpf-timetamp: support rx side Jesper Dangaard Brouer
2026-05-18 12:32 ` 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=20260519082514.AD96BC2BCC6@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.