aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-01-19 12:30:33 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2018-01-19 12:30:33 -0500
commit726ba84b50acf6f5816c1d854150612d2a511bab (patch)
tree7edb760dadb00bf017b0b4e2a6f45b70f9a1c24f /tools
parentdda3e15231b35840fe6f0973f803cc70ddb86281 (diff)
parenta0dca10fce42ae82651edbe682b1c637a8ecd365 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Pull networking fixes from David Miller: 1) Fix BPF divides by zero, from Eric Dumazet and Alexei Starovoitov. 2) Reject stores into bpf context via st and xadd, from Daniel Borkmann. 3) Fix a memory leak in TUN, from Cong Wang. 4) Disable RX aggregation on a specific troublesome configuration of r8152 in a Dell TB16b dock. 5) Fix sw_ctx leak in tls, from Sabrina Dubroca. 6) Fix program replacement in cls_bpf, from Daniel Borkmann. 7) Fix uninitialized station_info structures in cfg80211, from Johannes Berg. 8) Fix miscalculation of transport header offset field in flow dissector, from Eric Dumazet. 9) Fix LPM tree leak on failure in mlxsw driver, from Ido Schimmel. * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (29 commits) ibmvnic: Fix IPv6 packet descriptors ibmvnic: Fix IP offload control buffer ipv6: don't let tb6_root node share routes with other node ip6_gre: init dev->mtu and dev->hard_header_len correctly mlxsw: spectrum_router: Free LPM tree upon failure flow_dissector: properly cap thoff field fm10k: mark PM functions as __maybe_unused cfg80211: fix station info handling bugs netlink: reset extack earlier in netlink_rcv_skb can: af_can: canfd_rcv(): replace WARN_ONCE by pr_warn_once can: af_can: can_rcv(): replace WARN_ONCE by pr_warn_once bpf: mark dst unknown on inconsistent {s, u}bounds adjustments bpf: fix cls_bpf on filter replace Net: ethernet: ti: netcp: Fix inbound ping crash if MTU size is greater than 1500 tls: reset crypto_info when do_tls_setsockopt_tx fails tls: return -EBUSY if crypto_info is already set tls: fix sw_ctx leak net/tls: Only attach to sockets in ESTABLISHED state net: fs_enet: do not call phy_stop() in interrupts r8152: disable RX aggregation on Dell TB16 dock ...
Diffstat (limited to 'tools')
-rw-r--r--tools/testing/selftests/bpf/test_verifier.c152
1 files changed, 149 insertions, 3 deletions
diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c
index 6bafa5456568..5ed4175c4ff8 100644
--- a/tools/testing/selftests/bpf/test_verifier.c
+++ b/tools/testing/selftests/bpf/test_verifier.c
@@ -2593,6 +2593,29 @@ static struct bpf_test tests[] = {
2593 .prog_type = BPF_PROG_TYPE_SCHED_CLS, 2593 .prog_type = BPF_PROG_TYPE_SCHED_CLS,
2594 }, 2594 },
2595 { 2595 {
2596 "context stores via ST",
2597 .insns = {
2598 BPF_MOV64_IMM(BPF_REG_0, 0),
2599 BPF_ST_MEM(BPF_DW, BPF_REG_1, offsetof(struct __sk_buff, mark), 0),
2600 BPF_EXIT_INSN(),
2601 },
2602 .errstr = "BPF_ST stores into R1 context is not allowed",
2603 .result = REJECT,
2604 .prog_type = BPF_PROG_TYPE_SCHED_CLS,
2605 },
2606 {
2607 "context stores via XADD",
2608 .insns = {
2609 BPF_MOV64_IMM(BPF_REG_0, 0),
2610 BPF_RAW_INSN(BPF_STX | BPF_XADD | BPF_W, BPF_REG_1,
2611 BPF_REG_0, offsetof(struct __sk_buff, mark), 0),
2612 BPF_EXIT_INSN(),
2613 },
2614 .errstr = "BPF_XADD stores into R1 context is not allowed",
2615 .result = REJECT,
2616 .prog_type = BPF_PROG_TYPE_SCHED_CLS,
2617 },
2618 {
2596 "direct packet access: test1", 2619 "direct packet access: test1",
2597 .insns = { 2620 .insns = {
2598 BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1, 2621 BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1,
@@ -4312,7 +4335,8 @@ static struct bpf_test tests[] = {
4312 .fixup_map1 = { 2 }, 4335 .fixup_map1 = { 2 },
4313 .errstr_unpriv = "R2 leaks addr into mem", 4336 .errstr_unpriv = "R2 leaks addr into mem",
4314 .result_unpriv = REJECT, 4337 .result_unpriv = REJECT,
4315 .result = ACCEPT, 4338 .result = REJECT,
4339 .errstr = "BPF_XADD stores into R1 context is not allowed",
4316 }, 4340 },
4317 { 4341 {
4318 "leak pointer into ctx 2", 4342 "leak pointer into ctx 2",
@@ -4326,7 +4350,8 @@ static struct bpf_test tests[] = {
4326 }, 4350 },
4327 .errstr_unpriv = "R10 leaks addr into mem", 4351 .errstr_unpriv = "R10 leaks addr into mem",
4328 .result_unpriv = REJECT, 4352 .result_unpriv = REJECT,
4329 .result = ACCEPT, 4353 .result = REJECT,
4354 .errstr = "BPF_XADD stores into R1 context is not allowed",
4330 }, 4355 },
4331 { 4356 {
4332 "leak pointer into ctx 3", 4357 "leak pointer into ctx 3",
@@ -6707,7 +6732,7 @@ static struct bpf_test tests[] = {
6707 BPF_JMP_IMM(BPF_JA, 0, 0, -7), 6732 BPF_JMP_IMM(BPF_JA, 0, 0, -7),
6708 }, 6733 },
6709 .fixup_map1 = { 4 }, 6734 .fixup_map1 = { 4 },
6710 .errstr = "unbounded min value", 6735 .errstr = "R0 invalid mem access 'inv'",
6711 .result = REJECT, 6736 .result = REJECT,
6712 }, 6737 },
6713 { 6738 {
@@ -8609,6 +8634,127 @@ static struct bpf_test tests[] = {
8609 .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS, 8634 .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
8610 }, 8635 },
8611 { 8636 {
8637 "check deducing bounds from const, 1",
8638 .insns = {
8639 BPF_MOV64_IMM(BPF_REG_0, 1),
8640 BPF_JMP_IMM(BPF_JSGE, BPF_REG_0, 1, 0),
8641 BPF_ALU64_REG(BPF_SUB, BPF_REG_0, BPF_REG_1),
8642 BPF_EXIT_INSN(),
8643 },
8644 .result = REJECT,
8645 .errstr = "R0 tried to subtract pointer from scalar",
8646 },
8647 {
8648 "check deducing bounds from const, 2",
8649 .insns = {
8650 BPF_MOV64_IMM(BPF_REG_0, 1),
8651 BPF_JMP_IMM(BPF_JSGE, BPF_REG_0, 1, 1),
8652 BPF_EXIT_INSN(),
8653 BPF_JMP_IMM(BPF_JSLE, BPF_REG_0, 1, 1),
8654 BPF_EXIT_INSN(),
8655 BPF_ALU64_REG(BPF_SUB, BPF_REG_1, BPF_REG_0),
8656 BPF_EXIT_INSN(),
8657 },
8658 .result = ACCEPT,
8659 },
8660 {
8661 "check deducing bounds from const, 3",
8662 .insns = {
8663 BPF_MOV64_IMM(BPF_REG_0, 0),
8664 BPF_JMP_IMM(BPF_JSLE, BPF_REG_0, 0, 0),
8665 BPF_ALU64_REG(BPF_SUB, BPF_REG_0, BPF_REG_1),
8666 BPF_EXIT_INSN(),
8667 },
8668 .result = REJECT,
8669 .errstr = "R0 tried to subtract pointer from scalar",
8670 },
8671 {
8672 "check deducing bounds from const, 4",
8673 .insns = {
8674 BPF_MOV64_IMM(BPF_REG_0, 0),
8675 BPF_JMP_IMM(BPF_JSLE, BPF_REG_0, 0, 1),
8676 BPF_EXIT_INSN(),
8677 BPF_JMP_IMM(BPF_JSGE, BPF_REG_0, 0, 1),
8678 BPF_EXIT_INSN(),
8679 BPF_ALU64_REG(BPF_SUB, BPF_REG_1, BPF_REG_0),
8680 BPF_EXIT_INSN(),
8681 },
8682 .result = ACCEPT,
8683 },
8684 {
8685 "check deducing bounds from const, 5",
8686 .insns = {
8687 BPF_MOV64_IMM(BPF_REG_0, 0),
8688 BPF_JMP_IMM(BPF_JSGE, BPF_REG_0, 0, 1),
8689 BPF_ALU64_REG(BPF_SUB, BPF_REG_0, BPF_REG_1),
8690 BPF_EXIT_INSN(),
8691 },
8692 .result = REJECT,
8693 .errstr = "R0 tried to subtract pointer from scalar",
8694 },
8695 {
8696 "check deducing bounds from const, 6",
8697 .insns = {
8698 BPF_MOV64_IMM(BPF_REG_0, 0),
8699 BPF_JMP_IMM(BPF_JSGE, BPF_REG_0, 0, 1),
8700 BPF_EXIT_INSN(),
8701 BPF_ALU64_REG(BPF_SUB, BPF_REG_0, BPF_REG_1),
8702 BPF_EXIT_INSN(),
8703 },
8704 .result = REJECT,
8705 .errstr = "R0 tried to subtract pointer from scalar",
8706 },
8707 {
8708 "check deducing bounds from const, 7",
8709 .insns = {
8710 BPF_MOV64_IMM(BPF_REG_0, ~0),
8711 BPF_JMP_IMM(BPF_JSGE, BPF_REG_0, 0, 0),
8712 BPF_ALU64_REG(BPF_SUB, BPF_REG_1, BPF_REG_0),
8713 BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1,
8714 offsetof(struct __sk_buff, mark)),
8715 BPF_EXIT_INSN(),
8716 },
8717 .result = REJECT,
8718 .errstr = "dereference of modified ctx ptr",
8719 },
8720 {
8721 "check deducing bounds from const, 8",
8722 .insns = {
8723 BPF_MOV64_IMM(BPF_REG_0, ~0),
8724 BPF_JMP_IMM(BPF_JSGE, BPF_REG_0, 0, 1),
8725 BPF_ALU64_REG(BPF_ADD, BPF_REG_1, BPF_REG_0),
8726 BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1,
8727 offsetof(struct __sk_buff, mark)),
8728 BPF_EXIT_INSN(),
8729 },
8730 .result = REJECT,
8731 .errstr = "dereference of modified ctx ptr",
8732 },
8733 {
8734 "check deducing bounds from const, 9",
8735 .insns = {
8736 BPF_MOV64_IMM(BPF_REG_0, 0),
8737 BPF_JMP_IMM(BPF_JSGE, BPF_REG_0, 0, 0),
8738 BPF_ALU64_REG(BPF_SUB, BPF_REG_0, BPF_REG_1),
8739 BPF_EXIT_INSN(),
8740 },
8741 .result = REJECT,
8742 .errstr = "R0 tried to subtract pointer from scalar",
8743 },
8744 {
8745 "check deducing bounds from const, 10",
8746 .insns = {
8747 BPF_MOV64_IMM(BPF_REG_0, 0),
8748 BPF_JMP_IMM(BPF_JSLE, BPF_REG_0, 0, 0),
8749 /* Marks reg as unknown. */
8750 BPF_ALU64_IMM(BPF_NEG, BPF_REG_0, 0),
8751 BPF_ALU64_REG(BPF_SUB, BPF_REG_0, BPF_REG_1),
8752 BPF_EXIT_INSN(),
8753 },
8754 .result = REJECT,
8755 .errstr = "math between ctx pointer and register with unbounded min value is not allowed",
8756 },
8757 {
8612 "bpf_exit with invalid return code. test1", 8758 "bpf_exit with invalid return code. test1",
8613 .insns = { 8759 .insns = {
8614 BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1, 0), 8760 BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1, 0),