[LTP] [PATCH v4 1/2] network/tc01.sh: Add a regression test for tc qdisc command

xuyang2018.jy@fujitsu.com xuyang2018.jy@fujitsu.com
Mon Jul 19 07:45:34 CEST 2021


Hi Alexey

Thanks for your review, I have merged this patch.

Best Regards
Yang Xu

> Reviewed-by: Alexey Kodanev<aleksei.kodanev@bell-sw.com>
> Signed-off-by: Yang Xu<xuyang2018.jy@fujitsu.com>
> ---
>   runtest/net.tcp_cmds                   |  1 +
>   testcases/network/tcp_cmds/tc/Makefile | 10 ++++++
>   testcases/network/tcp_cmds/tc/tc01.sh  | 47 ++++++++++++++++++++++++++
>   3 files changed, 58 insertions(+)
>   create mode 100644 testcases/network/tcp_cmds/tc/Makefile
>   create mode 100755 testcases/network/tcp_cmds/tc/tc01.sh
> 
> diff --git a/runtest/net.tcp_cmds b/runtest/net.tcp_cmds
> index db47dfd5b..7e142de11 100644
> --- a/runtest/net.tcp_cmds
> +++ b/runtest/net.tcp_cmds
> @@ -12,6 +12,7 @@ netstat netstat01.sh
>   ping01 ping01.sh
>   ping02 ping02.sh
>   sendfile sendfile01.sh
> +tc01 tc01.sh
>   tcpdump tcpdump01.sh
>   telnet telnet01.sh
>   iptables iptables01.sh
> diff --git a/testcases/network/tcp_cmds/tc/Makefile b/testcases/network/tcp_cmds/tc/Makefile
> new file mode 100644
> index 000000000..b4d8b86ee
> --- /dev/null
> +++ b/testcases/network/tcp_cmds/tc/Makefile
> @@ -0,0 +1,10 @@
> +# SPDX-License-Identifier: GPL-2.0-or-later
> +# Copyright (c) 2021 FUJITSU LIMITED. All rights reserved.
> +
> +top_srcdir		?= ../../../..
> +
> +include $(top_srcdir)/include/mk/env_pre.mk
> +
> +INSTALL_TARGETS		:= tc01.sh
> +
> +include $(top_srcdir)/include/mk/generic_leaf_target.mk
> diff --git a/testcases/network/tcp_cmds/tc/tc01.sh b/testcases/network/tcp_cmds/tc/tc01.sh
> new file mode 100755
> index 000000000..a9da45b41
> --- /dev/null
> +++ b/testcases/network/tcp_cmds/tc/tc01.sh
> @@ -0,0 +1,47 @@
> +#!/bin/sh
> +# SPDX-License-Identifier: GPL-2.0-or-later
> +# Copyright (c) 2021 FUJITSU LIMITED. All rights reserved.
> +# Author: Yang Xu<xuyang2018.jy@fujitsu.com>
> +#
> +# When using "tc qdisc add dev teql0 root teql0 command", qdisc_create()
> +# calls teql_qdisc_init() it imediately fails after check "if (m->dev == dev)"
> +# because both devices are teql0, and it does not set qdisc_priv(sch)->m
> +# leaving it zero on error path, then qdisc_create() imediately calls
> +# teql_destroy() which does not expect zero master pointer and we get OOPS
> +# on unpatched kernel.
> +#
> +# If we enable panic_on_oops, this case may crash.
> +#
> +# This kernel bug was introduced by
> +# commit 87b60cfacf9f ("net_sched: fix error recovery at qdisc creation")
> +# and has been fixed by
> +# commit 1ffbc7ea9160 ("net: sched: sch_teql: fix null-pointer dereference")
> +#
> +
> +TST_SETUP="setup"
> +TST_TESTFUNC="do_test"
> +TST_NEEDS_ROOT=1
> +TST_NEEDS_DRIVERS="sch_teql"
> +TST_NEEDS_CMDS="tc modprobe dmesg grep"
> +
> +. tst_test.sh
> +
> +setup()
> +{
> +	ROD modprobe $TST_NEEDS_DRIVERS
> +}
> +
> +do_test()
> +{
> +	tst_res TINFO "Use tc qdisc command to trigger a null-pointer dereference"
> +
> +	EXPECT_FAIL tc qdisc add dev teql0 root teql0
> +
> +	if dmesg | grep -q 'RIP:.*sch_teql'; then
> +		tst_res TFAIL "This bug is reproduced."
> +	else
> +		tst_res TPASS "This bug is not reproduced."
> +	fi
> +}
> +
> +tst_run


More information about the ltp mailing list