xref: /aosp_15_r20/external/ltp/testcases/network/tcp_cmds/tc/tc01.sh (revision 49cdfc7efb34551c7342be41a7384b9c40d7cab7)
1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0-or-later
3# Copyright (c) 2021 FUJITSU LIMITED. All rights reserved.
4# Author: Yang Xu<[email protected]>
5#
6# When using "tc qdisc add dev teql0 root teql0 command", qdisc_create()
7# calls teql_qdisc_init() it imediately fails after check "if (m->dev == dev)"
8# because both devices are teql0, and it does not set qdisc_priv(sch)->m
9# leaving it zero on error path, then qdisc_create() imediately calls
10# teql_destroy() which does not expect zero master pointer and we get OOPS
11# on unpatched kernel.
12#
13# If we enable panic_on_oops, this case may crash.
14#
15# This kernel bug was introduced by
16# commit 87b60cfacf9f ("net_sched: fix error recovery at qdisc creation")
17# and has been fixed by
18# commit 1ffbc7ea9160 ("net: sched: sch_teql: fix null-pointer dereference")
19#
20
21TST_SETUP="setup"
22TST_TESTFUNC="do_test"
23TST_NEEDS_ROOT=1
24TST_NEEDS_DRIVERS="sch_teql"
25TST_NEEDS_CMDS="tc modprobe dmesg grep"
26
27setup()
28{
29	ROD modprobe $TST_NEEDS_DRIVERS
30}
31
32do_test()
33{
34	tst_res TINFO "Use tc qdisc command to trigger a null-pointer dereference"
35
36	EXPECT_FAIL tc qdisc add dev teql0 root teql0
37
38	if dmesg | grep -q 'RIP:.*sch_teql'; then
39		tst_res TFAIL "This bug is reproduced."
40	else
41		tst_res TPASS "This bug is not reproduced."
42	fi
43}
44
45. tst_test.sh
46tst_run
47