BPF List
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Kuniyuki Iwashima <kuniyu@amazon.com>, xiyou.wangcong@gmail.com
Cc: bpf@vger.kernel.org, cong.wang@bytedance.com, fw@strlen.de,
	netdev@vger.kernel.org,
	syzbot+0c4150bff9fff3bf023c@syzkaller.appspotmail.com
Subject: Re: [Patch net] net: remove the bogus overflow debug check in pskb_may_pull()
Date: Sat, 8 Jun 2024 10:01:32 +0200	[thread overview]
Message-ID: <9f254c96-54f2-4457-b7ab-1d9f6187939c@gmail.com> (raw)
In-Reply-To: <20240607213229.97602-1-kuniyu@amazon.com>


On 6/7/24 23:32, Kuniyuki Iwashima wrote:
> From: Cong Wang <xiyou.wangcong@gmail.com>
> Date: Fri, 7 Jun 2024 09:14:04 -0700
>> On Fri, Jun 07, 2024 at 01:27:47AM +0200, Florian Westphal wrote:
>>> Cong Wang <xiyou.wangcong@gmail.com> wrote:
>>>> From: Cong Wang <cong.wang@bytedance.com>
>>>>
>>>> Commit 219eee9c0d16 ("net: skbuff: add overflow debug check to pull/push
>>>> helpers") introduced an overflow debug check for pull/push helpers.
>>>> For __skb_pull() this makes sense because its callers rarely check its
>>>> return value. But for pskb_may_pull() it does not make sense, since its
>>>> return value is properly taken care of. Remove the one in
>>>> pskb_may_pull(), we can continue rely on its return value.
>>> See 025f8ad20f2e3264d11683aa9cbbf0083eefbdcd which would not exist
>>> without this check, I would not give up yet.
>> What's the point of that commit?
> 4b911a9690d7 would be better example.  The warning actually found a
> bug in NSH GSO.
>
> Here's splats triggered by syzkaller using NSH over various tunnels.
> https://lore.kernel.org/netdev/20240415222041.18537-2-kuniyu@amazon.com/


Right. We discussed this before. I guess I forgot to send the fix.

Florian could you submit the suggestion I made before ?

diff --git a/net/core/filter.c b/net/core/filter.c
index 
358870408a51e61f3cbc552736806e4dfee1ec39..da7aae6fd8ba557c66699d1cfebd47f18f442aa2 
100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -1662,6 +1662,11 @@ static DEFINE_PER_CPU(struct bpf_scratchpad, bpf_sp);
  static inline int __bpf_try_make_writable(struct sk_buff *skb,
                        unsigned int write_len)
  {
+#if defined(CONFIG_DEBUG_NET)
+    /* Avoid a splat in pskb_may_pull_reason() */
+    if (write_len > INT_MAX)
+        return -EINVAL;
+#endif
      return skb_ensure_writable(skb, write_len);
  }



  reply	other threads:[~2024-06-08  8:01 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-06 22:15 [Patch net] net: remove the bogus overflow debug check in pskb_may_pull() Cong Wang
2024-06-06 23:27 ` Florian Westphal
2024-06-07 16:14   ` Cong Wang
2024-06-07 21:32     ` Kuniyuki Iwashima
2024-06-08  8:01       ` Eric Dumazet [this message]
2024-06-08 22:24         ` Florian Westphal
2024-06-09  2:01         ` Jason Xing
2024-06-14 10:17         ` [PATCH bpf] bpf: avoid splat in pskb_pull_reason Florian Westphal
2024-06-14 12:11           ` Eric Dumazet
2024-06-14 15:30           ` patchwork-bot+netdevbpf

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=9f254c96-54f2-4457-b7ab-1d9f6187939c@gmail.com \
    --to=eric.dumazet@gmail.com \
    --cc=bpf@vger.kernel.org \
    --cc=cong.wang@bytedance.com \
    --cc=fw@strlen.de \
    --cc=kuniyu@amazon.com \
    --cc=netdev@vger.kernel.org \
    --cc=syzbot+0c4150bff9fff3bf023c@syzkaller.appspotmail.com \
    --cc=xiyou.wangcong@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