From: Josef Bacik <josef@toxicpanda.com>
To: Paolo Abeni <pabeni@redhat.com>
Cc: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Simon Horman <horms@kernel.org>,
Andrew Lunn <andrew+netdev@lunn.ch>,
Juergen Gross <jgross@suse.com>,
Stefano Stabellini <sstabellini@kernel.org>,
Willem de Bruijn <willemdebruijn.kernel@gmail.com>,
Fernando Fernandez Mancera <fmancera@suse.de>,
Mina Almasry <almasrymina@google.com>,
David Laight <david.laight.linux@gmail.com>,
netdev@vger.kernel.org, xen-devel@lists.xenproject.org
Subject: Re: [PATCH net-next v2 01/15] net: skbuff: make skb_copy_and_csum_bits() report unreadable frags
Date: Thu, 22 Oct 2026 20:07:28 +0000 [thread overview]
Message-ID: <179269964884897.2.9376562849077840876@toxicpanda.com> (raw)
In-Reply-To: <717ace2e-18b2-4df5-848d-5757c01ee5de@redhat.com>
On Thu, Oct 22, 2026 at 10:21:26AM +0200, Paolo Abeni wrote:
> Recently Eric did some work to remove return arguments from the fast-path,
> as with some config it gives measurable overhead. See commit
> a02a765bd5c2ae7705144829b2911c96c29db6ba.
>
> S/W csum should not be the fastest path, but AFAICS the UDP output path
> could use it when building the aggregate segments.
I checked this on x86_64 defconfig (CONFIG_STACKPROTECTOR_STRONG=y,
gcc 13.3), looking at which functions call __stack_chk_fail before and
after patches 1-6.
The callers on the output path don't change. __ip_append_data() and
__ip6_append_data() pass &skb->csum and skb_segment() passes
&SKB_GSO_CB(nskb)->csum, so no local has its address taken. The two
append functions already have a stack protector today, and
skb_segment() doesn't have one before or after.
You're right about the helpers themselves though.
skb_copy_and_csum_bits() and skb_checksum_full() both gain a stack
protector, because of the &csum2 local in the frag_list recursion.
Moving that loop into a noinline function gets rid of it, and only an
skb with a frag_list pays for it:
before v2 frag_list loop split out
skb_copy_and_csum_bits no yes no
skb_checksum / _full no yes no
__ip_append_data yes yes yes
__ip6_append_data yes yes yes
skb_segment no no no
skb_copy_and_csum_bits 774 905 666 bytes
I'll do that in v3.
These gain one and keep it, since they do pass a local:
__skb_checksum_complete(), __skb_checksum_complete_head(),
pskb_trim_rcsum_slow(), skb_copy_and_csum_dev(), icmp_glue_bits(),
icmpv6_getfrag() and xdr_skb_read_bits(). Each of them goes on to
checksum or copy the payload in software. I haven't measured cycles.
bloat-o-meter for patches 1-6 with the split is +1177 bytes in total,
most of it the new error paths.
> I'm wondering using a 64 bit return value and encoding there both the csum
> and the error coudl make sense.
I'd like to keep the int return and the pointer. It's __must_check, so
the compiler catches a caller that ignores the failure, and a packed
value needs every caller to know how to unpack it. 0 or ~0 as the error
doesn't work either, it changes the checksum on the wire for data that
sums to zero:
https://lore.kernel.org/all/179199883858343.2.17884063473154560573@toxicpanda.com/
> Also currently net-next is closed for the merge window, and a bunch of
> changes in this series looks more like cleanup than fixes. Cleanup will have
> to wait for the end of the merge window, fixes can land at any time.
There's no rush on any of it, so I'll resend the whole series when
net-next reopens.
Thanks,
Josef
next prev parent reply other threads:[~2026-10-23 0:43 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-21 13:46 [PATCH net-next v2 00/15] net: skbuff: follow-ups to the BUG_ON() removal Josef Bacik
2026-10-21 13:46 ` [PATCH net-next v2 01/15] net: skbuff: make skb_copy_and_csum_bits() report unreadable frags Josef Bacik
2026-10-21 21:48 ` Fernando Fernandez Mancera
2026-10-22 8:21 ` Paolo Abeni
2026-10-22 9:54 ` David Laight
2026-10-22 20:07 ` Josef Bacik [this message]
2026-10-21 13:46 ` [PATCH net-next v2 02/15] net: skbuff: add skb_checksum_full() that reports failure Josef Bacik
2026-10-21 22:08 ` Fernando Fernandez Mancera
2026-10-21 13:46 ` [PATCH net-next v2 03/15] net: skbuff: fail checksum validation when the skb can't be checksummed Josef Bacik
2026-10-21 22:28 ` Fernando Fernandez Mancera
2026-10-21 13:46 ` [PATCH net-next v2 04/15] net: skbuff: fail segmentation when a segment " Josef Bacik
2026-10-21 22:36 ` Fernando Fernandez Mancera
2026-10-21 13:46 ` [PATCH net-next v2 05/15] net: skbuff: fail pskb_trim_rcsum() when it can't checksum the tail Josef Bacik
2026-10-21 13:46 ` [PATCH net-next v2 06/15] net: skbuff: add skb_crc32c_full() that reports failure Josef Bacik
2026-10-21 13:46 ` [PATCH net-next v2 07/15] net: skbuff: let skb_zerocopy() copy a short skb without head_frag Josef Bacik
2026-10-21 13:46 ` [PATCH net-next v2 08/15] net: skbuff: make skb_try_coalesce()'s len unsigned Josef Bacik
2026-10-21 13:46 ` [PATCH net-next v2 09/15] net: skbuff: check csum_start against len in skb_copy_and_csum_dev() Josef Bacik
2026-10-21 13:46 ` [PATCH net-next v2 10/15] net: skbuff: reject a negative length in skb_copy_and_csum_bits() Josef Bacik
2026-10-21 13:46 ` [PATCH net-next v2 11/15] net: skbuff: refuse to segment a nested frag_list Josef Bacik
2026-10-22 1:47 ` Willem de Bruijn
2026-10-22 19:58 ` Josef Bacik
2026-10-23 3:07 ` Willem de Bruijn
2026-10-21 13:46 ` [PATCH net-next v2 12/15] net: test the frag_list layouts skb_segment() refuses Josef Bacik
2026-10-21 13:46 ` [PATCH net-next v2 13/15] xen-netfront: don't BUG() when skb_copy_bits() fails in bounce_skb() Josef Bacik
2026-10-21 13:46 ` [PATCH net-next v2 14/15] net/tls: don't BUG() on leftover length in __skb_nsg() Josef Bacik
2026-10-21 13:46 ` [PATCH net-next v2 15/15] net: update comments that still describe the skb BUG_ON()s Josef Bacik
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=179269964884897.2.9376562849077840876@toxicpanda.com \
--to=josef@toxicpanda.com \
--cc=almasrymina@google.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=david.laight.linux@gmail.com \
--cc=edumazet@kernel.org \
--cc=fmancera@suse.de \
--cc=horms@kernel.org \
--cc=jgross@suse.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sstabellini@kernel.org \
--cc=willemdebruijn.kernel@gmail.com \
--cc=xen-devel@lists.xenproject.org \
/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