android_kernel_xiaomi_sm7250/net/sched
Zhengchao Shao 86aa139089 net: sched: cake: fix null pointer access issue when cake_init() fails
[ Upstream commit 51f9a8921ceacd7bf0d3f47fa867a64988ba1dcb ]

When the default qdisc is cake, if the qdisc of dev_queue fails to be
inited during mqprio_init(), cake_reset() is invoked to clear
resources. In this case, the tins is NULL, and it will cause gpf issue.

The process is as follows:
qdisc_create_dflt()
	cake_init()
		q->tins = kvcalloc(...)        --->failed, q->tins is NULL
	...
	qdisc_put()
		...
		cake_reset()
			...
			cake_dequeue_one()
				b = &q->tins[...]   --->q->tins is NULL

The following is the Call Trace information:
general protection fault, probably for non-canonical address
0xdffffc0000000000: 0000 [#1] PREEMPT SMP KASAN
KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007]
RIP: 0010:cake_dequeue_one+0xc9/0x3c0
Call Trace:
<TASK>
cake_reset+0xb1/0x140
qdisc_reset+0xed/0x6f0
qdisc_destroy+0x82/0x4c0
qdisc_put+0x9e/0xb0
qdisc_create_dflt+0x2c3/0x4a0
mqprio_init+0xa71/0x1760
qdisc_create+0x3eb/0x1000
tc_modify_qdisc+0x408/0x1720
rtnetlink_rcv_msg+0x38e/0xac0
netlink_rcv_skb+0x12d/0x3a0
netlink_unicast+0x4a2/0x740
netlink_sendmsg+0x826/0xcc0
sock_sendmsg+0xc5/0x100
____sys_sendmsg+0x583/0x690
___sys_sendmsg+0xe8/0x160
__sys_sendmsg+0xbf/0x160
do_syscall_64+0x35/0x80
entry_SYSCALL_64_after_hwframe+0x46/0xb0
RIP: 0033:0x7f89e5122d04
</TASK>

Fixes: 046f6fd5da ("sched: Add Common Applications Kept Enhanced (cake) qdisc")
Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
Acked-by: Toke Høiland-Jørgensen <toke@toke.dk>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-11-03 23:52:26 +09:00
..
act_api.c net: sched: limit TC_ACT_REPEAT loops 2022-02-23 11:58:41 +01:00
act_bpf.c
act_connmark.c
act_csum.c
act_gact.c
act_ife.c
act_ipt.c
act_meta_mark.c
act_meta_skbprio.c
act_meta_skbtcindex.c
act_mirred.c
act_nat.c
act_pedit.c net/sched: act_pedit: sanitize shift argument before usage 2022-05-25 09:10:39 +02:00
act_police.c
act_sample.c
act_simple.c
act_skbedit.c
act_skbmod.c
act_tunnel_key.c
act_vlan.c
cls_api.c net_sched: fix a crash in tc_new_tfilter() 2021-12-14 10:18:10 +01:00
cls_basic.c
cls_bpf.c
cls_cgroup.c
cls_flow.c
cls_flower.c net/sched: flower: fix parsing of ethertype following VLAN header 2022-04-20 09:12:48 +02:00
cls_fw.c
cls_matchall.c
cls_route.c net_sched: cls_route: disallow handle of 0 2022-08-25 11:15:33 +02:00
cls_rsvp6.c
cls_rsvp.c
cls_rsvp.h
cls_tcindex.c
cls_u32.c net/sched: cls_u32: fix netns refcount changes in u32_change() 2022-05-01 17:00:35 +02:00
em_canid.c
em_cmp.c
em_ipset.c
em_ipt.c
em_meta.c
em_nbyte.c
em_text.c
em_u32.c
ematch.c
Kconfig
Makefile
sch_api.c net: sched: Clarify error message when qdisc kind is unknown 2022-02-16 12:51:44 +01:00
sch_atm.c net: sched: rename qdisc_destroy() to qdisc_put() 2021-12-14 10:18:04 +01:00
sch_blackhole.c
sch_cake.c net: sched: cake: fix null pointer access issue when cake_init() fails 2022-11-03 23:52:26 +09:00
sch_cbq.c net: sched: rename qdisc_destroy() to qdisc_put() 2021-12-14 10:18:04 +01:00
sch_cbs.c net: sched: rename qdisc_destroy() to qdisc_put() 2021-12-14 10:18:04 +01:00
sch_choke.c
sch_codel.c
sch_drr.c net: sched: rename qdisc_destroy() to qdisc_put() 2021-12-14 10:18:04 +01:00
sch_dsmark.c net: sched: rename qdisc_destroy() to qdisc_put() 2021-12-14 10:18:04 +01:00
sch_etf.c
sch_fifo.c net: sched: rename qdisc_destroy() to qdisc_put() 2021-12-14 10:18:04 +01:00
sch_fq_codel.c
sch_fq.c
sch_generic.c net: Fix data-races around weight_p and dev_weight_[rt]x_bias. 2022-09-05 10:26:30 +02:00
sch_gred.c
sch_hfsc.c net: sched: rename qdisc_destroy() to qdisc_put() 2021-12-14 10:18:04 +01:00
sch_hhf.c
sch_htb.c net: sched: rename qdisc_destroy() to qdisc_put() 2021-12-14 10:18:04 +01:00
sch_ingress.c
sch_mq.c net: sched: rename qdisc_destroy() to qdisc_put() 2021-12-14 10:18:04 +01:00
sch_mqprio.c net: sched: rename qdisc_destroy() to qdisc_put() 2021-12-14 10:18:04 +01:00
sch_multiq.c net: sched: rename qdisc_destroy() to qdisc_put() 2021-12-14 10:18:04 +01:00
sch_netem.c net/sched: sch_netem: Fix arithmetic in netem_dump() for 32-bit platforms 2022-07-02 16:27:32 +02:00
sch_pie.c
sch_plug.c
sch_prio.c net: sched: rename qdisc_destroy() to qdisc_put() 2021-12-14 10:18:04 +01:00
sch_qfq.c sch_qfq: prevent shift-out-of-bounds in qfq_init_qdisc 2022-01-11 13:58:49 +01:00
sch_red.c net: sched: rename qdisc_destroy() to qdisc_put() 2021-12-14 10:18:04 +01:00
sch_sfb.c sch_sfb: Also store skb len before calling child enqueue 2022-09-15 12:17:06 +02:00
sch_sfq.c
sch_skbprio.c
sch_tbf.c net: sched: rename qdisc_destroy() to qdisc_put() 2021-12-14 10:18:04 +01:00
sch_teql.c