All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Kuniyuki Iwashima" <kuniyu@google.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH v1 bpf-next/net 3/5] bpf: Add bpf_skb_set_hwtstamp().
Date: Fri, 12 Jun 2026 00:33:52 +0000	[thread overview]
Message-ID: <20260612003353.4977F1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260612001803.23341-4-kuniyu@google.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Unsafe modification of shared SKB data (skb_shinfo) via insufficient uncloning
--

commit 96bf1885d42f4593da3e164388ab66653eb4e518
Author: Kuniyuki Iwashima <kuniyu@google.com>

bpf: Add bpf_skb_set_hwtstamp().

Adds a kfunc to update skb_hwtstamps(skb)->hwtstamp at tc/ingress. This
allows transparent proxying of RX hardware timestamps via SCM_TIMESTAMPING to
socket applications.

> diff --git a/net/core/filter.c b/net/core/filter.c
> index acdc66aa4f27c..ab7adef9c0159 100644
> --- a/net/core/filter.c
> +++ b/net/core/filter.c

[ ... ]

> @@ -12372,6 +12372,28 @@ __bpf_kfunc int bpf_sock_ops_enable_tx_tstamp(struct bpf_sock_ops_kern *skops,
>  	return 0;
>  }
>  
> +__bpf_kfunc int bpf_skb_set_hwtstamp(struct __sk_buff *s,
> +				     struct bpf_hwtstamp *attrs, int attrs__sz)
> +{
> +	struct sk_buff *skb = (struct sk_buff *)s;
> +
> +	if (attrs__sz != sizeof(*attrs) || attrs->reserved)
> +		return -EINVAL;
> +
> +	if (!skb_at_tc_ingress(skb))
> +		return -EINVAL;
> +
> +	if (skb_header_unclone(skb, GFP_ATOMIC))
> +		return -ENOMEM;
> +
> +	skb_clear_tstamp(skb);
> +	skb_hwtstamps(skb)->hwtstamp = attrs->hwtstamp;

[Severity: High]
Does using skb_header_unclone() safely protect against modifying a shared
skb_shinfo(skb) here?

For TCP transmit clones, the header is released and skb->nohdr is set to 1.
This makes skb_header_cloned() return false, even though the data buffer and
skb_shinfo are still shared with the original packet in the TCP write queue.

When these packets loop back to TC ingress, such as via veth or loopback,
and are modified by the BPF program, skb_header_unclone() will skip
reallocation.

Could this lead to silent data corruption of the original socket buffer's
skb_shinfo? Would using skb_unclone() instead be necessary to prevent this?

> +
> +	bpf_compute_data_pointers(skb);
> +
> +	return 0;
> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260612001803.23341-1-kuniyu@google.com?part=3

  reply	other threads:[~2026-06-12  0:33 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-12  0:17 [PATCH v1 bpf-next/net 0/5] bpf: Support RX/TX HW timestamp proxy Kuniyuki Iwashima
2026-06-12  0:17 ` [PATCH v1 bpf-next/net 1/5] ethtool: Introduce ETHTOOL_MSG_TSINFO_SET for virtual interfaces Kuniyuki Iwashima
2026-06-12  0:17 ` [PATCH v1 bpf-next/net 2/5] bpf: Rename bpf_kfunc_set_tcp_reqsk to bpf_kfunc_set_sched_cls Kuniyuki Iwashima
2026-06-12  0:17 ` [PATCH v1 bpf-next/net 3/5] bpf: Add bpf_skb_set_hwtstamp() Kuniyuki Iwashima
2026-06-12  0:33   ` sashiko-bot [this message]
2026-06-12  5:41     ` Kuniyuki Iwashima
2026-06-12  0:17 ` [PATCH v1 bpf-next/net 4/5] bpf: Add kfunc to proxy TX HW Timestamp Kuniyuki Iwashima
2026-06-12  0:33   ` sashiko-bot
2026-06-12  5:59     ` Kuniyuki Iwashima
2026-06-12  3:37   ` Alexei Starovoitov
2026-06-12  4:16     ` Kuniyuki Iwashima
2026-06-12  0:17 ` [PATCH v1 bpf-next/net 5/5] selftest: bpf: Add test for hwtstamp proxy Kuniyuki Iwashima
2026-06-12  0:31   ` sashiko-bot
2026-06-12  6:03     ` Kuniyuki Iwashima
2026-06-12 16:04       ` Alexei Starovoitov
2026-06-12 18:55         ` Kuniyuki Iwashima

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=20260612003353.4977F1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=kuniyu@google.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.