From: Eric Dumazet <hidden> Date: 2021-10-29 15:22:17
Some layers in tx path do not expect skb being empty (skb->len == 0)
syzbot reported a crash [1] in fq_codel.
But I expect many drivers would also crash later.
Sure the immediate fq_codel crash could be 'fixed', but I would rather
add some sanity checks in net/core/filter.c
Thanks.
@@ -203,7 +203,14 @@ static int fq_codel_enqueue(struct sk_buff *skb, struct Qdisc *sch,codel_set_enqueue_time(skb);flow=&q->flows[idx];flow_queue_add(flow,skb);-q->backlogs[idx]+=qdisc_pkt_len(skb);++/* fq_codel_drop() depends on qdisc_pkt_len(skb) being not zero. */+pkt_len=qdisc_pkt_len(skb);+if(unlikely(!pkt_len)){+pkt_len=1;+qdisc_skb_cb(skb)->pkt_len=pkt_len;+}+q->backlogs[idx]+=pkt_len;qdisc_qstats_backlog_inc(sch,skb);if(list_empty(&flow->flowchain)){
@@ -220,8 +227,6 @@ static int fq_codel_enqueue(struct sk_buff *skb, struct Qdisc *sch,prev_backlog=sch->qstats.backlog;prev_qlen=sch->q.qlen;-/* save this packet length as it might be dropped by fq_codel_drop() */-pkt_len=qdisc_pkt_len(skb);/* fq_codel_drop() is quite expensive, as it performs a linear search*inq->backlogs[]tofindafatflow.*Soinsteadofdroppingasinglepacket,drophalfofitsbacklog
From: Daniel Borkmann <daniel@iogearbox.net> Date: 2021-10-29 15:39:56
On 10/29/21 5:22 PM, Eric Dumazet wrote:
Some layers in tx path do not expect skb being empty (skb->len == 0)
syzbot reported a crash [1] in fq_codel.
But I expect many drivers would also crash later.
Sure the immediate fq_codel crash could be 'fixed', but I would rather
add some sanity checks in net/core/filter.c
Makes sense, we shouldn't have to add this to fq_codel fast path, but rather
a sanity check for bpf_clone_redirect().
I wonder if it's only related to bpf_prog_test_run() infra or if it could also
have been generated via stack?
Thanks,
Daniel
@@ -203,7 +203,14 @@ static int fq_codel_enqueue(struct sk_buff *skb, struct Qdisc *sch,codel_set_enqueue_time(skb);flow=&q->flows[idx];flow_queue_add(flow,skb);-q->backlogs[idx]+=qdisc_pkt_len(skb);++/* fq_codel_drop() depends on qdisc_pkt_len(skb) being not zero. */+pkt_len=qdisc_pkt_len(skb);+if(unlikely(!pkt_len)){+pkt_len=1;+qdisc_skb_cb(skb)->pkt_len=pkt_len;+}+q->backlogs[idx]+=pkt_len;qdisc_qstats_backlog_inc(sch,skb);if(list_empty(&flow->flowchain)){
@@ -220,8 +227,6 @@ static int fq_codel_enqueue(struct sk_buff *skb, struct Qdisc *sch,prev_backlog=sch->qstats.backlog;prev_qlen=sch->q.qlen;-/* save this packet length as it might be dropped by fq_codel_drop() */-pkt_len=qdisc_pkt_len(skb);/* fq_codel_drop() is quite expensive, as it performs a linear search*inq->backlogs[]tofindafatflow.*Soinsteadofdroppingasinglepacket,drophalfofitsbacklog
On Fri, Oct 29, 2021 at 8:39 AM Daniel Borkmann [off-list ref] wrote:
On 10/29/21 5:22 PM, Eric Dumazet wrote:
quoted
Some layers in tx path do not expect skb being empty (skb->len == 0)
syzbot reported a crash [1] in fq_codel.
But I expect many drivers would also crash later.
Sure the immediate fq_codel crash could be 'fixed', but I would rather
add some sanity checks in net/core/filter.c
Makes sense, we shouldn't have to add this to fq_codel fast path, but rather
a sanity check for bpf_clone_redirect().
I wonder if it's only related to bpf_prog_test_run() infra or if it could also
have been generated via stack?
probably bpf_prog_test_run_skb only.
I would only add size !=0 check there.
From: Eric Dumazet <hidden> Date: 2021-10-29 15:48:41
On 10/29/21 8:41 AM, Alexei Starovoitov wrote:
On Fri, Oct 29, 2021 at 8:39 AM Daniel Borkmann [off-list ref] wrote:
quoted
On 10/29/21 5:22 PM, Eric Dumazet wrote:
quoted
Some layers in tx path do not expect skb being empty (skb->len == 0)
syzbot reported a crash [1] in fq_codel.
But I expect many drivers would also crash later.
Sure the immediate fq_codel crash could be 'fixed', but I would rather
add some sanity checks in net/core/filter.c
Makes sense, we shouldn't have to add this to fq_codel fast path, but rather
a sanity check for bpf_clone_redirect().
I wonder if it's only related to bpf_prog_test_run() infra or if it could also
have been generated via stack?
probably bpf_prog_test_run_skb only.
I would only add size !=0 check there.
We have a C repro, I will release the syzbot bug so that it can be shared with you.
Thanks.