Netdev List
 help / color / mirror / Atom feed
From: Steffen Klassert <steffen.klassert@secunet.com>
To: Roshan Kumar <roshaen09@gmail.com>
Cc: Jakub Kicinski <kuba@kernel.org>, <davem@davemloft.net>,
	<herbert@gondor.apana.org.au>, <netdev@vger.kernel.org>,
	Christian Hopps <chopps@labn.net>
Subject: Re: [PATCH 01/12] xfrm: iptfs: fix stack OOB read in iptfs_skb_reset_frag_walk()
Date: Wed, 16 Sep 2026 11:02:32 +0200	[thread overview]
Message-ID: <aqpbKKiNcQFemUk0@secunet.com> (raw)
In-Reply-To: <178946111414.531190.8806329997967238720@mail.gmail.com>

On Tue, Sep 15, 2026 at 08:31:54AM -0000, Roshan Kumar wrote:
> Hi Steffen,
> 
> I had a look at the review and it is right that the guard changes the
> len == 0 outcome, with one nuance worth splitting out.
> 
> The sharing branch needs a prepared frag walk, so the guard can only
> change behavior for skbs that are frag walk eligible (head_frag set, or
> all data in frags). For those, before the change
> iptfs_skb_can_add_frags() fell through the "while (len && fragi <
> walk->nr_frags)" loop and returned true, iptfs_skb_add_frags()
> returned immediately on its own " !walk->nr_frags || offset out of
> range" check, and reassembly continued with ra_wantseq++. With the
> guard the same input returns false, takes the copy branch, and
> skb_copy_seq_read(..., 0) returns EINVAL, so the in progress
> reassembly is dropped.
> 
> For linear skbs the frag walk stays NULL and this corner dropped
> reassembly before the change too: the copy branch runs either way and
> skb_seq_read at the end of the buffer fails the same way. I reproduced
> that part live on v7.3-rc3 today: a partial inner packet followed by
> an AGGFRAG basic header only block with block_offset 0xffff kills the
> in progress reassembly with and without the fix, so that part already
> existed rather than being something the guard introduces.
> 
> The review's suggestion closes the gap for the frag walk case: return
> true when len == 0, before the offset check. The dangerous walk in
> iptfs_skb_reset_frag_walk() is skipped entirely for len == 0, and
> iptfs_skb_add_frags() keeps its own bounds check for len > 0, so the
> out of bounds read cannot come back this way. The reassembly outcome
> stays identical to before the fix for head frag skbs, so there is no
> efficiency cost either.
> 
> Something like this on top of the patch:
> 
> diff --git a/net/xfrm/xfrm_iptfs.c b/net/xfrm/xfrm_iptfs.c
> --- a/net/xfrm/xfrm_iptfs.c
> +++ b/net/xfrm/xfrm_iptfs.c
> @@ static bool iptfs_skb_can_add_frags(const struct sk_buff *skb,
>         if (skb_has_frag_list(skb) || skb->pp_recycle != walk->pp_recycle)
>                 return false;
> 
> +       /* len == 0: nothing to add, proceed as before the fix. */
> +       if (!len)
> +               return true;

That's ok with me. But drop the comment above, this does not
give any usefull information.

> +
>         /* Reject an @offset that is at or beyond the end of the walk's data
>          * before calling iptfs_skb_reset_frag_walk(), whose fragment-advance
>          * loop is otherwise unbounded and would index past walk->frags[].
>          * This mirrors the guard already present in iptfs_skb_add_frags().
>          */
>         if (!walk->nr_frags || offset >= walk->total + walk->initial_offset)
>                 return false;
> 
> The len == 0 drop for linear skbs existed before this change; I am
> happy to look at that separately once this series lands.

Thanks!


  reply	other threads:[~2026-09-16  9:02 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-07  9:29 [PATCH 0/12] pull request (net): ipsec 2026-09-07 Steffen Klassert
2026-09-07  9:29 ` [PATCH 01/12] xfrm: iptfs: fix stack OOB read in iptfs_skb_reset_frag_walk() Steffen Klassert
2026-09-08 22:48   ` Jakub Kicinski
2026-09-14 10:37     ` Steffen Klassert
2026-09-15  8:31       ` Roshan Kumar
2026-09-16  9:02         ` Steffen Klassert [this message]
2026-09-07  9:29 ` [PATCH 02/12] xfrm: serialize state GC with device state flush Steffen Klassert
2026-09-08 22:48   ` Jakub Kicinski
2026-09-14 11:23     ` Steffen Klassert
2026-09-14 12:14       ` Chengfeng Ye
2026-09-07  9:29 ` [PATCH 03/12] xfrm: add missing RCU read lock in xfrm_send_migrate_state() Steffen Klassert
2026-09-07  9:29 ` [PATCH 04/12] xfrm: iptfs: fix runt reassembly panic from short inner tot_len Steffen Klassert
2026-09-08 22:48   ` Jakub Kicinski
2026-09-14  9:19     ` Steffen Klassert
2026-09-07  9:29 ` [PATCH 05/12] ipv6: xfrm: use full sockets in local error paths Steffen Klassert
2026-09-08 22:48   ` Jakub Kicinski
2026-09-14  9:25     ` Steffen Klassert
2026-09-07  9:29 ` [PATCH 06/12] xfrm: fix compat ALLOCSPI request use-after-free Steffen Klassert
2026-09-07  9:29 ` [PATCH 07/12] xfrm: add missing rcu_read_lock(), skb_dst_force() and dev_hold() for xfrm_trans_reinject() Steffen Klassert
2026-09-08 22:48   ` Jakub Kicinski
2026-09-14 11:30     ` Steffen Klassert
2026-09-07  9:29 ` [PATCH 08/12] xfrm: use hlist_del_init_rcu for state_cache and state_cache_input Steffen Klassert
2026-09-08 22:48   ` Jakub Kicinski
2026-09-07  9:29 ` [PATCH 09/12] esp: downgrade zerocopy managed frags before mutating skb frags Steffen Klassert
2026-09-08 22:49   ` Jakub Kicinski
2026-09-14  9:55     ` Steffen Klassert
2026-09-07  9:29 ` [PATCH 10/12] xfrm: hold net_device reference under RCU in bundle creation Steffen Klassert
2026-09-08 22:49   ` Jakub Kicinski
2026-09-14  9:57     ` Steffen Klassert
2026-09-07  9:29 ` [PATCH 11/12] xfrm: save input state data before secpath resets Steffen Klassert
2026-09-07  9:29 ` [PATCH 12/12] net: xfrm: reject unrepresentable espintcp transport headers Steffen Klassert
2026-09-08 22:49   ` Jakub Kicinski
2026-09-14 10:22     ` Steffen Klassert
2026-09-19  2:30       ` Wyatt Feng
2026-09-09  6:38 ` Some clarifications on the upstreaming process (was: [PATCH 0/12] pull request (net): ipsec 2026-09-07) Steffen Klassert
2026-09-09  9:23   ` Some clarifications on the upstreaming process Paolo Abeni
2026-09-09 10:22     ` Matthieu Baerts
2026-09-10  8:17       ` Steffen Klassert
2026-09-10  8:35         ` Matthieu Baerts
2026-09-10  9:28           ` Steffen Klassert
2026-09-09 10:23     ` Steffen Klassert
2026-09-09 10:34       ` Paolo Abeni
2026-09-09 10:44         ` Steffen Klassert
2026-09-09 18:57           ` Jakub Kicinski
2026-09-10  8:29             ` Matthieu Baerts
2026-09-10  9:02             ` Steffen Klassert
2026-09-14 11:34             ` Steffen Klassert
2026-09-16 10:05               ` Steffen Klassert

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=aqpbKKiNcQFemUk0@secunet.com \
    --to=steffen.klassert@secunet.com \
    --cc=chopps@labn.net \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=roshaen09@gmail.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