Re: [syzbot] [net?] general protection fault in qdisc_create

Victor Nogueira
2023-12-31T14:10:28Z

[-- Attachment #1: Type: text/plain, Size: 226 bytes --]

On 31/12/2023 08:04, syzbot wrote:
> HEAD commit: c2b2ee36250d bridge: cfm: fix enum typo in br_cc_ccm_tx_pa..
> git tree: net-next
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=15fed8f6e80000

#syz test

[-- Attachment #2: 0001-net-sched-We-should-only-add-appropriate-qdiscs-bloc.patch --]
[-- Type: text/x-patch, Size: 2109 bytes --]

From e63340707ce85f8608e3c3ae3cec1340ef17eede Mon Sep 17 00:00:00 2001
From: Victor Nogueira <victor@mojatatu.com>
Date: Thu, 28 Dec 2023 13:18:49 +0000
Subject: [PATCH net-next 1/1] net/sched: We should only add appropriate qdiscs
blocks to ports' xarray

We should only add qdiscs to the blocks ports' xarray in ingress that
support ingress_block_set/get or in egress that support
egress_block_set/get.

Fixes: 913b47d3424e ("net/sched: Introduce tc block netdev tracking infra")

Signed-off-by: Victor Nogueira <victor@mojatatu.com>
Reviewed-by: Jamal Hadi Salim <jhs@mojatatu.com>
---
net/sched/sch_api.c | 34 ++++++++++++++++++++--------------
1 file changed, 20 insertions(+), 14 deletions(-)

diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
index 299086bb6205..426be81276f1 100644
--- a/net/sched/sch_api.c
+++ b/net/sched/sch_api.c
@@ -1187,23 +1187,29 @@ static int qdisc_block_add_dev(struct Qdisc *sch, struct net_device *dev,
struct tcf_block *block;
int err;

- block = cl_ops->tcf_block(sch, TC_H_MIN_INGRESS, NULL);
- if (block) {
- err = xa_insert(&block->ports, dev->ifindex, dev, GFP_KERNEL);
- if (err) {
- NL_SET_ERR_MSG(extack,
- "ingress block dev insert failed");
- return err;
+ if (sch->ops->ingress_block_get) {
+ block = cl_ops->tcf_block(sch, TC_H_MIN_INGRESS, NULL);
+ if (block) {
+ err = xa_insert(&block->ports, dev->ifindex, dev,
+ GFP_KERNEL);
+ if (err) {
+ NL_SET_ERR_MSG(extack,
+ "ingress block dev insert failed");
+ return err;
+ }
}
}

- block = cl_ops->tcf_block(sch, TC_H_MIN_EGRESS, NULL);
- if (block) {
- err = xa_insert(&block->ports, dev->ifindex, dev, GFP_KERNEL);
- if (err) {
- NL_SET_ERR_MSG(extack,
- "Egress block dev insert failed");
- goto err_out;
+ if (sch->ops->egress_block_get) {
+ block = cl_ops->tcf_block(sch, TC_H_MIN_EGRESS, NULL);
+ if (block) {
+ err = xa_insert(&block->ports, dev->ifindex, dev,
+ GFP_KERNEL);
+ if (err) {
+ NL_SET_ERR_MSG(extack,
+ "Egress block dev insert failed");
+ goto err_out;
+ }
}
}

--
2.25.1