From: Di Zhu <zhudi2@huawei.com>
To: <ast@kernel.org>, <edumazet@google.com>, <daniel@iogearbox.net>,
<andrii@kernel.org>, <yhs@fb.com>, <davem@davemloft.net>
Cc: <netdev@vger.kernel.org>, <bpf@vger.kernel.org>,
<zhudi2@huawei.com>, <rose.chen@huawei.com>,
<syzbot+7a12909485b94426aceb@syzkaller.appspotmail.com>
Subject: [PATCH] bpf: Don't redirect packets with pkt_len 0
Date: Fri, 17 Jun 2022 15:18:55 +0800 [thread overview]
Message-ID: <20220617071855.2482-1-zhudi2@huawei.com> (raw)
Syzbot found an issue [1]: fq_codel_drop() try to drop a flow whitout any
skbs, that is, the flow->head is null.
The root cause, as the [2] says, is because that bpf_prog_test_run_skb()
run a bpf prog which redirects empty skbs.
So we should determine whether the length of the packet modified by bpf
prog or others like bpf_prog_test is 0 before forwarding it directly.
LINK: [1] https://syzkaller.appspot.com/bug?id=0b84da80c2917757915afa89f7738a9d16ec96c5
LINK: [2] https://www.spinics.net/lists/netdev/msg777503.html
Reported-by: syzbot+7a12909485b94426aceb@syzkaller.appspotmail.com
Signed-off-by: Di Zhu <zhudi2@huawei.com>
---
net/core/filter.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/net/core/filter.c b/net/core/filter.c
index 5af58eb48587..c7fbfa90898a 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -2156,6 +2156,9 @@ static int __bpf_redirect_common(struct sk_buff *skb, struct net_device *dev,
static int __bpf_redirect(struct sk_buff *skb, struct net_device *dev,
u32 flags)
{
+ if (unlikely(skb->len == 0))
+ return -EINVAL;
+
if (dev_is_mac_header_xmit(dev))
return __bpf_redirect_common(skb, dev, flags);
else
--
2.27.0
next reply other threads:[~2022-06-17 7:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-17 7:18 Di Zhu [this message]
2022-06-17 8:10 ` [PATCH] bpf: Don't redirect packets with pkt_len 0 Eric Dumazet
2022-06-18 10:16 zhudi (E)
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=20220617071855.2482-1-zhudi2@huawei.com \
--to=zhudi2@huawei.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=netdev@vger.kernel.org \
--cc=rose.chen@huawei.com \
--cc=syzbot+7a12909485b94426aceb@syzkaller.appspotmail.com \
--cc=yhs@fb.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;
as well as URLs for NNTP newsgroup(s).