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<xuyang2018.jy@fujitsu.com> 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 27. tst_test.sh 28 29setup() 30{ 31 ROD modprobe $TST_NEEDS_DRIVERS 32} 33 34do_test() 35{ 36 tst_res TINFO "Use tc qdisc command to trigger a null-pointer dereference" 37 38 EXPECT_FAIL tc qdisc add dev teql0 root teql0 39 40 if dmesg | grep -q 'RIP:.*sch_teql'; then 41 tst_res TFAIL "This bug is reproduced." 42 else 43 tst_res TPASS "This bug is not reproduced." 44 fi 45} 46 47tst_run 48