[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKH8qBtxJOCWoON6QXygOTD7AqjF+k=-4JWPHXEAQh-TO+W54A@mail.gmail.com>
Date: Thu, 14 Jul 2022 11:22:20 -0700
From: Stanislav Fomichev <sdf@...gle.com>
To: Zhengchao Shao <shaozhengchao@...wei.com>
Cc: bpf@...r.kernel.org, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org, davem@...emloft.net,
edumazet@...gle.com, kuba@...nel.org, pabeni@...hat.com,
hawk@...nel.org, ast@...nel.org, daniel@...earbox.net,
andrii@...nel.org, martin.lau@...ux.dev, song@...nel.org,
yhs@...com, john.fastabend@...il.com, kpsingh@...nel.org,
weiyongjun1@...wei.com, yuehaibing@...wei.com
Subject: Re: [PATCH v2,bpf-next] bpf: Don't redirect packets with invalid pkt_len
On Wed, Jul 13, 2022 at 11:05 PM Zhengchao Shao
<shaozhengchao@...wei.com> wrote:
>
> 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 is valid 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@...kaller.appspotmail.com
> Signed-off-by: Zhengchao Shao <shaozhengchao@...wei.com>
Reviewed-by: Stanislav Fomichev <sdf@...gle.com>
Daniel, do you see any issues with this approach?
I wonder if we might also want to add some WARN_ON to the
__bpf_redirect_common routine gated by #ifdef CONFIG_DEBUG_NET ?
In case syscaller manages to hit similar issues elsewhere..
> ---
> v1: should not check len in fast path
>
> net/bpf/test_run.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c
> index 2ca96acbc50a..750d7d173a20 100644
> --- a/net/bpf/test_run.c
> +++ b/net/bpf/test_run.c
> @@ -1152,6 +1152,12 @@ int bpf_prog_test_run_skb(struct bpf_prog *prog, const union bpf_attr *kattr,
> ret = convert___skb_to_skb(skb, ctx);
> if (ret)
> goto out;
> +
> + if (skb->len == 0) {
> + ret = -EINVAL;
> + goto out;
> + }
> +
> ret = bpf_test_run(prog, skb, repeat, &retval, &duration, false);
> if (ret)
> goto out;
> --
> 2.17.1
>
Powered by blists - more mailing lists