Files
linux/tools/testing/selftests/tc-testing/tc-tests/actions/sample.json
Davide Caratti e8c87c643e net/sched: act_sample: validate the control action inside init()
the following script:

 # tc qdisc add dev crash0 clsact
 # tc filter add dev crash0 egress matchall \
 > action sample rate 1024 group 4 pass index 90
 # tc actions replace action sample \
 > rate 1024 group 4 goto chain 42 index 90 cookie c1a0c1a0
 # tc actions show action sample

had the following output:

 Error: Failed to init TC action chain.
 We have an error talking to the kernel
 total acts 1

         action order 0: sample rate 1/1024 group 4 goto chain 42
          index 90 ref 2 bind 1
         cookie c1a0c1a0

Then, the first packet transmitted by crash0 made the kernel crash:

 BUG: unable to handle kernel NULL pointer dereference at 0000000000000000
 #PF error: [normal kernel read fault]
 PGD 8000000079966067 P4D 8000000079966067 PUD 7987b067 PMD 0
 Oops: 0000 [#1] SMP PTI
 CPU: 0 PID: 5 Comm: kworker/0:0 Not tainted 5.0.0-rc4.gotochain_crash+ #536
 Hardware name: Red Hat KVM, BIOS 0.5.1 01/01/2011
 Workqueue: ipv6_addrconf addrconf_dad_work
 RIP: 0010:tcf_action_exec+0xb8/0x100
 Code: 00 00 00 20 74 1d 83 f8 03 75 09 49 83 c4 08 4d 39 ec 75 bc 48 83 c4 10 5b 5d 41 5c 41 5d 41 5e 41 5f c3 49 8b 97 a8 00 00 00 <48> 8b 12 48 89 55 00 48 83 c4 10 5b 5d 41 5c 41 5d 41 5e 41 5f c3
 RSP: 0018:ffffbee60033fad0 EFLAGS: 00010246
 RAX: 000000002000002a RBX: ffff99d7ae6e3b00 RCX: 00000000e555df9b
 RDX: 0000000000000000 RSI: 00000000b0352718 RDI: ffff99d7fda1fcf0
 RBP: ffffbee60033fb70 R08: 0000000070731ab1 R09: 0000000000000400
 R10: 0000000000000000 R11: ffff99d7ac733838 R12: ffff99d7f3c2be00
 R13: ffff99d7f3c2be08 R14: 0000000000000001 R15: ffff99d7f3c2b600
 FS:  0000000000000000(0000) GS:ffff99d7fda00000(0000) knlGS:0000000000000000
 CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
 CR2: 0000000000000000 CR3: 00000000797de006 CR4: 00000000001606f0
 Call Trace:
  tcf_classify+0x58/0x120
  __dev_queue_xmit+0x40a/0x890
  ? ndisc_next_option+0x50/0x50
  ? ___neigh_create+0x4d5/0x680
  ? ip6_finish_output2+0x1b5/0x590
  ip6_finish_output2+0x1b5/0x590
  ? ip6_output+0x68/0x110
  ip6_output+0x68/0x110
  ? nf_hook.constprop.28+0x79/0xc0
  ndisc_send_skb+0x248/0x2e0
  ndisc_send_ns+0xf8/0x200
  ? addrconf_dad_work+0x389/0x4b0
  addrconf_dad_work+0x389/0x4b0
  ? __switch_to_asm+0x34/0x70
  ? process_one_work+0x195/0x380
  ? addrconf_dad_completed+0x370/0x370
  process_one_work+0x195/0x380
  worker_thread+0x30/0x390
  ? process_one_work+0x380/0x380
  kthread+0x113/0x130
  ? kthread_park+0x90/0x90
  ret_from_fork+0x35/0x40
 Modules linked in: act_sample psample veth ip6table_filter ip6_tables iptable_filter binfmt_misc ext4 crct10dif_pclmul crc32_pclmul ghash_clmulni_intel mbcache jbd2 snd_hda_codec_generic snd_hda_intel snd_hda_codec snd_hwdep snd_hda_core snd_seq snd_seq_device aesni_intel crypto_simd snd_pcm cryptd glue_helper snd_timer joydev snd pcspkr virtio_balloon i2c_piix4 soundcore nfsd auth_rpcgss nfs_acl lockd grace sunrpc ip_tables xfs ata_generic pata_acpi qxl drm_kms_helper syscopyarea sysfillrect virtio_net sysimgblt fb_sys_fops net_failover ttm failover virtio_blk virtio_console drm ata_piix serio_raw crc32c_intel libata virtio_pci virtio_ring virtio floppy dm_mirror dm_region_hash dm_log dm_mod
 CR2: 0000000000000000

Validating the control action within tcf_sample_init() proved to fix the
above issue. A TDC selftest is added to verify the correct behavior.

Fixes: db50514f9a ("net: sched: add termination action to allow goto chain")
Fixes: 97763dc0f4 ("net_sched: reject unknown tcfa_action values")
Signed-off-by: Davide Caratti <dcaratti@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-03-21 13:26:41 -07:00

614 lines
18 KiB
JSON

[
{
"id": "9784",
"name": "Add valid sample action with mandatory arguments",
"category": [
"actions",
"sample"
],
"setup": [
[
"$TC actions flush action sample",
0,
1,
255
]
],
"cmdUnderTest": "$TC actions add action sample rate 10 group 1 index 2",
"expExitCode": "0",
"verifyCmd": "$TC actions get action sample index 2",
"matchPattern": "action order [0-9]+: sample rate 1/10 group 1.*index 2 ref",
"matchCount": "1",
"teardown": [
"$TC actions flush action sample"
]
},
{
"id": "5c91",
"name": "Add valid sample action with mandatory arguments and continue control action",
"category": [
"actions",
"sample"
],
"setup": [
[
"$TC actions flush action sample",
0,
1,
255
]
],
"cmdUnderTest": "$TC actions add action sample rate 700 group 2 continue index 2",
"expExitCode": "0",
"verifyCmd": "$TC actions get action sample index 2",
"matchPattern": "action order [0-9]+: sample rate 1/700 group 2 continue.*index 2 ref",
"matchCount": "1",
"teardown": [
"$TC actions flush action sample"
]
},
{
"id": "334b",
"name": "Add valid sample action with mandatory arguments and drop control action",
"category": [
"actions",
"sample"
],
"setup": [
[
"$TC actions flush action sample",
0,
1,
255
]
],
"cmdUnderTest": "$TC actions add action sample rate 10000 group 11 drop index 22",
"expExitCode": "0",
"verifyCmd": "$TC actions list action sample",
"matchPattern": "action order [0-9]+: sample rate 1/10000 group 11 drop.*index 22 ref",
"matchCount": "1",
"teardown": [
"$TC actions flush action sample"
]
},
{
"id": "da69",
"name": "Add valid sample action with mandatory arguments and reclassify control action",
"category": [
"actions",
"sample"
],
"setup": [
[
"$TC actions flush action sample",
0,
1,
255
]
],
"cmdUnderTest": "$TC actions add action sample rate 20000 group 72 reclassify index 100",
"expExitCode": "0",
"verifyCmd": "$TC actions list action sample",
"matchPattern": "action order [0-9]+: sample rate 1/20000 group 72 reclassify.*index 100 ref",
"matchCount": "1",
"teardown": [
"$TC actions flush action sample"
]
},
{
"id": "13ce",
"name": "Add valid sample action with mandatory arguments and pipe control action",
"category": [
"actions",
"sample"
],
"setup": [
[
"$TC actions flush action sample",
0,
1,
255
]
],
"cmdUnderTest": "$TC actions add action sample rate 20 group 2 pipe index 100",
"expExitCode": "0",
"verifyCmd": "$TC actions list action sample",
"matchPattern": "action order [0-9]+: sample rate 1/20 group 2 pipe.*index 100 ref",
"matchCount": "1",
"teardown": [
"$TC actions flush action sample"
]
},
{
"id": "1886",
"name": "Add valid sample action with mandatory arguments and jump control action",
"category": [
"actions",
"sample"
],
"setup": [
[
"$TC actions flush action sample",
0,
1,
255
]
],
"cmdUnderTest": "$TC actions add action sample rate 700 group 25 jump 4 index 200",
"expExitCode": "0",
"verifyCmd": "$TC actions get action sample index 200",
"matchPattern": "action order [0-9]+: sample rate 1/700 group 25 jump 4.*index 200 ref",
"matchCount": "1",
"teardown": [
"$TC actions flush action sample"
]
},
{
"id": "b6d4",
"name": "Add sample action with mandatory arguments and invalid control action",
"category": [
"actions",
"sample"
],
"setup": [
[
"$TC actions flush action sample",
0,
1,
255
]
],
"cmdUnderTest": "$TC actions add action sample rate 200000 group 52 foo index 1",
"expExitCode": "255",
"verifyCmd": "$TC actions list action sample",
"matchPattern": "action order [0-9]+: sample rate 1/200000 group 52 foo.*index 1 ref",
"matchCount": "0",
"teardown": []
},
{
"id": "a874",
"name": "Add invalid sample action without mandatory arguments",
"category": [
"actions",
"sample"
],
"setup": [
[
"$TC actions flush action sample",
0,
1,
255
]
],
"cmdUnderTest": "$TC actions add action sample index 1",
"expExitCode": "255",
"verifyCmd": "$TC actions list action sample",
"matchPattern": "action order [0-9]+: sample.*index 1 ref",
"matchCount": "0",
"teardown": []
},
{
"id": "ac01",
"name": "Add invalid sample action without mandatory argument rate",
"category": [
"actions",
"sample"
],
"setup": [
[
"$TC actions flush action sample",
0,
1,
255
]
],
"cmdUnderTest": "$TC actions add action sample group 10 index 1",
"expExitCode": "255",
"verifyCmd": "$TC actions list action sample",
"matchPattern": "action order [0-9]+: sample.*group 10.*index 1 ref",
"matchCount": "0",
"teardown": []
},
{
"id": "4203",
"name": "Add invalid sample action without mandatory argument group",
"category": [
"actions",
"sample"
],
"setup": [
[
"$TC actions flush action sample",
0,
1,
255
]
],
"cmdUnderTest": "$TC actions add action sample rate 100 index 10",
"expExitCode": "255",
"verifyCmd": "$TC actions get action sample index 10",
"matchPattern": "action order [0-9]+: sample rate 1/100.*index 10 ref",
"matchCount": "0",
"teardown": []
},
{
"id": "14a7",
"name": "Add invalid sample action without mandatory argument group",
"category": [
"actions",
"sample"
],
"setup": [
[
"$TC actions flush action sample",
0,
1,
255
]
],
"cmdUnderTest": "$TC actions add action sample rate 100 index 10",
"expExitCode": "255",
"verifyCmd": "$TC actions get action sample index 10",
"matchPattern": "action order [0-9]+: sample rate 1/100.*index 10 ref",
"matchCount": "0",
"teardown": []
},
{
"id": "8f2e",
"name": "Add valid sample action with trunc argument",
"category": [
"actions",
"sample"
],
"setup": [
[
"$TC actions flush action sample",
0,
1,
255
]
],
"cmdUnderTest": "$TC actions add action sample rate 1024 group 4 trunc 1024 index 10",
"expExitCode": "0",
"verifyCmd": "$TC actions get action sample index 10",
"matchPattern": "action order [0-9]+: sample rate 1/1024 group 4 trunc_size 1024 pipe.*index 10 ref",
"matchCount": "1",
"teardown": [
"$TC actions flush action sample"
]
},
{
"id": "45f8",
"name": "Add sample action with maximum rate argument",
"category": [
"actions",
"sample"
],
"setup": [
[
"$TC actions flush action sample",
0,
1,
255
]
],
"cmdUnderTest": "$TC actions add action sample rate 4294967295 group 4 index 10",
"expExitCode": "0",
"verifyCmd": "$TC actions get action sample index 10",
"matchPattern": "action order [0-9]+: sample rate 1/4294967295 group 4 pipe.*index 10 ref",
"matchCount": "1",
"teardown": [
"$TC actions flush action sample"
]
},
{
"id": "ad0c",
"name": "Add sample action with maximum trunc argument",
"category": [
"actions",
"sample"
],
"setup": [
[
"$TC actions flush action sample",
0,
1,
255
]
],
"cmdUnderTest": "$TC actions add action sample rate 16000 group 4 trunc 4294967295 index 10",
"expExitCode": "0",
"verifyCmd": "$TC actions get action sample index 10",
"matchPattern": "action order [0-9]+: sample rate 1/16000 group 4 trunc_size 4294967295 pipe.*index 10 ref",
"matchCount": "1",
"teardown": [
"$TC actions flush action sample"
]
},
{
"id": "83a9",
"name": "Add sample action with maximum group argument",
"category": [
"actions",
"sample"
],
"setup": [
[
"$TC actions flush action sample",
0,
1,
255
]
],
"cmdUnderTest": "$TC actions add action sample rate 4294 group 4294967295 index 1",
"expExitCode": "0",
"verifyCmd": "$TC actions get action sample index 1",
"matchPattern": "action order [0-9]+: sample rate 1/4294 group 4294967295 pipe.*index 1 ref",
"matchCount": "1",
"teardown": [
"$TC actions flush action sample"
]
},
{
"id": "ed27",
"name": "Add sample action with invalid rate argument",
"category": [
"actions",
"sample"
],
"setup": [
[
"$TC actions flush action sample",
0,
1,
255
]
],
"cmdUnderTest": "$TC actions add action sample rate 4294967296 group 4 index 10",
"expExitCode": "255",
"verifyCmd": "$TC actions get action sample index 10",
"matchPattern": "action order [0-9]+: sample rate 1/4294967296 group 4 pipe.*index 10 ref",
"matchCount": "0",
"teardown": []
},
{
"id": "2eae",
"name": "Add sample action with invalid group argument",
"category": [
"actions",
"sample"
],
"setup": [
[
"$TC actions flush action sample",
0,
1,
255
]
],
"cmdUnderTest": "$TC actions add action sample rate 4098 group 5294967299 continue index 1",
"expExitCode": "255",
"verifyCmd": "$TC actions get action sample index 1",
"matchPattern": "action order [0-9]+: sample rate 1/4098 group 5294967299 continue.*index 1 ref",
"matchCount": "0",
"teardown": []
},
{
"id": "6ff3",
"name": "Add sample action with invalid trunc size",
"category": [
"actions",
"sample"
],
"setup": [
[
"$TC actions flush action sample",
0,
1,
255
]
],
"cmdUnderTest": "$TC actions add action sample rate 1024 group 4 trunc 112233445566 index 11",
"expExitCode": "255",
"verifyCmd": "$TC actions get action sample index 11",
"matchPattern": "action order [0-9]+: sample rate 1/1024 group 4 trunc_size 112233445566.*index 11 ref",
"matchCount": "0",
"teardown": []
},
{
"id": "2b2a",
"name": "Add sample action with invalid index",
"category": [
"actions",
"sample"
],
"setup": [
[
"$TC actions flush action sample",
0,
1,
255
]
],
"cmdUnderTest": "$TC actions add action sample rate 1024 group 4 index 5294967299",
"expExitCode": "255",
"verifyCmd": "$TC actions get action sample index 5294967299",
"matchPattern": "action order [0-9]+: sample rate 1/1024 group 4 pipe.*index 5294967299 ref",
"matchCount": "0",
"teardown": []
},
{
"id": "dee2",
"name": "Add sample action with maximum allowed index",
"category": [
"actions",
"sample"
],
"setup": [
[
"$TC actions flush action sample",
0,
1,
255
]
],
"cmdUnderTest": "$TC actions add action sample rate 1024 group 4 index 4294967295",
"expExitCode": "0",
"verifyCmd": "$TC actions get action sample index 4294967295",
"matchPattern": "action order [0-9]+: sample rate 1/1024 group 4 pipe.*index 4294967295 ref",
"matchCount": "1",
"teardown": [
"$TC actions flush action sample"
]
},
{
"id": "560e",
"name": "Add sample action with cookie",
"category": [
"actions",
"sample"
],
"setup": [
[
"$TC actions flush action sample",
0,
1,
255
]
],
"cmdUnderTest": "$TC actions add action sample rate 1024 group 4 index 45 cookie aabbccdd",
"expExitCode": "0",
"verifyCmd": "$TC actions get action sample index 45",
"matchPattern": "action order [0-9]+: sample rate 1/1024 group 4 pipe.*index 45.*cookie aabbccdd",
"matchCount": "1",
"teardown": [
"$TC actions flush action sample"
]
},
{
"id": "704a",
"name": "Replace existing sample action with new rate argument",
"category": [
"actions",
"sample"
],
"setup": [
[
"$TC actions flush action sample",
0,
1,
255
],
"$TC actions add action sample rate 1024 group 4 index 4"
],
"cmdUnderTest": "$TC actions replace action sample rate 2048 group 4 index 4",
"expExitCode": "0",
"verifyCmd": "$TC actions list action sample",
"matchPattern": "action order [0-9]+: sample rate 1/2048 group 4 pipe.*index 4",
"matchCount": "1",
"teardown": [
"$TC actions flush action sample"
]
},
{
"id": "60eb",
"name": "Replace existing sample action with new group argument",
"category": [
"actions",
"sample"
],
"setup": [
[
"$TC actions flush action sample",
0,
1,
255
],
"$TC actions add action sample rate 1024 group 4 index 4"
],
"cmdUnderTest": "$TC actions replace action sample rate 1024 group 7 index 4",
"expExitCode": "0",
"verifyCmd": "$TC actions list action sample",
"matchPattern": "action order [0-9]+: sample rate 1/1024 group 7 pipe.*index 4",
"matchCount": "1",
"teardown": [
"$TC actions flush action sample"
]
},
{
"id": "2cce",
"name": "Replace existing sample action with new trunc argument",
"category": [
"actions",
"sample"
],
"setup": [
[
"$TC actions flush action sample",
0,
1,
255
],
"$TC actions add action sample rate 1024 group 4 trunc 48 index 4"
],
"cmdUnderTest": "$TC actions replace action sample rate 1024 group 7 trunc 64 index 4",
"expExitCode": "0",
"verifyCmd": "$TC actions list action sample",
"matchPattern": "action order [0-9]+: sample rate 1/1024 group 7 trunc_size 64 pipe.*index 4",
"matchCount": "1",
"teardown": [
"$TC actions flush action sample"
]
},
{
"id": "59d1",
"name": "Replace existing sample action with new control argument",
"category": [
"actions",
"sample"
],
"setup": [
[
"$TC actions flush action sample",
0,
1,
255
],
"$TC actions add action sample rate 1024 group 4 reclassify index 4"
],
"cmdUnderTest": "$TC actions replace action sample rate 1024 group 7 pipe index 4",
"expExitCode": "0",
"verifyCmd": "$TC actions list action sample",
"matchPattern": "action order [0-9]+: sample rate 1/1024 group 7 pipe.*index 4",
"matchCount": "1",
"teardown": [
"$TC actions flush action sample"
]
},
{
"id": "0a6e",
"name": "Replace sample action with invalid goto chain control",
"category": [
"actions",
"sample"
],
"setup": [
[
"$TC actions flush action sample",
0,
1,
255
],
"$TC actions add action sample rate 1024 group 4 pass index 90"
],
"cmdUnderTest": "$TC actions replace action sample rate 1024 group 7 goto chain 42 index 90 cookie c1a0c1a0",
"expExitCode": "255",
"verifyCmd": "$TC actions list action sample",
"matchPattern": "action order [0-9]+: sample rate 1/1024 group 4 pass.*index 90",
"matchCount": "1",
"teardown": [
"$TC actions flush action sample"
]
}
]