Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Todd Freed" <toddfreed@meta.com>
Cc: linux-rdma@vger.kernel.org
Subject: Re: [PATCH net-next v2 06/12] net/sched: add act_psp for psp transport mode
Date: Fri, 20 Nov 2026 01:31:58 +0000	[thread overview]
Message-ID: <sashiko-outbox-224313@kernel.org> (raw)
In-Reply-To: <20261119013103.1092559-7-toddfreed@meta.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] net/sched: act_psp sets GSO transport_header without pulling L4
  header
--

commit 8cc19eccde3250f6beb0d3d37c3541f580815f9f
Author: Todd Freed <toddfreed@meta.com>

net/sched: add act_psp for psp transport mode

This commit adds the act_psp traffic control action to attach a PSP Tx
association via a METADATA_PSP dst on egress (encap) or drop decrypted
SKB_EXT_PSP state (decap).

> diff --git a/net/sched/act_psp.c b/net/sched/act_psp.c
> new file mode 100644
> index 0000000000000..9056ba2582c2c
> --- /dev/null
> +++ b/net/sched/act_psp.c
> @@ -0,0 +1,439 @@

[ ... ]

> +static bool tcf_psp_set_transport_header(struct sk_buff *skb)
> +{
> +	unsigned int off = skb_network_offset(skb);
> +	const struct iphdr *iph;
> +	unsigned int hlen, len;
> +
> +	switch (skb->protocol) {
> +	case htons(ETH_P_IP):
> +		if (!pskb_may_pull(skb, off + sizeof(*iph)))
> +			return false;
> +		iph = ip_hdr(skb);
> +		if (iph->version != 4 || iph->ihl < 5 || ip_is_fragment(iph))
> +			return false;
> +		hlen = iph->ihl * 4;
> +		len = ntohs(iph->tot_len);
> +		if (!pskb_may_pull(skb, off + hlen))
> +			return false;
> +		break;
> +	case htons(ETH_P_IPV6):
> +		if (!pskb_may_pull(skb, off + sizeof(struct ipv6hdr)))
> +			return false;
> +		if (ipv6_hdr(skb)->version != 6 ||
> +		    ipv6_ext_hdr(ipv6_hdr(skb)->nexthdr))
> +			return false;
> +		hlen = sizeof(struct ipv6hdr);
> +		len = hlen + ntohs(ipv6_hdr(skb)->payload_len);
> +		break;
> +	default:
> +		return false;
> +	}
> +
> +	/* The device takes the length of the payload from the packet: it must
> +	 * hold the IP length, and L2 padding, e.g. of a minimum size frame,
> +	 * must not be encrypted as payload. A GSO skb's header doesn't always
> +	 * carry its length (BIG TCP).
> +	 */
> +	if (!skb_is_gso(skb)) {
> +		if (len < hlen || skb->len - off < len)
> +			return false;
> +		if (pskb_trim_rcsum(skb, off + len))
> +			return false;
> +	}
> +
> +	skb_set_transport_header(skb, off + hlen);
> +	return true;
> +}

[Severity: High]
Can setting transport_header to off + hlen on a GSO skb cause out-of-bounds
L4 header accesses down the transmit path?

At the start of __dev_queue_xmit(), qdisc_pkt_len_segs_init() returns early
without pulling the L4 header if skb_transport_header_was_set(skb) is false
(for instance, after gro_cells_receive() unsets transport_header on a
bridged GSO packet), or pulls the L4 header at the old transport offset if
it differed from off + hlen.

tcf_psp_set_transport_header() only pulls off + hlen bytes before setting
transport_header to off + hlen.  Right after sch_handle_egress(),
psp_xmit_md() -> skb_gso_validate_network_len() -> skb_gso_network_seglen()
-> skb_gso_transport_seglen() reads tcp_hdr(skb)->doff at the new
transport_header past skb->tail, and mlx5e_psp_handle_tx_skb() writes
inner_tcp_hdr(skb)->check out of bounds.

Overwriting transport_header on GSO packets also bypasses the
skb_network_header_len(skb) check in psp_dev_encap_ok().

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261119013103.1092559-1-toddfreed@meta.com?part=6

  reply	other threads:[~2026-11-20  1:31 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19  1:30 [PATCH net-next v2 00/12] psp: introduce socket-less associations Todd Freed
2026-11-19  1:30 ` [PATCH net-next v2 01/12] psp: get netns from net_device instead of sock Todd Freed
2026-11-20  1:31   ` sashiko-bot
2026-11-19  1:30 ` [PATCH net-next v2 02/12] psp: take the psp nexthdr from the packet on encap Todd Freed
2026-11-20  1:31   ` sashiko-bot
2026-11-19  1:30 ` [PATCH net-next v2 03/12] psp: declare psp_assoc_set_tx() in psp.h Todd Freed
2026-11-20  1:31   ` sashiko-bot
2026-11-19  1:30 ` [PATCH net-next v2 04/12] psp: add support for socket-less psp associations Todd Freed
2026-11-20  1:31   ` sashiko-bot
2026-11-19  1:30 ` [PATCH net-next v2 05/12] net: add METADATA_PSP dst to carry a psp association on an skb Todd Freed
2026-11-20  1:31   ` sashiko-bot
2026-11-19  1:30 ` [PATCH net-next v2 06/12] net/sched: add act_psp for psp transport mode Todd Freed
2026-11-20  1:31   ` sashiko-bot [this message]
2026-11-19  1:30 ` [PATCH net-next v2 07/12] net/sched: flower: add psp_spi, psp_ver, and psp_dev matches Todd Freed
2026-11-20  1:31   ` sashiko-bot
2026-11-19  1:30 ` [PATCH net-next v2 08/12] selftests: drv-net: psp: test socket-less associations and the tc psp action Todd Freed
2026-11-20  1:32   ` sashiko-bot
2026-11-19  1:31 ` [PATCH net-next v2 09/12] selftests: drv-net: psp: test that software encap on ingress drops Todd Freed
2026-11-20  1:32   ` sashiko-bot
2026-11-19  1:31 ` [PATCH net-next v2 10/12] selftests: tc-testing: run dependsOn probes outside the test namespace Todd Freed
2026-11-20  1:32   ` sashiko-bot
2026-11-19  1:31 ` [PATCH net-next v2 11/12] selftests: tc-testing: add tests for the psp action Todd Freed
2026-11-20  1:32   ` sashiko-bot
2026-11-19  1:31 ` [PATCH net-next v2 12/12] Documentation: networking: psp: document socket-less associations Todd Freed
2026-11-20  1:32   ` sashiko-bot

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-224313@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=toddfreed@meta.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox