From: Fred Li <dracodingfly@gmail.com>
To: willemdebruijn.kernel@gmail.com
Cc: andrii@kernel.org, ast@kernel.org, bpf@vger.kernel.org,
daniel@iogearbox.net, dracodingfly@gmail.com,
herbert@gondor.apana.org.au, john.fastabend@gmail.com,
kpsingh@kernel.org, linux-kernel@vger.kernel.org,
netdev@vger.kernel.org, pabeni@redhat.com, song@kernel.org,
yonghong.song@linux.dev
Subject: Re: [PATCH v3] net: linearizing skb when downgrade gso_size
Date: Thu, 18 Jul 2024 15:42:56 +0800 [thread overview]
Message-ID: <20240718074256.65274-1-dracodingfly@gmail.com> (raw)
In-Reply-To: <6697f20876b11_34277329417@willemb.c.googlers.com.notmuch>
>
> > Linearizing skb when downgrade gso_size because it may
> > trigger the BUG_ON when segment skb as described in [1].
> >
> > v3 changes:
> > linearize skb if having frag_list as Willem de Bruijn suggested[2].
> >
> > [1] https://lore.kernel.org/all/20240626065555.35460-2-dracodingfly@gmail.com/
> > [2] https://lore.kernel.org/all/668d5cf1ec330_1c18c32947@willemb.c.googlers.com.notmuch/
> >
> > Signed-off-by: Fred Li <dracodingfly@gmail.com>
>
> A fix needs a Fixed tag.
>
> This might be the original commit that introduced gso_size adjustment,
> commit 6578171a7ff0c ("bpf: add bpf_skb_change_proto helper")
>
Yes, this is the original commit, but it's already fixed by commit
364745fbe981a (bpf: Do not change gso_size during bpf_skb_change_proto())
Another commit 2be7e212d5419 (bpf: add bpf_skb_adjust_room helper) introduced
gso_size too.
> Unless support for frag_list came later.
>
> > ---
> > net/core/filter.c | 16 ++++++++++++----
> > 1 file changed, 12 insertions(+), 4 deletions(-)
> >
> > diff --git a/net/core/filter.c b/net/core/filter.c
> > index df4578219e82..70919b532d68 100644
> > --- a/net/core/filter.c
> > +++ b/net/core/filter.c
> > @@ -3525,13 +3525,21 @@ static int bpf_skb_net_grow(struct sk_buff *skb, u32 off, u32 len_diff,
> > if (skb_is_gso(skb)) {
> > struct skb_shared_info *shinfo = skb_shinfo(skb);
> >
> > - /* Due to header grow, MSS needs to be downgraded. */
> > - if (!(flags & BPF_F_ADJ_ROOM_FIXED_GSO))
> > - skb_decrease_gso_size(shinfo, len_diff);
> > -
> > /* Header must be checked, and gso_segs recomputed. */
> > shinfo->gso_type |= gso_type;
> > shinfo->gso_segs = 0;
> > +
> > + /* Due to header grow, MSS needs to be downgraded.
> > + * There is BUG_ON When segment the frag_list with
> > + * head_frag true so linearize skb after downgrade
> > + * the MSS.
> > + */
>
> Super tiny nit: no capitalization of When in the middle of a sentence.
Thanks, i'will fix.
>
> > + if (!(flags & BPF_F_ADJ_ROOM_FIXED_GSO)) {
> > + skb_decrease_gso_size(shinfo, len_diff);
> > + if (shinfo->frag_list)
> > + return skb_linearize(skb);
>
> I previously asked whether it was safe to call pskb_expand_head from
> within a BPF external function. There are actually plenty of existing
> examples of this, so this is fine.
>
> > + }
> > +
> > }
> >
> > return 0;
> > --
> > 2.33.0
> >
next prev parent reply other threads:[~2024-07-18 7:43 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-26 6:55 [PATCH v2 2/2] test_bpf: Introduce an skb_segment test for frag_list whose head_frag=true and gso_size was mangled Fred Li
2024-06-26 6:55 ` [PATCH v2 1/2] net: Fix skb_segment when splitting gso_size mangled skb having linear-headed frag_list whose head_frag=true Fred Li
2024-07-02 9:23 ` Paolo Abeni
2024-07-03 12:21 ` Fred Li
2024-07-06 14:26 ` Willem de Bruijn
2024-07-08 14:31 ` [PATCH] net: linearizing skb when downgrade gso_size Fred Li
2024-07-09 15:53 ` Willem de Bruijn
2024-07-09 20:16 ` Herbert Xu
2024-07-09 21:29 ` Willem de Bruijn
2024-07-10 23:06 ` Herbert Xu
2024-07-12 8:17 ` Fred Li
2024-07-17 5:35 ` [PATCH v3] " Fred Li
2024-07-17 16:32 ` Willem de Bruijn
2024-07-18 7:42 ` Fred Li [this message]
2024-07-19 2:46 ` [PATCH v4] bpf: Fixed a segment issue " Fred Li
2024-07-19 18:22 ` Willem de Bruijn
2024-07-22 3:08 ` [PATCH bpf v5] bpf: Fixed " Fred Li
2024-07-22 16:29 ` Willem de Bruijn
2024-07-24 13:37 ` Fred Li
2024-07-25 10:09 ` Daniel Borkmann
2024-06-26 6:55 ` [PATCH v2 0/2] net: Fix BUG_ON for segment frag_list with mangled gso_size and head_frag is true Fred Li
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=20240718074256.65274-1-dracodingfly@gmail.com \
--to=dracodingfly@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=herbert@gondor.apana.org.au \
--cc=john.fastabend@gmail.com \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=song@kernel.org \
--cc=willemdebruijn.kernel@gmail.com \
--cc=yonghong.song@linux.dev \
/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