From: Hyunwoo Kim <imv4bel@gmail.com>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: steffen.klassert@secunet.com, davem@davemloft.net,
dsahern@kernel.org, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, horms@kernel.org, ilant@mellanox.com,
sowmini.varadhan@oracle.com, netdev@vger.kernel.org,
imv4bel@gmail.com
Subject: Re: [PATCH ipsec] esp: Force skb_cow_data() on RX when the skb is non-linear
Date: Thu, 30 Apr 2026 16:16:15 +0900 [thread overview]
Message-ID: <afMBv4M-iyd8Z-g2@v4bel> (raw)
In-Reply-To: <afLZ6Fl6b2ChTnus@gondor.apana.org.au>
On Thu, Apr 30, 2026 at 12:26:16PM +0800, Herbert Xu wrote:
> On Thu, Apr 30, 2026 at 11:49:13AM +0900, Hyunwoo Kim wrote:
> > esp_input() and esp6_input() skip skb_cow_data() on uncloned skbs
> > through two arms: one for fully linear skbs (nfrags = 1) and one for
> > skbs carrying paged fragments without a frag_list, which sets
> > nfrags = skb_shinfo(skb)->nr_frags + 1. In both arms the skb is mapped
> > into a scatterlist via skb_to_sgvec() and passed as both src and dst of
> > aead_request_set_crypt(), so the AEAD operates in place over the
> > existing frag pages.
> >
> > Drop the paged-fragment arm so any non-linear inbound skb falls through
> > to skb_cow_data(). The fully linear fast path is unchanged and the
> > existing skb_cow_data() error handling that follows the gate is reused.
> >
> > Fixes: cac2661c53f3 ("esp4: Avoid skb_cow_data whenever possible")
> > Fixes: 03e2a30f6a27 ("esp6: Avoid skb_cow_data whenever possible")
> > Signed-off-by: Hyunwoo Kim <imv4bel@gmail.com>
> > ---
> > net/ipv4/esp4.c | 13 +++----------
> > net/ipv6/esp6.c | 13 +++----------
> > 2 files changed, 6 insertions(+), 20 deletions(-)
>
> Good catch!
>
> When a packet comes from a device driver, it's usually safe to
> write to the fragments since they would have been allocated by
> the driver.
>
> But when a packet originates from our own stack, then it's not
> safe to write to the fragments.
>
> Unfortunately the two paths cross with the loopback driver (and
> probably other means of creating loopback).
>
> Acked-by: Herbert Xu <herbert@gondor.apana.org.au>
Thank you for the review.
If it's not too much trouble, I would be grateful if you could also
take a look at this rxrpc patch, which addresses a similar bug:
https://lore.kernel.org/all/afKV2zGR6rrelPC7@v4bel/
Best regards,
Hyunwoo Kim
>
> Thanks,
> --
> Email: Herbert Xu <herbert@gondor.apana.org.au>
> Home Page: http://gondor.apana.org.au/~herbert/
> PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
next prev parent reply other threads:[~2026-04-30 7:16 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-30 2:49 [PATCH ipsec] esp: Force skb_cow_data() on RX when the skb is non-linear Hyunwoo Kim
2026-04-30 4:26 ` Herbert Xu
2026-04-30 7:16 ` Hyunwoo Kim [this message]
2026-05-01 16:09 ` Simon Horman
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=afMBv4M-iyd8Z-g2@v4bel \
--to=imv4bel@gmail.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=herbert@gondor.apana.org.au \
--cc=horms@kernel.org \
--cc=ilant@mellanox.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sowmini.varadhan@oracle.com \
--cc=steffen.klassert@secunet.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 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.