public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: xuyang2018.jy@fujitsu.com <xuyang2018.jy@fujitsu.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] network/tc01.sh: Add a regression test for tc qdisc command
Date: Thu, 8 Jul 2021 06:22:02 +0000	[thread overview]
Message-ID: <60E699AE.30607@fujitsu.com> (raw)
In-Reply-To: <50bca7a2-41f5-3eba-d1da-e8e12c883d22@bell-sw.com>

Hi Alexey
> Hi!
> On 07.07.2021 12:22, Yang Xu wrote:
>> Signed-off-by: Yang Xu<xuyang2018.jy@fujitsu.com>
>> ---
>>   runtest/net.tcp_cmds                   |  1 +
>>   testcases/network/tcp_cmds/tc/Makefile | 13 +++++++
>>   testcases/network/tcp_cmds/tc/tc01.sh  | 51 ++++++++++++++++++++++++++
>>   3 files changed, 65 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..60150a1ce
>> --- /dev/null
>> +++ b/testcases/network/tcp_cmds/tc/Makefile
>> @@ -0,0 +1,13 @@
>> +# SPDX-License-Identifier: GPL-2.0-or-later
>> +# Copyright (C) 2009, Cisco Systems Inc.
>> +# Ngie Cooper, July 2009
>> +
>> +top_srcdir		?= ../../../..
>> +
>> +include $(top_srcdir)/include/mk/env_pre.mk
>> +
>> +INSTALL_TARGETS		:= tc01.sh
>> +
>> +MAKE_TARGETS		:=
>> +
>> +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..0a241843b
>> --- /dev/null
>> +++ b/testcases/network/tcp_cmds/tc/tc01.sh
>> @@ -0,0 +1,51 @@
>> +#!/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_TESTFUNC="do_test"
>> +TST_NEEDS_ROOT=1
>> +TST_NEEDS_DRIVERS="sch_teql"
>> +TST_NEEDS_CMDS="tc modprobe"
>> +sys_file="/proc/sys/kernel/panic_on_oops"
>> +. tst_test.sh
>> +
>> +do_test()
>> +{
>> +	[ ! -f "$sys_file" ]&&  tst_brk TCONF "$sys_file not enabled"
>
> Why this check is needed and also setting panic_on_oops to
> trigger the bug? If not, I would suggest to remove them from
> the test.
>
Yes, I will remove it.

>> +	orig_value=$(cat "$sys_file")
>> +	if [ $orig_value = "0" ]; then
>> +		echo 1>  $sys_file
>> +	fi
>> +
>> +	tst_res TINFO "Use tc qdisc command to trigger a null-pointer dereference"
>> +	modprobe $TST_NEEDS_DRIVERS
>
> setup()
> {
> 	ROD modprobe $TST_NEEDS_DRIVERS
> }
>
>> +
>> +	tc qdisc add dev teql0 root teql0 2>/dev/null
>
> TST_EXP_FAIL tc qdisc add dev teql0 root teql0
Will do these on v2.

Best Regards
Yang Xu
>
>> +	if [ $? -eq 0 ]; then
>> +		tst_res TFAIL "tc qdisc command succeeded unexpectedly"
>> +	else
>> +		tst_res TPASS "the bug was not reproduced"
>> +	fi
>> +
>> +	if [ $orig_value = "0" ]; then
>> +		 echo 0>  $sys_file
>> +	fi
>> +}
>> +
>> +tst_run
>>

  reply	other threads:[~2021-07-08  6:22 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-07  9:22 [LTP] [PATCH] network/tc01.sh: Add a regression test for tc qdisc command Yang Xu
2021-07-07 14:03 ` Alexey Kodanev
2021-07-08  6:22   ` xuyang2018.jy [this message]
2021-07-08  8:42   ` [LTP] [PATCH v2] " Yang Xu
2021-07-09 10:05     ` Alexey Kodanev
2021-07-12  2:18       ` [LTP] [PATCH v3] " Yang Xu
2021-07-12  8:19         ` Alexey Kodanev
2021-07-12  9:10           ` [LTP] [PATCH v4 1/2] " Yang Xu
2021-07-12  9:10             ` [LTP] [PATCH v4 2/2] testcase/network: Remove useless MAKE_TARGETS Yang Xu
2021-07-21 17:14               ` Petr Vorel
2021-07-19  5:45             ` [LTP] [PATCH v4 1/2] network/tc01.sh: Add a regression test for tc qdisc command xuyang2018.jy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=60E699AE.30607@fujitsu.com \
    --to=xuyang2018.jy@fujitsu.com \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox