Netdev List
 help / color / mirror / Atom feed
* [PATCH] netfilter: flowtable: update skb csum after pppoe header push
@ 2026-12-03  9:49 lvjunyu
  2026-12-03  9:59 ` netdev-bot+sinfo
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: lvjunyu @ 2026-12-03  9:49 UTC (permalink / raw)
  To: pablo; +Cc: fw, phil, netfilter-devel, netdev, coreteam, lvjunyu

nf_flow_pppoe_push() pushes a new PPPoE session header in front of
the packet data but does not fold it into skb->csum.

For CHECKSUM_COMPLETE skbs the checksum covers everything from
skb->data onwards, so after __skb_push(PPPOE_SES_HLEN) the 8 bytes
of the new header are not accounted for in skb->csum.  Any later
consumer doing incremental checksum updates on top of skb->csum
then starts from a stale initial value and can drop valid packets.

This is inconsistent with the sibling paths, which all keep the
checksum in sync: the vlan push path uses skb_postpush_rcsum() and
the vlan/pppoe pop paths use skb_pull_rcsum().

Mirror the vlan push path and use skb_postpush_rcsum() so the
pushed header is accounted for in CHECKSUM_COMPLETE skbs.  Call it
after the header fields are written, since it folds in the bytes
as they are at call time.

Fixes: 18d27bed0880 ("netfilter: flowtable: inline pppoe encapsulation in xmit path")
Signed-off-by: lvjunyu <lvjunyu@cmss.chinamobile.com>
---
 net/netfilter/nf_flow_table_ip.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/netfilter/nf_flow_table_ip.c b/net/netfilter/nf_flow_table_ip.c
index 19cafae748ab..a0b541b811b4 100644
--- a/net/netfilter/nf_flow_table_ip.c
+++ b/net/netfilter/nf_flow_table_ip.c
@@ -585,6 +585,8 @@ static int nf_flow_pppoe_push(struct sk_buff *skb, u16 id,
 	ph->proto	= proto;
 	skb->protocol	= htons(ETH_P_PPP_SES);
 
+	skb_postpush_rcsum(skb, skb->data, PPPOE_SES_HLEN);
+
 	return 0;
 }
 
-- 
2.43.0




^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] netfilter: flowtable: update skb csum after pppoe header push
  2026-12-03  9:49 [PATCH] netfilter: flowtable: update skb csum after pppoe header push lvjunyu
@ 2026-12-03  9:59 ` netdev-bot+sinfo
  2026-12-03 13:51 ` lvjunyu
  2026-12-04 10:42 ` netdev-bot+sashiko
  2 siblings, 0 replies; 4+ messages in thread
From: netdev-bot+sinfo @ 2026-12-03  9:59 UTC (permalink / raw)
  To: lvjunyu; +Cc: pablo, fw, phil, netfilter-devel, netdev, coreteam

Hi!

This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:

 - How the issue was discovered, e.g. hit in production, hit during
   development, syzbot report, manual code inspection, LLM or static
   analysis tool scan.

 - Whether the issue was actually triggered, or is only theoretical
   (e.g. found by LLM and not proven at runtime). If it was triggered
   please include the symptoms, like the stack trace or kernel messages.

Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.

*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
-- 
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] netfilter: flowtable: update skb csum after pppoe header push
  2026-12-03  9:49 [PATCH] netfilter: flowtable: update skb csum after pppoe header push lvjunyu
  2026-12-03  9:59 ` netdev-bot+sinfo
@ 2026-12-03 13:51 ` lvjunyu
  2026-12-04 10:42 ` netdev-bot+sashiko
  2 siblings, 0 replies; 4+ messages in thread
From: lvjunyu @ 2026-12-03 13:51 UTC (permalink / raw)
  To: netdev-bot+sinfo
  Cc: pablo, fw, phil, netfilter-devel, netdev, coreteam, lvjunyu

The issue was found by manual code inspection and has not been
triggered at runtime yet. Details for both questions:

How the issue was discovered:

While reviewing the flowtable encapsulation paths in
nf_flow_table_ip.c I compared nf_flow_pppoe_push() against its
sibling helpers. Every sibling path keeps skb->csum in sync when
it moves skb->data:

  - nf_flow_vlan_push() calls skb_postpush_rcsum() after pushing
    the vlan header
  - the pop path (nf_flow_encap_pop()) uses skb_pull_rcsum() for
    both vlan and pppoe

nf_flow_pppoe_push() pushes the 8-byte PPPoE session header
(__skb_push(PPPOE_SES_HLEN)) but never folds those bytes into
skb->csum, so for CHECKSUM_COMPLETE skbs the checksum stops
covering the bytes from skb->data onwards. Checking the history
(cgit, commit 18d27bed0880) shows the call was missing on the day
the helper was introduced, so this is a defect since the first
version, not a regression of a recent refactor.

Whether the issue was actually triggered:

Not triggered at runtime so far; the defect was established by
source inspection, so the runtime evidence is an impact analysis
rather than a trace:

with a pppoe-offloaded flow and a CHECKSUM_COMPLETE skb, every
later incremental checksum update on top of skb->csum starts from
a stale base (the pushed 8 header bytes are missing from it), so
downstream consumers can compute a wrong final checksum and drop
valid packets. The fix mirrors the vlan push path and only
touches the pppoe push path, so the change is limited to keeping
the existing invariant on one more path.

The patch is build-verified against mainline tip (nf_flow_table_ip.o
compiled clean) and checkpatch-clean.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] netfilter: flowtable: update skb csum after pppoe header push
  2026-12-03  9:49 [PATCH] netfilter: flowtable: update skb csum after pppoe header push lvjunyu
  2026-12-03  9:59 ` netdev-bot+sinfo
  2026-12-03 13:51 ` lvjunyu
@ 2026-12-04 10:42 ` netdev-bot+sashiko
  2 siblings, 0 replies; 4+ messages in thread
From: netdev-bot+sashiko @ 2026-12-04 10:42 UTC (permalink / raw)
  To: lvjunyu; +Cc: pablo, fw, phil, netfilter-devel, netdev, coreteam, kuba

Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 1 · Medium: 0 · Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [High] The fix does not deliver what its commit message promises.

--

netfilter: flowtable: update skb csum after pppoe header push

This patch adds a skb_postpush_rcsum() call to nf_flow_pppoe_push(). The
goal is for skb->csum on CHECKSUM_COMPLETE skbs to cover the newly pushed
8 byte PPPoE session header. It follows what the vlan push path already
does.

> diff --git a/net/netfilter/nf_flow_table_ip.c b/net/netfilter/nf_flow_table_ip.c
> index 19cafae748abe..a0b541b811b40 100644
> --- a/net/netfilter/nf_flow_table_ip.c
> +++ b/net/netfilter/nf_flow_table_ip.c
> @@ -585,6 +585,8 @@ static int nf_flow_pppoe_push(struct sk_buff *skb, u16 id,
>  	ph->proto	= proto;
>  	skb->protocol	= htons(ETH_P_PPP_SES);
>  
> +	skb_postpush_rcsum(skb, skb->data, PPPOE_SES_HLEN);
> +

[Severity: High]
Does this actually leave skb->csum covering everything from skb->data
onwards by the time the skb reaches later consumers?

nf_flow_queue_xmit() calls nf_flow_encap_push() and then
__nf_flow_queue_xmit(). That pushes the Ethernet header right after the
PPPoE header, with no rcsum update:

net/netfilter/nf_flow_table_ip.c:__nf_flow_queue_xmit() {
    ...
	skb->dev = dev;
	dev_hard_header(skb, dev, ntohs(skb->protocol),
			xmit->dest, xmit->source, skb->len);
	dev_queue_xmit(skb);
}

eth_header() does a plain skb_push(skb, ETH_HLEN). After it runs,
skb->data points at the Ethernet header. skb->csum still covers only
PPPoE plus L3 onward. The checksum is still stale, just off by 14 bytes
instead of 22.

The consumers that keep CHECKSUM_COMPLETE across L2 expect skb->csum to
cover the MAC header. For example, with a veth egress device,
__dev_forward_skb2() in net/core/dev.c does:

	reason = eth_type_trans_careful(skb, dev);
	...
	skb_postpull_rcsum(skb, eth_hdr(skb), ETH_HLEN);

This subtracts Ethernet bytes that were never added. The tc mirred
egress to ingress redirect in tcf_mirred_to_dev() does the same thing
with skb_pull_rcsum(skb_to_send, mac_len). Will these still compute a
wrong checksum after this patch?

There is also an earlier problem on IPv6 flows. nf_flow_offload_ipv6_forward()
changes L3 bytes without updating skb->csum:

	ip6h->hop_limit--;

So for IPv6, skb->csum is already stale before nf_flow_pppoe_push() runs,
and folding in the pushed header cannot make it correct again.

The core forwarding paths handle this by downgrading CHECKSUM_COMPLETE
with skb_forward_csum(). That is done in ip_forward(), in ip6_forward()
before the hop_limit decrement, and in the bridge forward path.
nf_flow_table_ip.c never calls skb_forward_csum() and never sets
ip_summed.

Flowtable hooks are only registered at NF_NETDEV_INGRESS, so
NIC-provided CHECKSUM_COMPLETE skbs from ordinary forwarded traffic reach
this path. nf_flow_vlan_push(), cited in the commit message as the
precedent, has the same limitation.

Would calling skb_forward_csum() in the flowtable forward paths, as the
core stack does, be a better fix? That would make the per-header rcsum
calls unnecessary. The other option is to also fold the L2 header pushed
by dev_hard_header() and every L3 change, such as the IPv6 hop_limit
decrement, into skb->csum.

>  	return 0;
>  }

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261203094901.164422-1-lvjunyu%40cmss.chinamobile.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-12-04 10:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03  9:49 [PATCH] netfilter: flowtable: update skb csum after pppoe header push lvjunyu
2026-12-03  9:59 ` netdev-bot+sinfo
2026-12-03 13:51 ` lvjunyu
2026-12-04 10:42 ` netdev-bot+sashiko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox