Netdev List
 help / color / mirror / Atom feed
* Re: [PATCH v2 3/7] bpf: Add strict alignment flag for BPF_PROG_LOAD.
From: David Miller @ 2017-05-11 16:43 UTC (permalink / raw)
  To: ecree; +Cc: daniel, ast, alexei.starovoitov, netdev
In-Reply-To: <a1a33bb6-c230-3748-a192-9479d5d4fa2d@solarflare.com>

From: Edward Cree <ecree@solarflare.com>
Date: Thu, 11 May 2017 17:18:30 +0100

> On 11/05/17 17:05, David Miller wrote:
>> Add a new field, "prog_flags", and an initial flag value
>> BPF_F_STRCIT_ALIGNMENT.
> Should this be STRICT?

Indeed, thanks for catching that typo.

^ permalink raw reply

* Re: [PATCH net] bpf, arm64: fix faulty emission of map access in tail calls
From: David Miller @ 2017-05-11 16:42 UTC (permalink / raw)
  To: daniel
  Cc: alexei.starovoitov, illusionist.neo, zlim.lnx, catalin.marinas,
	netdev, linux-arm-kernel
In-Reply-To: <0e928e7c351b962a16376a2ab29e2af1c5b4c027.1494459589.git.daniel@iogearbox.net>

From: Daniel Borkmann <daniel@iogearbox.net>
Date: Thu, 11 May 2017 01:53:15 +0200

> Shubham was recently asking on netdev why in arm64 JIT we don't multiply
> the index for accessing the tail call map by 8. That led me into testing
> out arm64 JIT wrt tail calls and it turned out I got a NULL pointer
> dereference on the tail call.
 ...
> Fix this by emitting the following instead:
> 
>   [...]
>   00000060:  d2800e0a  mov x10, #0x70 // #112
>   00000064:  8b0a002a  add x10, x1, x10
>   00000068:  d37df04b  lsl x11, x2, #3
>   0000006c:  f86b694b  ldr x11, [x10,x11]
>   00000070:  b40000ab  cbz x11, 0x00000084
>   [...]
> 
> This basically adds the offset to ptrs to the base address of the bpf
> array we got and we later on access the map with an index * 8 offset
> relative to that. The tail call map itself is basically one large area
> with meta data at the head followed by the array of prog pointers.
> This makes tail calls working again, tested on Cavium ThunderX ARMv8.
> 
> Fixes: ddb55992b04d ("arm64: bpf: implement bpf_tail_call() helper")
> Reported-by: Shubham Bansal <illusionist.neo@gmail.com>
> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>

Applied and queued up for -stable, thanks.

^ permalink raw reply

* Re: [PATCH v2 2/7] bpf: Do per-instruction state dumping in verifier when log_level > 1.
From: Daniel Borkmann @ 2017-05-11 16:40 UTC (permalink / raw)
  To: David Miller; +Cc: ast, alexei.starovoitov, netdev
In-Reply-To: <20170511.120529.492579439081538459.davem@davemloft.net>

On 05/11/2017 06:05 PM, David Miller wrote:
>
> If log_level > 1, do a state dump every instruction and emit it in
> a more compact way (without a leading newline).
>
> This will facilitate more sophisticated test cases which inspect the
> verifier log for register state.
>
> Signed-off-by: David S. Miller <davem@davemloft.net>

Acked-by: Daniel Borkmann <daniel@iogearbox.net>

^ permalink raw reply

* Re: [PATCH] net: ethernet: ti: netcp_core: return error while dma channel open issue
From: David Miller @ 2017-05-11 16:40 UTC (permalink / raw)
  To: ivan.khoronzhuk; +Cc: w-kwok2, m-karicheri2, ssantosh, netdev, linux-kernel
In-Reply-To: <1494437285-13839-1-git-send-email-ivan.khoronzhuk@linaro.org>

From: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
Date: Wed, 10 May 2017 10:28:05 -0700

> Fix error path while dma open channel issue. Also, no need to check output
> on NULL if it's never returned.
> 
> Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>

Applied.

^ permalink raw reply

* Re: [PATCH net 0/4] s390/net fixes
From: David Miller @ 2017-05-11 16:38 UTC (permalink / raw)
  To: jwi; +Cc: netdev, linux-s390, schwidefsky, heiko.carstens, raspl, ubraun
In-Reply-To: <20170510170754.53922-1-jwi@linux.vnet.ibm.com>

From: Julian Wiedmann <jwi@linux.vnet.ibm.com>
Date: Wed, 10 May 2017 19:07:50 +0200

> some qeth fixes for -net, the OSM/OSN one being the most crucial.
> Please also queue these up for stable.

Series applied and queued up for -stable, thanks.

^ permalink raw reply

* Re: Implementing Dynamic Rerouting in Kernel
From: Florian Fainelli @ 2017-05-11 16:22 UTC (permalink / raw)
  To: Ravish Kumar, Networking, linux-kernel, mst, Jason
In-Reply-To: <CAEDnJmKWYeEwB=cBKd-cOL+hmxe0U6G7CQ8Mkwc_eP5CpJVmbA@mail.gmail.com>

On 05/11/2017 02:59 AM, Ravish Kumar wrote:
> Hi Experts,
> 
> Need expert advice for the one of the requirement Where in VPN
> solution we want to dynaically route the packets to different adapter.
> We will manage our own DNS cache and , based on DNS to IP lookup, we
> can redirect the packet either to Tun device or to a physical adapter.
> 
> Please suggest some design what i need to do.

What you are looking for can be done using ipset-dns from Jason:

https://git.zx2c4.com/ipset-dns/about/
-- 
Florian

^ permalink raw reply

* Re: [PATCH v2 3/7] bpf: Add strict alignment flag for BPF_PROG_LOAD.
From: Edward Cree @ 2017-05-11 16:18 UTC (permalink / raw)
  To: David Miller, daniel; +Cc: ast, alexei.starovoitov, netdev
In-Reply-To: <20170511.120540.405652687533650995.davem@davemloft.net>

On 11/05/17 17:05, David Miller wrote:
> Add a new field, "prog_flags", and an initial flag value
> BPF_F_STRCIT_ALIGNMENT.
Should this be STRICT?

^ permalink raw reply

* Re: [Patch net] ipv6/dccp: do not inherit ipv6_mc_list from parent
From: David Miller @ 2017-05-11 16:18 UTC (permalink / raw)
  To: xiyou.wangcong; +Cc: netdev, edumazet
In-Reply-To: <1494374394-24373-1-git-send-email-xiyou.wangcong@gmail.com>

From: Cong Wang <xiyou.wangcong@gmail.com>
Date: Tue,  9 May 2017 16:59:54 -0700

> Like commit 657831ffc38e ("dccp/tcp: do not inherit mc_list from parent")
> we should clear ipv6_mc_list etc. for IPv6 sockets too.
> 
> Cc: Eric Dumazet <edumazet@google.com>
> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>

Applied and queued up for -stable, thanks.

^ permalink raw reply

* Re: [PATCH] netxen_nic: set rcode to the return status from the call to netxen_issue_cmd
From: David Miller @ 2017-05-11 16:16 UTC (permalink / raw)
  To: colin.king
  Cc: manish.chopra, rahul.verma, Dept-GELinuxNICDev, netdev,
	kernel-janitors, linux-kernel
In-Reply-To: <20170509161942.32383-1-colin.king@canonical.com>

From: Colin King <colin.king@canonical.com>
Date: Tue,  9 May 2017 17:19:42 +0100

> From: Colin Ian King <colin.king@canonical.com>
> 
> Currently rcode is being initialized to NX_RCODE_SUCCESS and later it
> is checked to see if it is not NX_RCODE_SUCCESS which is never true. It
> appears that there is an unintentional missing assignment of rcode from
> the return of the call to netxen_issue_cmd() that was dropped in
> an earlier fix, so add it in.
> 
> Detected by CoverityScan, CID#401900 ("Logically dead code")
> 
> Fixes: 2dcd5d95ad6b2 ("netxen_nic: fix cdrp race condition")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Applied.

^ permalink raw reply

* Re: [PATCH] net: qca_spi: Fix alignment issues in rx path
From: David Miller @ 2017-05-11 16:14 UTC (permalink / raw)
  To: stefan.wahren; +Cc: gregkh, netdev, linux-kernel
In-Reply-To: <1494337238-1699-1-git-send-email-stefan.wahren@i2se.com>

From: Stefan Wahren <stefan.wahren@i2se.com>
Date: Tue,  9 May 2017 15:40:38 +0200

> The qca_spi driver causes alignment issues on ARM devices.
> So fix this by using netdev_alloc_skb_ip_align().
> 
> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
> Fixes: 291ab06ecf67 ("net: qualcomm: new Ethernet over SPI driver for QCA7000")

Applied.

^ permalink raw reply

* Re: [PATCH net v2] driver: vrf: Fix one possible use-after-free issue
From: David Miller @ 2017-05-11 16:13 UTC (permalink / raw)
  To: gfree.wind; +Cc: dsa, shm, fw, netdev
In-Reply-To: <1494325653-39885-1-git-send-email-gfree.wind@vip.163.com>

From: gfree.wind@vip.163.com
Date: Tue,  9 May 2017 18:27:33 +0800

> From: Gao Feng <gfree.wind@vip.163.com>
> 
> The current codes only deal with the case that the skb is dropped, it
> may meet one use-after-free issue when NF_HOOK returns 0 that means
> the skb is stolen by one netfilter rule or hook.
> 
> When one netfilter rule or hook stoles the skb and return NF_STOLEN,
> it means the skb is taken by the rule, and other modules should not
> touch this skb ever. Maybe the skb is queued or freed directly by the
> rule.
> 
> Now uses the nf_hook instead of NF_HOOK to get the result of netfilter,
> and check the return value of nf_hook. Only when its value equals 1, it
> means the skb could go ahead. Or reset the skb as NULL.
> 
> BTW, because vrf_rcv_finish is empty function, so needn't invoke it
> even though nf_hook returns 1. But we need to modify vrf_rcv_finish
> to deal with the NF_STOLEN case.
> 
> There are two cases when skb is stolen.
> 1. The skb is stolen and freed directly.
>    There is nothing we need to do, and vrf_rcv_finish isn't invoked.
> 2. The skb is queued and reinjected again.
>    The vrf_rcv_finish would be invoked as okfn, so need to free the
>    skb in it.
> 
> Signed-off-by: Gao Feng <gfree.wind@vip.163.com>

Applied and queued up for -stable, thanks.

^ permalink raw reply

* [PATCH v2 7/7] bpf: Adjust test_verifier for alignment changes.
From: David Miller @ 2017-05-11 16:06 UTC (permalink / raw)
  To: daniel; +Cc: ast, alexei.starovoitov, netdev


Now that the verifier properly tracks pointer alignment,
many of the tests here no longer need to specify the test
flag F_NEEDS_EFFICIENT_UNALIGNED_ACCESS.

The are only two tests remaining which need it and those
intentionally try to perform unaligned accesses.

Signed-off-by: David S. Miller <davem@davemloft.net>
---
 tools/testing/selftests/bpf/test_verifier.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c
index 3773562..5318fbc 100644
--- a/tools/testing/selftests/bpf/test_verifier.c
+++ b/tools/testing/selftests/bpf/test_verifier.c
@@ -3117,7 +3117,6 @@ static struct bpf_test tests[] = {
 		.errstr_unpriv = "R0 pointer arithmetic prohibited",
 		.result_unpriv = REJECT,
 		.result = ACCEPT,
-		.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
 	},
 	{
 		"valid map access into an array with a variable",
@@ -3141,7 +3140,6 @@ static struct bpf_test tests[] = {
 		.errstr_unpriv = "R0 pointer arithmetic prohibited",
 		.result_unpriv = REJECT,
 		.result = ACCEPT,
-		.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
 	},
 	{
 		"valid map access into an array with a signed variable",
@@ -3169,7 +3167,6 @@ static struct bpf_test tests[] = {
 		.errstr_unpriv = "R0 pointer arithmetic prohibited",
 		.result_unpriv = REJECT,
 		.result = ACCEPT,
-		.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
 	},
 	{
 		"invalid map access into an array with a constant",
@@ -3211,7 +3208,6 @@ static struct bpf_test tests[] = {
 		.errstr = "R0 min value is outside of the array range",
 		.result_unpriv = REJECT,
 		.result = REJECT,
-		.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
 	},
 	{
 		"invalid map access into an array with a variable",
@@ -3235,7 +3231,6 @@ static struct bpf_test tests[] = {
 		.errstr = "R0 min value is negative, either use unsigned index or do a if (index >=0) check.",
 		.result_unpriv = REJECT,
 		.result = REJECT,
-		.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
 	},
 	{
 		"invalid map access into an array with no floor check",
@@ -3262,7 +3257,6 @@ static struct bpf_test tests[] = {
 		.errstr = "R0 min value is negative, either use unsigned index or do a if (index >=0) check.",
 		.result_unpriv = REJECT,
 		.result = REJECT,
-		.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
 	},
 	{
 		"invalid map access into an array with a invalid max check",
@@ -3289,7 +3283,6 @@ static struct bpf_test tests[] = {
 		.errstr = "invalid access to map value, value_size=48 off=44 size=8",
 		.result_unpriv = REJECT,
 		.result = REJECT,
-		.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
 	},
 	{
 		"invalid map access into an array with a invalid max check",
@@ -3319,7 +3312,6 @@ static struct bpf_test tests[] = {
 		.errstr = "R0 min value is negative, either use unsigned index or do a if (index >=0) check.",
 		.result_unpriv = REJECT,
 		.result = REJECT,
-		.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
 	},
 	{
 		"multiple registers share map_lookup_elem result",
@@ -3443,7 +3435,6 @@ static struct bpf_test tests[] = {
 		.result = REJECT,
 		.errstr_unpriv = "R0 pointer arithmetic prohibited",
 		.result_unpriv = REJECT,
-		.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
 	},
 	{
 		"constant register |= constant should keep constant type",
@@ -4396,7 +4387,6 @@ static struct bpf_test tests[] = {
 		.errstr_unpriv = "R0 pointer arithmetic prohibited",
 		.result = ACCEPT,
 		.result_unpriv = REJECT,
-		.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
 	},
 	{
 		"helper access to variable memory: stack, bitwise AND + JMP, correct bounds",
@@ -4835,7 +4825,6 @@ static struct bpf_test tests[] = {
 		.errstr = "R0 min value is negative, either use unsigned index or do a if (index >=0) check.",
 		.result = REJECT,
 		.result_unpriv = REJECT,
-		.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
 	},
 	{
 		"invalid range check",
@@ -4867,7 +4856,6 @@ static struct bpf_test tests[] = {
 		.errstr = "R0 min value is negative, either use unsigned index or do a if (index >=0) check.",
 		.result = REJECT,
 		.result_unpriv = REJECT,
-		.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
 	},
 	{
 		"map in map access",
@@ -5070,7 +5058,7 @@ static void do_test_single(struct bpf_test *test, bool unpriv,
 
 	reject_from_alignment = fd_prog < 0 &&
 				(test->flags & F_NEEDS_EFFICIENT_UNALIGNED_ACCESS) &&
-				strstr(bpf_vlog, "Unknown alignment.");
+				strstr(bpf_vlog, "misaligned value access");
 #ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
 	if (reject_from_alignment) {
 		printf("FAIL\nFailed due to alignment despite having efficient unaligned access: '%s'!\n",
-- 
2.1.2.532.g19b5d50

^ permalink raw reply related

* [PATCH v2 5/7] bpf: Add verifier test case for alignment.
From: David Miller @ 2017-05-11 16:06 UTC (permalink / raw)
  To: daniel; +Cc: ast, alexei.starovoitov, netdev


Signed-off-by: David S. Miller <davem@davemloft.net>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
---
 tools/testing/selftests/bpf/Makefile     |   3 +-
 tools/testing/selftests/bpf/test_align.c | 417 +++++++++++++++++++++++++++++++
 2 files changed, 419 insertions(+), 1 deletion(-)
 create mode 100644 tools/testing/selftests/bpf/test_align.c

diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
index 91edd05..f92f27d 100644
--- a/tools/testing/selftests/bpf/Makefile
+++ b/tools/testing/selftests/bpf/Makefile
@@ -11,7 +11,8 @@ endif
 CFLAGS += -Wall -O2 -I$(APIDIR) -I$(LIBDIR) -I$(GENDIR) $(GENFLAGS) -I../../../include
 LDLIBS += -lcap -lelf
 
-TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map test_lpm_map test_progs
+TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map test_lpm_map test_progs \
+	test_align
 
 TEST_GEN_FILES = test_pkt_access.o test_xdp.o test_l4lb.o test_tcp_estats.o
 
diff --git a/tools/testing/selftests/bpf/test_align.c b/tools/testing/selftests/bpf/test_align.c
new file mode 100644
index 0000000..9dd9794
--- /dev/null
+++ b/tools/testing/selftests/bpf/test_align.c
@@ -0,0 +1,417 @@
+#include <asm/types.h>
+#include <linux/types.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+#include <string.h>
+#include <stddef.h>
+#include <stdbool.h>
+
+#include <linux/unistd.h>
+#include <linux/filter.h>
+#include <linux/bpf_perf_event.h>
+#include <linux/bpf.h>
+
+#include <bpf/bpf.h>
+
+#include "../../../include/linux/filter.h"
+
+#ifndef ARRAY_SIZE
+# define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+#endif
+
+#define MAX_INSNS	512
+#define MAX_MATCHES	16
+
+struct bpf_align_test {
+	const char *descr;
+	struct bpf_insn	insns[MAX_INSNS];
+	enum {
+		UNDEF,
+		ACCEPT,
+		REJECT
+	} result;
+	enum bpf_prog_type prog_type;
+	const char *matches[MAX_MATCHES];
+};
+
+static struct bpf_align_test tests[] = {
+	{
+		.descr = "mov",
+		.insns = {
+			BPF_MOV64_IMM(BPF_REG_3, 2),
+			BPF_MOV64_IMM(BPF_REG_3, 4),
+			BPF_MOV64_IMM(BPF_REG_3, 8),
+			BPF_MOV64_IMM(BPF_REG_3, 16),
+			BPF_MOV64_IMM(BPF_REG_3, 32),
+			BPF_MOV64_IMM(BPF_REG_0, 0),
+			BPF_EXIT_INSN(),
+		},
+		.prog_type = BPF_PROG_TYPE_SCHED_CLS,
+		.matches = {
+			"1: R1=ctx R3=imm2,min_value=2,max_value=2,min_align=2 R10=fp",
+			"2: R1=ctx R3=imm4,min_value=4,max_value=4,min_align=4 R10=fp",
+			"3: R1=ctx R3=imm8,min_value=8,max_value=8,min_align=8 R10=fp",
+			"4: R1=ctx R3=imm16,min_value=16,max_value=16,min_align=16 R10=fp",
+			"5: R1=ctx R3=imm32,min_value=32,max_value=32,min_align=32 R10=fp",
+		},
+	},
+	{
+		.descr = "shift",
+		.insns = {
+			BPF_MOV64_IMM(BPF_REG_3, 1),
+			BPF_ALU64_IMM(BPF_LSH, BPF_REG_3, 1),
+			BPF_ALU64_IMM(BPF_LSH, BPF_REG_3, 1),
+			BPF_ALU64_IMM(BPF_LSH, BPF_REG_3, 1),
+			BPF_ALU64_IMM(BPF_LSH, BPF_REG_3, 1),
+			BPF_ALU64_IMM(BPF_RSH, BPF_REG_3, 4),
+			BPF_MOV64_IMM(BPF_REG_4, 32),
+			BPF_ALU64_IMM(BPF_RSH, BPF_REG_4, 1),
+			BPF_ALU64_IMM(BPF_RSH, BPF_REG_4, 1),
+			BPF_ALU64_IMM(BPF_RSH, BPF_REG_4, 1),
+			BPF_ALU64_IMM(BPF_RSH, BPF_REG_4, 1),
+			BPF_MOV64_IMM(BPF_REG_0, 0),
+			BPF_EXIT_INSN(),
+		},
+		.prog_type = BPF_PROG_TYPE_SCHED_CLS,
+		.matches = {
+			"1: R1=ctx R3=imm1,min_value=1,max_value=1,min_align=1 R10=fp",
+			"2: R1=ctx R3=imm2,min_value=2,max_value=2,min_align=2 R10=fp",
+			"3: R1=ctx R3=imm4,min_value=4,max_value=4,min_align=4 R10=fp",
+			"4: R1=ctx R3=imm8,min_value=8,max_value=8,min_align=8 R10=fp",
+			"5: R1=ctx R3=imm16,min_value=16,max_value=16,min_align=16 R10=fp",
+			"6: R1=ctx R3=imm1,min_value=1,max_value=1,min_align=1 R10=fp",
+			"7: R1=ctx R3=imm1,min_value=1,max_value=1,min_align=1 R4=imm32,min_value=32,max_value=32,min_align=32 R10=fp",
+			"8: R1=ctx R3=imm1,min_value=1,max_value=1,min_align=1 R4=imm16,min_value=16,max_value=16,min_align=16 R10=fp",
+			"9: R1=ctx R3=imm1,min_value=1,max_value=1,min_align=1 R4=imm8,min_value=8,max_value=8,min_align=8 R10=fp",
+			"10: R1=ctx R3=imm1,min_value=1,max_value=1,min_align=1 R4=imm4,min_value=4,max_value=4,min_align=4 R10=fp",
+			"11: R1=ctx R3=imm1,min_value=1,max_value=1,min_align=1 R4=imm2,min_value=2,max_value=2,min_align=2 R10=fp",
+		},
+	},
+	{
+		.descr = "addsub",
+		.insns = {
+			BPF_MOV64_IMM(BPF_REG_3, 4),
+			BPF_ALU64_IMM(BPF_ADD, BPF_REG_3, 4),
+			BPF_ALU64_IMM(BPF_ADD, BPF_REG_3, 2),
+			BPF_MOV64_IMM(BPF_REG_4, 8),
+			BPF_ALU64_IMM(BPF_ADD, BPF_REG_4, 4),
+			BPF_ALU64_IMM(BPF_ADD, BPF_REG_4, 2),
+			BPF_MOV64_IMM(BPF_REG_0, 0),
+			BPF_EXIT_INSN(),
+		},
+		.prog_type = BPF_PROG_TYPE_SCHED_CLS,
+		.matches = {
+			"1: R1=ctx R3=imm4,min_value=4,max_value=4,min_align=4 R10=fp",
+			"2: R1=ctx R3=imm8,min_value=8,max_value=8,min_align=4 R10=fp",
+			"3: R1=ctx R3=imm10,min_value=10,max_value=10,min_align=2 R10=fp",
+			"4: R1=ctx R3=imm10,min_value=10,max_value=10,min_align=2 R4=imm8,min_value=8,max_value=8,min_align=8 R10=fp",
+			"5: R1=ctx R3=imm10,min_value=10,max_value=10,min_align=2 R4=imm12,min_value=12,max_value=12,min_align=4 R10=fp",
+			"6: R1=ctx R3=imm10,min_value=10,max_value=10,min_align=2 R4=imm14,min_value=14,max_value=14,min_align=2 R10=fp",
+		},
+	},
+	{
+		.descr = "mul",
+		.insns = {
+			BPF_MOV64_IMM(BPF_REG_3, 7),
+			BPF_ALU64_IMM(BPF_MUL, BPF_REG_3, 1),
+			BPF_ALU64_IMM(BPF_MUL, BPF_REG_3, 2),
+			BPF_ALU64_IMM(BPF_MUL, BPF_REG_3, 4),
+			BPF_MOV64_IMM(BPF_REG_0, 0),
+			BPF_EXIT_INSN(),
+		},
+		.prog_type = BPF_PROG_TYPE_SCHED_CLS,
+		.matches = {
+			"1: R1=ctx R3=imm7,min_value=7,max_value=7,min_align=1 R10=fp",
+			"2: R1=ctx R3=imm7,min_value=7,max_value=7,min_align=1 R10=fp",
+			"3: R1=ctx R3=imm14,min_value=14,max_value=14,min_align=2 R10=fp",
+			"4: R1=ctx R3=imm56,min_value=56,max_value=56,min_align=4 R10=fp",
+		},
+	},
+
+#define PREP_PKT_POINTERS \
+	BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1, \
+		    offsetof(struct __sk_buff, data)), \
+	BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1, \
+		    offsetof(struct __sk_buff, data_end))
+
+#define LOAD_UNKNOWN(DST_REG) \
+	PREP_PKT_POINTERS, \
+	BPF_MOV64_REG(BPF_REG_0, BPF_REG_2), \
+	BPF_ALU64_IMM(BPF_ADD, BPF_REG_0, 8), \
+	BPF_JMP_REG(BPF_JGE, BPF_REG_3, BPF_REG_0, 1), \
+	BPF_EXIT_INSN(), \
+	BPF_LDX_MEM(BPF_B, DST_REG, BPF_REG_2, 0)
+
+	{
+		.descr = "unknown shift",
+		.insns = {
+			LOAD_UNKNOWN(BPF_REG_3),
+			BPF_ALU64_IMM(BPF_LSH, BPF_REG_3, 1),
+			BPF_ALU64_IMM(BPF_LSH, BPF_REG_3, 1),
+			BPF_ALU64_IMM(BPF_LSH, BPF_REG_3, 1),
+			BPF_ALU64_IMM(BPF_LSH, BPF_REG_3, 1),
+			LOAD_UNKNOWN(BPF_REG_4),
+			BPF_ALU64_IMM(BPF_LSH, BPF_REG_4, 5),
+			BPF_ALU64_IMM(BPF_RSH, BPF_REG_4, 1),
+			BPF_ALU64_IMM(BPF_RSH, BPF_REG_4, 1),
+			BPF_ALU64_IMM(BPF_RSH, BPF_REG_4, 1),
+			BPF_ALU64_IMM(BPF_RSH, BPF_REG_4, 1),
+			BPF_MOV64_IMM(BPF_REG_0, 0),
+			BPF_EXIT_INSN(),
+		},
+		.prog_type = BPF_PROG_TYPE_SCHED_CLS,
+		.matches = {
+			"7: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=inv56 R10=fp",
+			"8: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=inv55,min_align=2 R10=fp",
+			"9: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=inv54,min_align=4 R10=fp",
+			"10: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=inv53,min_align=8 R10=fp",
+			"11: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=inv52,min_align=16 R10=fp",
+			"18: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=pkt_end R4=inv56 R10=fp",
+			"19: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=pkt_end R4=inv51,min_align=32 R10=fp",
+			"20: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=pkt_end R4=inv52,min_align=16 R10=fp",
+			"21: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=pkt_end R4=inv53,min_align=8 R10=fp",
+			"22: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=pkt_end R4=inv54,min_align=4 R10=fp",
+			"23: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=pkt_end R4=inv55,min_align=2 R10=fp",
+		},
+	},
+	{
+		.descr = "unknown mul",
+		.insns = {
+			LOAD_UNKNOWN(BPF_REG_3),
+			BPF_MOV64_REG(BPF_REG_4, BPF_REG_3),
+			BPF_ALU64_IMM(BPF_MUL, BPF_REG_4, 1),
+			BPF_MOV64_REG(BPF_REG_4, BPF_REG_3),
+			BPF_ALU64_IMM(BPF_MUL, BPF_REG_4, 2),
+			BPF_MOV64_REG(BPF_REG_4, BPF_REG_3),
+			BPF_ALU64_IMM(BPF_MUL, BPF_REG_4, 4),
+			BPF_MOV64_REG(BPF_REG_4, BPF_REG_3),
+			BPF_ALU64_IMM(BPF_MUL, BPF_REG_4, 8),
+			BPF_ALU64_IMM(BPF_MUL, BPF_REG_4, 2),
+			BPF_MOV64_IMM(BPF_REG_0, 0),
+			BPF_EXIT_INSN(),
+		},
+		.prog_type = BPF_PROG_TYPE_SCHED_CLS,
+		.matches = {
+			"7: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=inv56 R10=fp",
+			"8: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=inv56 R4=inv56 R10=fp",
+			"9: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=inv56 R4=inv55,min_align=1 R10=fp",
+			"10: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=inv56 R4=inv56 R10=fp",
+			"11: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=inv56 R4=inv54,min_align=2 R10=fp",
+			"12: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=inv56 R4=inv56 R10=fp",
+			"13: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=inv56 R4=inv53,min_align=4 R10=fp",
+			"14: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=inv56 R4=inv56 R10=fp",
+			"15: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=inv56 R4=inv52,min_align=8 R10=fp",
+			"16: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=inv56 R4=inv50,min_align=8 R10=fp"
+		},
+	},
+	{
+		.descr = "packet const offset",
+		.insns = {
+			PREP_PKT_POINTERS,
+			BPF_MOV64_REG(BPF_REG_5, BPF_REG_2),
+
+			BPF_MOV64_IMM(BPF_REG_0, 0),
+
+			/* Skip over ethernet header.  */
+			BPF_ALU64_IMM(BPF_ADD, BPF_REG_5, 14),
+			BPF_MOV64_REG(BPF_REG_4, BPF_REG_5),
+			BPF_ALU64_IMM(BPF_ADD, BPF_REG_4, 4),
+			BPF_JMP_REG(BPF_JGE, BPF_REG_3, BPF_REG_4, 1),
+			BPF_EXIT_INSN(),
+
+			BPF_LDX_MEM(BPF_B, BPF_REG_4, BPF_REG_5, 0),
+			BPF_LDX_MEM(BPF_B, BPF_REG_4, BPF_REG_5, 1),
+			BPF_LDX_MEM(BPF_B, BPF_REG_4, BPF_REG_5, 2),
+			BPF_LDX_MEM(BPF_B, BPF_REG_4, BPF_REG_5, 3),
+			BPF_LDX_MEM(BPF_H, BPF_REG_4, BPF_REG_5, 0),
+			BPF_LDX_MEM(BPF_H, BPF_REG_4, BPF_REG_5, 2),
+			BPF_LDX_MEM(BPF_W, BPF_REG_4, BPF_REG_5, 0),
+
+			BPF_MOV64_IMM(BPF_REG_0, 0),
+			BPF_EXIT_INSN(),
+		},
+		.prog_type = BPF_PROG_TYPE_SCHED_CLS,
+		.matches = {
+			"4: R0=imm0,min_value=0,max_value=0,min_align=2147483648 R1=ctx R2=pkt(id=0,off=0,r=0) R3=pkt_end R5=pkt(id=0,off=0,r=0) R10=fp",
+			"5: R0=imm0,min_value=0,max_value=0,min_align=2147483648 R1=ctx R2=pkt(id=0,off=0,r=0) R3=pkt_end R5=pkt(id=0,off=14,r=0) R10=fp",
+			"6: R0=imm0,min_value=0,max_value=0,min_align=2147483648 R1=ctx R2=pkt(id=0,off=0,r=0) R3=pkt_end R4=pkt(id=0,off=14,r=0) R5=pkt(id=0,off=14,r=0) R10=fp",
+			"10: R0=imm0,min_value=0,max_value=0,min_align=2147483648 R1=ctx R2=pkt(id=0,off=0,r=18) R3=pkt_end R4=inv56 R5=pkt(id=0,off=14,r=18) R10=fp",
+			"14: R0=imm0,min_value=0,max_value=0,min_align=2147483648 R1=ctx R2=pkt(id=0,off=0,r=18) R3=pkt_end R4=inv48 R5=pkt(id=0,off=14,r=18) R10=fp",
+			"15: R0=imm0,min_value=0,max_value=0,min_align=2147483648 R1=ctx R2=pkt(id=0,off=0,r=18) R3=pkt_end R4=inv48 R5=pkt(id=0,off=14,r=18) R10=fp",
+		},
+	},
+	{
+		.descr = "packet variable offset",
+		.insns = {
+			LOAD_UNKNOWN(BPF_REG_6),
+			BPF_ALU64_IMM(BPF_LSH, BPF_REG_6, 2),
+
+			/* First, add a constant to the R5 packet pointer,
+			 * then a variable with a known alignment.
+			 */
+			BPF_MOV64_REG(BPF_REG_5, BPF_REG_2),
+			BPF_ALU64_IMM(BPF_ADD, BPF_REG_5, 14),
+			BPF_ALU64_REG(BPF_ADD, BPF_REG_5, BPF_REG_6),
+			BPF_MOV64_REG(BPF_REG_4, BPF_REG_5),
+			BPF_ALU64_IMM(BPF_ADD, BPF_REG_4, 4),
+			BPF_JMP_REG(BPF_JGE, BPF_REG_3, BPF_REG_4, 1),
+			BPF_EXIT_INSN(),
+			BPF_LDX_MEM(BPF_W, BPF_REG_4, BPF_REG_5, 0),
+
+			/* Now, test in the other direction.  Adding first
+			 * the variable offset to R5, then the constant.
+			 */
+			BPF_MOV64_REG(BPF_REG_5, BPF_REG_2),
+			BPF_ALU64_REG(BPF_ADD, BPF_REG_5, BPF_REG_6),
+			BPF_ALU64_IMM(BPF_ADD, BPF_REG_5, 14),
+			BPF_MOV64_REG(BPF_REG_4, BPF_REG_5),
+			BPF_ALU64_IMM(BPF_ADD, BPF_REG_4, 4),
+			BPF_JMP_REG(BPF_JGE, BPF_REG_3, BPF_REG_4, 1),
+			BPF_EXIT_INSN(),
+			BPF_LDX_MEM(BPF_W, BPF_REG_4, BPF_REG_5, 0),
+
+			BPF_MOV64_IMM(BPF_REG_0, 0),
+			BPF_EXIT_INSN(),
+		},
+		.prog_type = BPF_PROG_TYPE_SCHED_CLS,
+		.matches = {
+			/* Calculated offset in R6 has unknown value, but known
+			 * alignment of 4.
+			 */
+			"8: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=pkt_end R6=inv54,min_align=4 R10=fp",
+
+			/* Offset is added to packet pointer R5, resulting in known
+			 * auxiliary alignment and offset.
+			 */
+			"11: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=pkt_end R5=pkt(id=1,off=0,r=0),aux_off=14,aux_off_align=4 R6=inv54,min_align=4 R10=fp",
+
+			/* At the time the word size load is performed from R5,
+			 * it's total offset is NET_IP_ALIGN + reg->off (0) +
+			 * reg->aux_off (14) which is 16.  Then the variable
+			 * offset is considered using reg->aux_off_align which
+			 * is 4 and meets the load's requirements.
+			 */
+			"15: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=pkt_end R4=pkt(id=1,off=4,r=4),aux_off=14,aux_off_align=4 R5=pkt(id=1,off=0,r=4),aux_off=14,aux_off_align=4 R6=inv54,min_align=4 R10=fp",
+
+
+			/* Variable offset is added to R5 packet pointer,
+			 * resulting in auxiliary alignment of 4.
+			 */
+			"18: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=pkt_end R4=inv,aux_off=14,aux_off_align=4 R5=pkt(id=2,off=0,r=0),aux_off_align=4 R6=inv54,min_align=4 R10=fp",
+
+			/* Constant offset is added to R5, resulting in
+			 * reg->off of 14.
+			 */
+			"19: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=pkt_end R4=inv,aux_off=14,aux_off_align=4 R5=pkt(id=2,off=14,r=0),aux_off_align=4 R6=inv54,min_align=4 R10=fp",
+
+			/* At the time the word size load is performed from R5,
+			 * it's total offset is NET_IP_ALIGN + reg->off (14) which
+			 * is 16.  Then the variable offset is considered using
+			 * reg->aux_off_align which is 4 and meets the load's
+			 * requirements.
+			 */
+			"23: R0=pkt(id=0,off=8,r=8) R1=ctx R2=pkt(id=0,off=0,r=8) R3=pkt_end R4=pkt(id=2,off=18,r=18),aux_off_align=4 R5=pkt(id=2,off=14,r=18),aux_off_align=4 R6=inv54,min_align=4 R10=fp",
+		},
+	},
+};
+
+static int probe_filter_length(const struct bpf_insn *fp)
+{
+	int len;
+
+	for (len = MAX_INSNS - 1; len > 0; --len)
+		if (fp[len].code != 0 || fp[len].imm != 0)
+			break;
+	return len + 1;
+}
+
+static char bpf_vlog[32768];
+
+static int do_test_single(struct bpf_align_test *test)
+{
+	struct bpf_insn *prog = test->insns;
+	int prog_type = test->prog_type;
+	int prog_len, i;
+	int fd_prog;
+	int ret;
+
+	prog_len = probe_filter_length(prog);
+	fd_prog = bpf_verify_program(prog_type ? : BPF_PROG_TYPE_SOCKET_FILTER,
+				     prog, prog_len, 1, "GPL", 0,
+				     bpf_vlog, sizeof(bpf_vlog));
+	if (fd_prog < 0) {
+		printf("Failed to load program.\n");
+		printf("%s", bpf_vlog);
+		ret = 1;
+	} else {
+		ret = 0;
+		for (i = 0; i < MAX_MATCHES; i++) {
+			const char *t, *m = test->matches[i];
+
+			if (!m)
+				break;
+			t = strstr(bpf_vlog, m);
+			if (!t) {
+				printf("Failed to find match: %s\n", m);
+				ret = 1;
+				printf("%s", bpf_vlog);
+				break;
+			}
+		}
+		/* printf("%s", bpf_vlog); */
+		close(fd_prog);
+	}
+	return ret;
+}
+
+static int do_test(unsigned int from, unsigned int to)
+{
+	int all_pass = 0;
+	int all_fail = 0;
+	unsigned int i;
+
+	for (i = from; i < to; i++) {
+		struct bpf_align_test *test = &tests[i];
+		int fail;
+
+		printf("Test %3d: %s ... ",
+		       i, test->descr);
+		fail = do_test_single(test);
+		if (fail) {
+			all_fail++;
+			printf("FAIL\n");
+		} else {
+			all_pass++;
+			printf("PASS\n");
+		}
+	}
+	printf("Results: %d pass %d fail\n",
+	       all_pass, all_fail);
+	return 0;
+}
+
+int main(int argc, char **argv)
+{
+	unsigned int from = 0, to = ARRAY_SIZE(tests);
+
+	if (argc == 3) {
+		unsigned int l = atoi(argv[argc - 2]);
+		unsigned int u = atoi(argv[argc - 1]);
+
+		if (l < to && u < to) {
+			from = l;
+			to   = u + 1;
+		}
+	} else if (argc == 2) {
+		unsigned int t = atoi(argv[argc - 1]);
+
+		if (t < to) {
+			from = t;
+			to   = t + 1;
+		}
+	}
+	return do_test(from, to);
+}
-- 
2.7.4

^ permalink raw reply related

* [PATCH v2 6/7] bpf: Make use of alignment information in check_val_ptr_alignment().
From: David Miller @ 2017-05-11 16:06 UTC (permalink / raw)
  To: daniel; +Cc: ast, alexei.starovoitov, netdev


We can validate PTR_TO_MAP_VALUE_ADJ accesses in the same way that we
do for PTR_TO_PACKET.  The only difference is that we don't plug
NET_IP_ALIGN into the equation.

Signed-off-by: David S. Miller <davem@davemloft.net>
---
 kernel/bpf/verifier.c | 25 +++++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index e74fb1b..cdbf282 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -823,10 +823,27 @@ static int check_pkt_ptr_alignment(const struct bpf_reg_state *reg,
 }
 
 static int check_val_ptr_alignment(const struct bpf_reg_state *reg,
-				   int size, bool strict)
+				   int off, int size, bool strict)
 {
-	if (strict && size != 1) {
-		verbose("Unknown alignment. Only byte-sized access allowed in value access.\n");
+	int reg_off;
+
+	/* Byte size accesses are always allowed. */
+	if (!strict || size == 1)
+		return 0;
+
+	reg_off = reg->off;
+	if (reg->id) {
+		if (reg->aux_off_align % size) {
+			verbose("Value access is only %u byte aligned, %d byte access not allowed\n",
+				reg->aux_off_align, size);
+			return -EACCES;
+		}
+		reg_off += reg->aux_off;
+	}
+
+	if ((reg_off + off) % size != 0) {
+		verbose("misaligned value access off %d+%d size %d\n",
+			reg_off, off, size);
 		return -EACCES;
 	}
 
@@ -846,7 +863,7 @@ static int check_ptr_alignment(struct bpf_verifier_env *env,
 	case PTR_TO_PACKET:
 		return check_pkt_ptr_alignment(reg, off, size, strict);
 	case PTR_TO_MAP_VALUE_ADJ:
-		return check_val_ptr_alignment(reg, size, strict);
+		return check_val_ptr_alignment(reg, off, size, strict);
 	default:
 		if (off % size != 0) {
 			verbose("misaligned access off %d size %d\n",
-- 
2.1.2.532.g19b5d50

^ permalink raw reply related

* [PATCH v2 4/7] bpf: Add bpf_verify_program() to the library.
From: David Miller @ 2017-05-11 16:05 UTC (permalink / raw)
  To: daniel; +Cc: ast, alexei.starovoitov, netdev


This allows a test case to load a BPF program and unconditionally
acquire the verifier log.

It also allows specification of the strict alignment flag.

Signed-off-by: David S. Miller <davem@davemloft.net>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
---
 tools/lib/bpf/bpf.c | 22 ++++++++++++++++++++++
 tools/lib/bpf/bpf.h |  4 ++++
 2 files changed, 26 insertions(+)

diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c
index 4fe444b80..6e17898 100644
--- a/tools/lib/bpf/bpf.c
+++ b/tools/lib/bpf/bpf.c
@@ -117,6 +117,28 @@ int bpf_load_program(enum bpf_prog_type type, const struct bpf_insn *insns,
 	return sys_bpf(BPF_PROG_LOAD, &attr, sizeof(attr));
 }
 
+int bpf_verify_program(enum bpf_prog_type type, const struct bpf_insn *insns,
+		       size_t insns_cnt, int strict_alignment,
+		       const char *license, __u32 kern_version,
+		       char *log_buf, size_t log_buf_sz)
+{
+	union bpf_attr attr;
+
+	bzero(&attr, sizeof(attr));
+	attr.prog_type = type;
+	attr.insn_cnt = (__u32)insns_cnt;
+	attr.insns = ptr_to_u64(insns);
+	attr.license = ptr_to_u64(license);
+	attr.log_buf = ptr_to_u64(log_buf);
+	attr.log_size = log_buf_sz;
+	attr.log_level = 2;
+	log_buf[0] = 0;
+	attr.kern_version = kern_version;
+	attr.prog_flags = strict_alignment ? BPF_F_STRICT_ALIGNMENT : 0;
+
+	return sys_bpf(BPF_PROG_LOAD, &attr, sizeof(attr));
+}
+
 int bpf_map_update_elem(int fd, const void *key, const void *value,
 			__u64 flags)
 {
diff --git a/tools/lib/bpf/bpf.h b/tools/lib/bpf/bpf.h
index edb4dae..972bd83 100644
--- a/tools/lib/bpf/bpf.h
+++ b/tools/lib/bpf/bpf.h
@@ -35,6 +35,10 @@ int bpf_load_program(enum bpf_prog_type type, const struct bpf_insn *insns,
 		     size_t insns_cnt, const char *license,
 		     __u32 kern_version, char *log_buf,
 		     size_t log_buf_sz);
+int bpf_verify_program(enum bpf_prog_type type, const struct bpf_insn *insns,
+		       size_t insns_cnt, int strict_alignment,
+		       const char *license, __u32 kern_version,
+		       char *log_buf, size_t log_buf_sz);
 
 int bpf_map_update_elem(int fd, const void *key, const void *value,
 			__u64 flags);
-- 
2.7.4

^ permalink raw reply related

* [PATCH v2 3/7] bpf: Add strict alignment flag for BPF_PROG_LOAD.
From: David Miller @ 2017-05-11 16:05 UTC (permalink / raw)
  To: daniel; +Cc: ast, alexei.starovoitov, netdev


Add a new field, "prog_flags", and an initial flag value
BPF_F_STRCIT_ALIGNMENT.

When set, the verifier will enforce strict pointer alignment
regardless of the setting of CONFIG_EFFICIENT_UNALIGNED_ACCESS.

The verifier, in this mode, will also use a fixed value of "2" in
place of NET_IP_ALIGN.

This facilitates test cases that will exercise and validate this part
of the verifier even when run on architectures where alignment doesn't
matter.

Signed-off-by: David S. Miller <davem@davemloft.net>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
---
 include/linux/bpf_verifier.h   |  1 +
 include/uapi/linux/bpf.h       |  8 ++++++++
 kernel/bpf/syscall.c           |  5 ++++-
 kernel/bpf/verifier.c          | 23 +++++++++++++++++------
 tools/build/feature/test-bpf.c |  1 +
 tools/include/uapi/linux/bpf.h | 11 +++++++++--
 6 files changed, 40 insertions(+), 9 deletions(-)

diff --git a/include/linux/bpf_verifier.h b/include/linux/bpf_verifier.h
index 7c6a519..d5093b5 100644
--- a/include/linux/bpf_verifier.h
+++ b/include/linux/bpf_verifier.h
@@ -90,6 +90,7 @@ struct bpf_verifier_env {
 	struct bpf_prog *prog;		/* eBPF program being verified */
 	struct bpf_verifier_stack_elem *head; /* stack of verifier states to be processed */
 	int stack_size;			/* number of states to be processed */
+	bool strict_alignment;		/* perform strict pointer alignment checks */
 	struct bpf_verifier_state cur_state; /* current verifier state */
 	struct bpf_verifier_state_list **explored_states; /* search pruning optimization */
 	const struct bpf_ext_analyzer_ops *analyzer_ops; /* external analyzer ops */
diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
index 945a1f5..94dfa9d 100644
--- a/include/uapi/linux/bpf.h
+++ b/include/uapi/linux/bpf.h
@@ -132,6 +132,13 @@ enum bpf_attach_type {
  */
 #define BPF_F_ALLOW_OVERRIDE	(1U << 0)
 
+/* If BPF_F_STRICT_ALIGNMENT is used in BPF_PROG_LOAD command, the
+ * verifier will perform strict alignment checking as if the kernel
+ * has been built with CONFIG_EFFICIENT_UNALIGNED_ACCESS not set,
+ * and NET_IP_ALIGN defined to 2.
+ */
+#define BPF_F_STRICT_ALIGNMENT	(1U << 0)
+
 #define BPF_PSEUDO_MAP_FD	1
 
 /* flags for BPF_MAP_UPDATE_ELEM command */
@@ -177,6 +184,7 @@ union bpf_attr {
 		__u32		log_size;	/* size of user buffer */
 		__aligned_u64	log_buf;	/* user supplied buffer */
 		__u32		kern_version;	/* checked when prog_type=kprobe */
+		__u32		prog_flags;
 	};
 
 	struct { /* anonymous struct used by BPF_OBJ_* commands */
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index fd2411f..265a0d8 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -783,7 +783,7 @@ struct bpf_prog *bpf_prog_get_type(u32 ufd, enum bpf_prog_type type)
 EXPORT_SYMBOL_GPL(bpf_prog_get_type);
 
 /* last field in 'union bpf_attr' used by this command */
-#define	BPF_PROG_LOAD_LAST_FIELD kern_version
+#define	BPF_PROG_LOAD_LAST_FIELD prog_flags
 
 static int bpf_prog_load(union bpf_attr *attr)
 {
@@ -796,6 +796,9 @@ static int bpf_prog_load(union bpf_attr *attr)
 	if (CHECK_ATTR(BPF_PROG_LOAD))
 		return -EINVAL;
 
+	if (attr->prog_flags & ~BPF_F_STRICT_ALIGNMENT)
+		return -EINVAL;
+
 	/* copy eBPF program license from user space */
 	if (strncpy_from_user(license, u64_to_user_ptr(attr->license),
 			      sizeof(license) - 1) < 0)
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index ff2bfe1..e74fb1b 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -791,6 +791,7 @@ static bool is_pointer_value(struct bpf_verifier_env *env, int regno)
 static int check_pkt_ptr_alignment(const struct bpf_reg_state *reg,
 				   int off, int size, bool strict)
 {
+	int ip_align;
 	int reg_off;
 
 	/* Byte size accesses are always allowed. */
@@ -807,10 +808,14 @@ static int check_pkt_ptr_alignment(const struct bpf_reg_state *reg,
 		reg_off += reg->aux_off;
 	}
 
-	/* skb->data is NET_IP_ALIGN-ed */
-	if ((NET_IP_ALIGN + reg_off + off) % size != 0) {
+	/* skb->data is NET_IP_ALIGN-ed, but for strict alignment checking
+	 * we force this to 2 which is universally what architectures use
+	 * when they don't set CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS.
+	 */
+	ip_align = strict ? 2 : NET_IP_ALIGN;
+	if ((ip_align + reg_off + off) % size != 0) {
 		verbose("misaligned packet access off %d+%d+%d size %d\n",
-			NET_IP_ALIGN, reg_off, off, size);
+			ip_align, reg_off, off, size);
 		return -EACCES;
 	}
 
@@ -828,10 +833,11 @@ static int check_val_ptr_alignment(const struct bpf_reg_state *reg,
 	return 0;
 }
 
-static int check_ptr_alignment(const struct bpf_reg_state *reg,
+static int check_ptr_alignment(struct bpf_verifier_env *env,
+			       const struct bpf_reg_state *reg,
 			       int off, int size)
 {
-	bool strict = false;
+	bool strict = env->strict_alignment;
 
 	if (!IS_ENABLED(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS))
 		strict = true;
@@ -873,7 +879,7 @@ static int check_mem_access(struct bpf_verifier_env *env, u32 regno, int off,
 	if (size < 0)
 		return size;
 
-	err = check_ptr_alignment(reg, off, size);
+	err = check_ptr_alignment(env, reg, off, size);
 	if (err)
 		return err;
 
@@ -3568,6 +3574,10 @@ int bpf_check(struct bpf_prog **prog, union bpf_attr *attr)
 	} else {
 		log_level = 0;
 	}
+	if (attr->prog_flags & BPF_F_STRICT_ALIGNMENT)
+		env->strict_alignment = true;
+	else
+		env->strict_alignment = false;
 
 	ret = replace_map_fd_with_map_ptr(env);
 	if (ret < 0)
@@ -3673,6 +3683,7 @@ int bpf_analyzer(struct bpf_prog *prog, const struct bpf_ext_analyzer_ops *ops,
 	mutex_lock(&bpf_verifier_lock);
 
 	log_level = 0;
+	env->strict_alignment = false;
 
 	env->explored_states = kcalloc(env->prog->len,
 				       sizeof(struct bpf_verifier_state_list *),
diff --git a/tools/build/feature/test-bpf.c b/tools/build/feature/test-bpf.c
index ebc6dce..7598361 100644
--- a/tools/build/feature/test-bpf.c
+++ b/tools/build/feature/test-bpf.c
@@ -29,6 +29,7 @@ int main(void)
 	attr.log_size = 0;
 	attr.log_level = 0;
 	attr.kern_version = 0;
+	attr.prog_flags = 0;
 
 	/*
 	 * Test existence of __NR_bpf and BPF_PROG_LOAD.
diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
index e553529..94dfa9d 100644
--- a/tools/include/uapi/linux/bpf.h
+++ b/tools/include/uapi/linux/bpf.h
@@ -132,6 +132,13 @@ enum bpf_attach_type {
  */
 #define BPF_F_ALLOW_OVERRIDE	(1U << 0)
 
+/* If BPF_F_STRICT_ALIGNMENT is used in BPF_PROG_LOAD command, the
+ * verifier will perform strict alignment checking as if the kernel
+ * has been built with CONFIG_EFFICIENT_UNALIGNED_ACCESS not set,
+ * and NET_IP_ALIGN defined to 2.
+ */
+#define BPF_F_STRICT_ALIGNMENT	(1U << 0)
+
 #define BPF_PSEUDO_MAP_FD	1
 
 /* flags for BPF_MAP_UPDATE_ELEM command */
@@ -177,6 +184,7 @@ union bpf_attr {
 		__u32		log_size;	/* size of user buffer */
 		__aligned_u64	log_buf;	/* user supplied buffer */
 		__u32		kern_version;	/* checked when prog_type=kprobe */
+		__u32		prog_flags;
 	};
 
 	struct { /* anonymous struct used by BPF_OBJ_* commands */
@@ -481,8 +489,7 @@ union bpf_attr {
  * u32 bpf_get_socket_uid(skb)
  *     Get the owner uid of the socket stored inside sk_buff.
  *     @skb: pointer to skb
- *     Return: uid of the socket owner on success or 0 if the socket pointer
- *     inside sk_buff is NULL
+ *     Return: uid of the socket owner on success or overflowuid if failed.
  */
 #define __BPF_FUNC_MAPPER(FN)		\
 	FN(unspec),			\
-- 
2.7.4

^ permalink raw reply related

* [PATCH v2 2/7] bpf: Do per-instruction state dumping in verifier when log_level > 1.
From: David Miller @ 2017-05-11 16:05 UTC (permalink / raw)
  To: daniel; +Cc: ast, alexei.starovoitov, netdev


If log_level > 1, do a state dump every instruction and emit it in
a more compact way (without a leading newline).

This will facilitate more sophisticated test cases which inspect the
verifier log for register state.

Signed-off-by: David S. Miller <davem@davemloft.net>
---
 kernel/bpf/verifier.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index cc7b626..ff2bfe1 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -2926,8 +2926,12 @@ static int do_check(struct bpf_verifier_env *env)
 			goto process_bpf_exit;
 		}
 
-		if (log_level && do_print_state) {
-			verbose("\nfrom %d to %d:", prev_insn_idx, insn_idx);
+		if (log_level > 1 || (log_level && do_print_state)) {
+			if (log_level > 1)
+				verbose("%d:", insn_idx);
+			else
+				verbose("\nfrom %d to %d:",
+					prev_insn_idx, insn_idx);
 			print_verifier_state(&env->cur_state);
 			do_print_state = false;
 		}
-- 
2.7.4

^ permalink raw reply related

* [PATCH v2 1/7] bpf: Track alignment of register values in the verifier.
From: David Miller @ 2017-05-11 16:05 UTC (permalink / raw)
  To: daniel; +Cc: ast, alexei.starovoitov, netdev


Currently if we add only constant values to pointers we can fully
validate the alignment, and properly check if we need to reject the
program on !CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS architectures.

However, once an unknown value is introduced we only allow byte sized
memory accesses which is too restrictive.

Add logic to track the known minimum alignment of register values,
and propagate this state into registers containing pointers.

The most common paradigm that makes use of this new logic is computing
the transport header using the IP header length field.  For example:

	struct ethhdr *ep = skb->data;
	struct iphdr *iph = (struct iphdr *) (ep + 1);
	struct tcphdr *th;
 ...
	n = iph->ihl;
	th = ((void *)iph + (n * 4));
	port = th->dest;

The existing code will reject the load of th->dest because it cannot
validate that the alignment is at least 2 once "n * 4" is added the
the packet pointer.

In the new code, the register holding "n * 4" will have a reg->min_align
value of 4, because any value multiplied by 4 will be at least 4 byte
aligned.  (actually, the eBPF code emitted by the compiler in this case
is most likely to use a shift left by 2, but the end result is identical)

At the critical addition:

	th = ((void *)iph + (n * 4));

The register holding 'th' will start with reg->off value of 14.  The
pointer addition will transform that reg into something that looks like:

	reg->aux_off = 14
	reg->aux_off_align = 4

Next, the verifier will look at the th->dest load, and it will see
a load offset of 2, and first check:

	if (reg->aux_off_align % size)

which will pass because aux_off_align is 4.  reg_off will be computed:

	reg_off = reg->off;
 ...
		reg_off += reg->aux_off;

plus we have off==2, and it will thus check:

	if ((NET_IP_ALIGN + reg_off + off) % size != 0)

which evaluates to:

	if ((NET_IP_ALIGN + 14 + 2) % size != 0)

On strict alignment architectures, NET_IP_ALIGN is 2, thus:

	if ((2 + 14 + 2) % size != 0)

which passes.

These pointer transformations and checks work regardless of whether
the constant offset or the variable with known alignment is added
first to the pointer register.

Signed-off-by: David S. Miller <davem@davemloft.net>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
---
 include/linux/bpf_verifier.h |   3 ++
 kernel/bpf/verifier.c        | 108 +++++++++++++++++++++++++++++++++++--------
 2 files changed, 92 insertions(+), 19 deletions(-)

diff --git a/include/linux/bpf_verifier.h b/include/linux/bpf_verifier.h
index 5efb4db..7c6a519 100644
--- a/include/linux/bpf_verifier.h
+++ b/include/linux/bpf_verifier.h
@@ -40,6 +40,9 @@ struct bpf_reg_state {
 	 */
 	s64 min_value;
 	u64 max_value;
+	u32 min_align;
+	u32 aux_off;
+	u32 aux_off_align;
 };
 
 enum bpf_stack_slot_type {
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index c5b56c9..cc7b626 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -241,6 +241,12 @@ static void print_verifier_state(struct bpf_verifier_state *state)
 		if (reg->max_value != BPF_REGISTER_MAX_RANGE)
 			verbose(",max_value=%llu",
 				(unsigned long long)reg->max_value);
+		if (reg->min_align)
+			verbose(",min_align=%u", reg->min_align);
+		if (reg->aux_off)
+			verbose(",aux_off=%u", reg->aux_off);
+		if (reg->aux_off_align)
+			verbose(",aux_off_align=%u", reg->aux_off_align);
 	}
 	for (i = 0; i < MAX_BPF_STACK; i += BPF_REG_SIZE) {
 		if (state->stack_slot_type[i] == STACK_SPILL)
@@ -466,6 +472,9 @@ static void init_reg_state(struct bpf_reg_state *regs)
 		regs[i].imm = 0;
 		regs[i].min_value = BPF_REGISTER_MIN_RANGE;
 		regs[i].max_value = BPF_REGISTER_MAX_RANGE;
+		regs[i].min_align = 0;
+		regs[i].aux_off = 0;
+		regs[i].aux_off_align = 0;
 	}
 
 	/* frame pointer */
@@ -492,6 +501,7 @@ static void reset_reg_range_values(struct bpf_reg_state *regs, u32 regno)
 {
 	regs[regno].min_value = BPF_REGISTER_MIN_RANGE;
 	regs[regno].max_value = BPF_REGISTER_MAX_RANGE;
+	regs[regno].min_align = 0;
 }
 
 static void mark_reg_unknown_value_and_range(struct bpf_reg_state *regs,
@@ -779,17 +789,28 @@ static bool is_pointer_value(struct bpf_verifier_env *env, int regno)
 }
 
 static int check_pkt_ptr_alignment(const struct bpf_reg_state *reg,
-				   int off, int size)
+				   int off, int size, bool strict)
 {
-	if (reg->id && size != 1) {
-		verbose("Unknown alignment. Only byte-sized access allowed in packet access.\n");
-		return -EACCES;
+	int reg_off;
+
+	/* Byte size accesses are always allowed. */
+	if (!strict || size == 1)
+		return 0;
+
+	reg_off = reg->off;
+	if (reg->id) {
+		if (reg->aux_off_align % size) {
+			verbose("Packet access is only %u byte aligned, %d byte access not allowed\n",
+				reg->aux_off_align, size);
+			return -EACCES;
+		}
+		reg_off += reg->aux_off;
 	}
 
 	/* skb->data is NET_IP_ALIGN-ed */
-	if ((NET_IP_ALIGN + reg->off + off) % size != 0) {
+	if ((NET_IP_ALIGN + reg_off + off) % size != 0) {
 		verbose("misaligned packet access off %d+%d+%d size %d\n",
-			NET_IP_ALIGN, reg->off, off, size);
+			NET_IP_ALIGN, reg_off, off, size);
 		return -EACCES;
 	}
 
@@ -797,9 +818,9 @@ static int check_pkt_ptr_alignment(const struct bpf_reg_state *reg,
 }
 
 static int check_val_ptr_alignment(const struct bpf_reg_state *reg,
-				   int size)
+				   int size, bool strict)
 {
-	if (size != 1) {
+	if (strict && size != 1) {
 		verbose("Unknown alignment. Only byte-sized access allowed in value access.\n");
 		return -EACCES;
 	}
@@ -810,13 +831,16 @@ static int check_val_ptr_alignment(const struct bpf_reg_state *reg,
 static int check_ptr_alignment(const struct bpf_reg_state *reg,
 			       int off, int size)
 {
+	bool strict = false;
+
+	if (!IS_ENABLED(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS))
+		strict = true;
+
 	switch (reg->type) {
 	case PTR_TO_PACKET:
-		return IS_ENABLED(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) ? 0 :
-		       check_pkt_ptr_alignment(reg, off, size);
+		return check_pkt_ptr_alignment(reg, off, size, strict);
 	case PTR_TO_MAP_VALUE_ADJ:
-		return IS_ENABLED(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) ? 0 :
-		       check_val_ptr_alignment(reg, size);
+		return check_val_ptr_alignment(reg, size, strict);
 	default:
 		if (off % size != 0) {
 			verbose("misaligned access off %d size %d\n",
@@ -883,6 +907,8 @@ static int check_mem_access(struct bpf_verifier_env *env, u32 regno, int off,
 							 value_regno);
 			/* note that reg.[id|off|range] == 0 */
 			state->regs[value_regno].type = reg_type;
+			state->regs[value_regno].aux_off = 0;
+			state->regs[value_regno].aux_off_align = 0;
 		}
 
 	} else if (reg->type == FRAME_PTR || reg->type == PTR_TO_STACK) {
@@ -1455,6 +1481,8 @@ static int check_packet_ptr_add(struct bpf_verifier_env *env,
 		 */
 		dst_reg->off += imm;
 	} else {
+		bool had_id;
+
 		if (src_reg->type == PTR_TO_PACKET) {
 			/* R6=pkt(id=0,off=0,r=62) R7=imm22; r7 += r6 */
 			tmp_reg = *dst_reg;  /* save r7 state */
@@ -1488,14 +1516,23 @@ static int check_packet_ptr_add(struct bpf_verifier_env *env,
 				src_reg->imm);
 			return -EACCES;
 		}
+
+		had_id = (dst_reg->id != 0);
+
 		/* dst_reg stays as pkt_ptr type and since some positive
 		 * integer value was added to the pointer, increment its 'id'
 		 */
 		dst_reg->id = ++env->id_gen;
 
-		/* something was added to pkt_ptr, set range and off to zero */
+		/* something was added to pkt_ptr, set range to zero */
+		dst_reg->aux_off = dst_reg->off;
 		dst_reg->off = 0;
 		dst_reg->range = 0;
+		if (had_id)
+			dst_reg->aux_off_align = min(dst_reg->aux_off_align,
+						     src_reg->min_align);
+		else
+			dst_reg->aux_off_align = src_reg->min_align;
 	}
 	return 0;
 }
@@ -1669,6 +1706,13 @@ static void check_reg_overflow(struct bpf_reg_state *reg)
 		reg->min_value = BPF_REGISTER_MIN_RANGE;
 }
 
+static u32 calc_align(u32 imm)
+{
+	if (!imm)
+		return 1U << 31;
+	return imm - ((imm - 1) & imm);
+}
+
 static void adjust_reg_min_max_vals(struct bpf_verifier_env *env,
 				    struct bpf_insn *insn)
 {
@@ -1676,8 +1720,10 @@ static void adjust_reg_min_max_vals(struct bpf_verifier_env *env,
 	s64 min_val = BPF_REGISTER_MIN_RANGE;
 	u64 max_val = BPF_REGISTER_MAX_RANGE;
 	u8 opcode = BPF_OP(insn->code);
+	u32 dst_align, src_align;
 
 	dst_reg = &regs[insn->dst_reg];
+	src_align = 0;
 	if (BPF_SRC(insn->code) == BPF_X) {
 		check_reg_overflow(&regs[insn->src_reg]);
 		min_val = regs[insn->src_reg].min_value;
@@ -1693,12 +1739,18 @@ static void adjust_reg_min_max_vals(struct bpf_verifier_env *env,
 		    regs[insn->src_reg].type != UNKNOWN_VALUE) {
 			min_val = BPF_REGISTER_MIN_RANGE;
 			max_val = BPF_REGISTER_MAX_RANGE;
+			src_align = 0;
+		} else {
+			src_align = regs[insn->src_reg].min_align;
 		}
 	} else if (insn->imm < BPF_REGISTER_MAX_RANGE &&
 		   (s64)insn->imm > BPF_REGISTER_MIN_RANGE) {
 		min_val = max_val = insn->imm;
+		src_align = calc_align(insn->imm);
 	}
 
+	dst_align = dst_reg->min_align;
+
 	/* We don't know anything about what was done to this register, mark it
 	 * as unknown.
 	 */
@@ -1723,18 +1775,21 @@ static void adjust_reg_min_max_vals(struct bpf_verifier_env *env,
 			dst_reg->min_value += min_val;
 		if (dst_reg->max_value != BPF_REGISTER_MAX_RANGE)
 			dst_reg->max_value += max_val;
+		dst_reg->min_align = min(src_align, dst_align);
 		break;
 	case BPF_SUB:
 		if (dst_reg->min_value != BPF_REGISTER_MIN_RANGE)
 			dst_reg->min_value -= min_val;
 		if (dst_reg->max_value != BPF_REGISTER_MAX_RANGE)
 			dst_reg->max_value -= max_val;
+		dst_reg->min_align = min(src_align, dst_align);
 		break;
 	case BPF_MUL:
 		if (dst_reg->min_value != BPF_REGISTER_MIN_RANGE)
 			dst_reg->min_value *= min_val;
 		if (dst_reg->max_value != BPF_REGISTER_MAX_RANGE)
 			dst_reg->max_value *= max_val;
+		dst_reg->min_align = max(src_align, dst_align);
 		break;
 	case BPF_AND:
 		/* Disallow AND'ing of negative numbers, ain't nobody got time
@@ -1746,17 +1801,23 @@ static void adjust_reg_min_max_vals(struct bpf_verifier_env *env,
 		else
 			dst_reg->min_value = 0;
 		dst_reg->max_value = max_val;
+		dst_reg->min_align = max(src_align, dst_align);
 		break;
 	case BPF_LSH:
 		/* Gotta have special overflow logic here, if we're shifting
 		 * more than MAX_RANGE then just assume we have an invalid
 		 * range.
 		 */
-		if (min_val > ilog2(BPF_REGISTER_MAX_RANGE))
+		if (min_val > ilog2(BPF_REGISTER_MAX_RANGE)) {
 			dst_reg->min_value = BPF_REGISTER_MIN_RANGE;
-		else if (dst_reg->min_value != BPF_REGISTER_MIN_RANGE)
-			dst_reg->min_value <<= min_val;
-
+			dst_reg->min_align = 1;
+		} else {
+			if (dst_reg->min_value != BPF_REGISTER_MIN_RANGE)
+				dst_reg->min_value <<= min_val;
+			if (!dst_reg->min_align)
+				dst_reg->min_align = 1;
+			dst_reg->min_align <<= min_val;
+		}
 		if (max_val > ilog2(BPF_REGISTER_MAX_RANGE))
 			dst_reg->max_value = BPF_REGISTER_MAX_RANGE;
 		else if (dst_reg->max_value != BPF_REGISTER_MAX_RANGE)
@@ -1766,11 +1827,19 @@ static void adjust_reg_min_max_vals(struct bpf_verifier_env *env,
 		/* RSH by a negative number is undefined, and the BPF_RSH is an
 		 * unsigned shift, so make the appropriate casts.
 		 */
-		if (min_val < 0 || dst_reg->min_value < 0)
+		if (min_val < 0 || dst_reg->min_value < 0) {
 			dst_reg->min_value = BPF_REGISTER_MIN_RANGE;
-		else
+		} else {
 			dst_reg->min_value =
 				(u64)(dst_reg->min_value) >> min_val;
+		}
+		if (min_val < 0) {
+			dst_reg->min_align = 1;
+		} else {
+			dst_reg->min_align >>= (u64) min_val;
+			if (!dst_reg->min_align)
+				dst_reg->min_align = 1;
+		}
 		if (dst_reg->max_value != BPF_REGISTER_MAX_RANGE)
 			dst_reg->max_value >>= max_val;
 		break;
@@ -1872,6 +1941,7 @@ static int check_alu_op(struct bpf_verifier_env *env, struct bpf_insn *insn)
 			regs[insn->dst_reg].imm = insn->imm;
 			regs[insn->dst_reg].max_value = insn->imm;
 			regs[insn->dst_reg].min_value = insn->imm;
+			regs[insn->dst_reg].min_align = calc_align(insn->imm);
 		}
 
 	} else if (opcode > BPF_END) {
-- 
2.7.4

^ permalink raw reply related

* [PATCH v2 0/7] bpf: Add alignment tracker to verifier.
From: David Miller @ 2017-05-11 16:05 UTC (permalink / raw)
  To: daniel; +Cc: ast, alexei.starovoitov, netdev


First we add the alignment tracking logic to the verifier.

Next, we work on building up infrastructure to facilitate regression
testing of this facility.

Next, we add the "test_align" test case.

Finally, we let the map value pointer checks use the new
infrastructure and adjust test_verifier to match.

Signed-off-by: David S. Miller <davem@davemloft.net>
---

v1 -->v2:
	Adjustments based upon Daniel's feedback
	Add map value and test_verifier changes

^ permalink raw reply

* Re: [PATCH v2 1/2] net: Added mtu parameter to dev_forward_skb calls
From: Stephen Hemminger @ 2017-05-11 16:01 UTC (permalink / raw)
  To: Fredrik Markstrom
  Cc: Eric Dumazet, David S. Miller, Alexei Starovoitov,
	Daniel Borkmann, netdev, linux-kernel, bridge
In-Reply-To: <20170511134629.139528-2-fredrik.markstrom@gmail.com>

On Thu, 11 May 2017 15:46:27 +0200
Fredrik Markstrom <fredrik.markstrom@gmail.com> wrote:

> From: Fredrik Markström <fredrik.markstrom@gmail.com>
> 
> is_skb_forwardable() currently checks if the packet size is <= mtu of
> the receiving interface. This is not consistent with most of the hardware
> ethernet drivers that happily receives packets larger then MTU.

Wrong.

Hardware interfaces are free to drop any packet greater than MTU (actually MTU + VLAN).
The actual limit is a function of the hardware. Some hardware can only limit by
power of 2; some can only limit frames larger than 1500; some have no limiting at all.
Any application that should:
  * not expect packets larger than MTU to be received
  * not send packets larger than MTU
  * check actual receive size. IP protocols will do truncation of padded packets

^ permalink raw reply

* Re: arch: arm: bpf: Converting cBPF to eBPF for arm 32 bit
From: Kees Cook @ 2017-05-11 15:30 UTC (permalink / raw)
  To: Shubham Bansal
  Cc: David Miller, Mircea Gherzan, Network Development,
	kernel-hardening@lists.openwall.com,
	linux-arm-kernel@lists.infradead.org, ast, Daniel Borkmann
In-Reply-To: <CAHgaXdLJoVUXXGTYs7FYXay5wx=sA-O+=dYhX+r7AQT7vSNfGQ@mail.gmail.com>

On Thu, May 11, 2017 at 2:32 AM, Shubham Bansal
<illusionist.neo@gmail.com> wrote:
> What do you guys suggest i should implement it? I am almost done with
> my current implementation but if you think I should change it to the
> way David suggested, its better to suggest now before I send the
> patch.

I'd say send what you have right now, as it's a good starting point
for future work. I'll be curious to see the benchmarks, etc. It can be
a base for further optimization.

Thanks for chipping away at this!

-Kees

-- 
Kees Cook
Pixel Security

^ permalink raw reply

* [Problem] Broadcom BCM5762 Ethernet tg3 times out with stack trace
From: Daniel Kim @ 2017-05-11 15:25 UTC (permalink / raw)
  To: siva.kallam, prashant, mchan; +Cc: netdev

Summary:
Broadcom BCM5762 Ethernet tg3 times out with stack trace

Description:
The ethernet device will disconnect with dmesg reporting a stack trace
and a time out (visible in DMesg Output below). The ethernet device
will periodically reconnect and disconnect and the driver will output
a lot of hex values into logs.

The computer doesn't have to have network activity in order to trigger
this to happen, but I believe it can trigger faster if there was. It
usually occurs as soon as a few minutes after bootup to upwards of a
few hours in my test cases.

Kernel version:
Linux version 4.11.0-041100-generic (kernel@tangerine) (gcc version
6.3.0 20170415 (Ubuntu 6.3.0-14ubuntu3) ) #201705041534 SMP Thu May 4
19:36:05 UTC 2017

Full DMesg Output:
https://launchpadlibrarian.net/319135862/error_dmesg.txt
Bug has been reported with additional information at:
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1689383

Please let me know if there is other data or logs that you may need.


Cut DMesg Output:
[ 6244.283996] ------------[ cut here ]------------
[ 6244.284051] WARNING: CPU: 0 PID: 0 at
/home/kernel/COD/linux/net/sched/sch_generic.c:316
dev_watchdog+0x22c/0x230
[ 6244.284058] NETDEV WATCHDOG: enp4s0 (tg3): transmit queue 0 timed out
[ 6244.284064] Modules linked in: snd_hda_codec_hdmi hp_wmi
snd_hda_codec_realtek snd_hda_codec_generic sparse_keymap
snd_hda_intel snd_hda_codec edac_mce_amd edac_core crct10dif_pclmul
crc32_pclmul snd_hda_core snd_hwdep ghash_clmulni_intel pcbc joydev
input_leds snd_pcm aesni_intel aes_x86_64 snd_seq_midi
snd_seq_midi_event snd_rawmidi crypto_simd snd_seq snd_seq_device
snd_timer glue_helper snd cryptd soundcore serio_raw k10temp shpchp
i2c_piix4 mac_hid tpm_infineon wmi parport_pc ppdev lp parport autofs4
hid_generic usbhid hid psmouse tg3 ptp pps_core ahci libahci video
[ 6244.284129] CPU: 0 PID: 0 Comm: swapper/0 Not tainted
4.11.0-041100-generic #201705041534
[ 6244.284131] Hardware name: Hewlett-Packard HP EliteDesk 705 G1
MT/2215, BIOS L06 v02.17 12/11/2014
[ 6244.284132] Call Trace:
[ 6244.284135]  <IRQ>
[ 6244.284141]  dump_stack+0x63/0x81
[ 6244.284143]  __warn+0xcb/0xf0
[ 6244.284146]  warn_slowpath_fmt+0x5a/0x80
[ 6244.284149]  ? cpu_load_update+0xdd/0x150
[ 6244.284155]  dev_watchdog+0x22c/0x230
[ 6244.284159]  ? qdisc_rcu_free+0x50/0x50
[ 6244.284162]  call_timer_fn+0x35/0x140
[ 6244.284165]  run_timer_softirq+0x1db/0x440
[ 6244.284168]  ? ktime_get+0x41/0xb0
[ 6244.284172]  ? lapic_next_event+0x1d/0x30
[ 6244.284175]  ? clockevents_program_event+0x7f/0x120
[ 6244.284179]  __do_softirq+0x104/0x2af
[ 6244.284183]  irq_exit+0xb6/0xc0
[ 6244.284187]  smp_apic_timer_interrupt+0x3d/0x50
[ 6244.284190]  apic_timer_interrupt+0x89/0x90
[ 6244.284193] RIP: 0010:cpuidle_enter_state+0x122/0x2c0
[ 6244.284195] RSP: 0018:ffffffff86203dc8 EFLAGS: 00000246 ORIG_RAX:
ffffffffffffff10
[ 6244.284198] RAX: 0000000000000000 RBX: 0000000000000002 RCX: 000000000000001f
[ 6244.284200] RDX: 000005addc53de33 RSI: ffffa01a2ec189d8 RDI: 0000000000000000
[ 6244.284202] RBP: ffffffff86203e08 R08: 000000000000cd01 R09: 0000000000000018
[ 6244.284203] R10: ffffffff86203d98 R11: 0000000000000ef9 R12: ffffa01a1d6ab200
[ 6244.284205] R13: ffffffff862f92d8 R14: 0000000000000002 R15: ffffffff862f92c0
[ 6244.284207]  </IRQ>
[ 6244.284211]  ? cpuidle_enter_state+0x110/0x2c0
[ 6244.284213]  cpuidle_enter+0x17/0x20
[ 6244.284218]  call_cpuidle+0x23/0x40
[ 6244.284221]  do_idle+0x189/0x200
[ 6244.284224]  cpu_startup_entry+0x71/0x80
[ 6244.284227]  rest_init+0x77/0x80
[ 6244.284230]  start_kernel+0x455/0x476
[ 6244.284235]  ? early_idt_handler_array+0x120/0x120
[ 6244.284239]  x86_64_start_reservations+0x24/0x26
[ 6244.284243]  x86_64_start_kernel+0x14d/0x170
[ 6244.284246]  start_cpu+0x14/0x14
[ 6244.284251] ---[ end trace b14ec0a8b1e2a4e8 ]---
[ 6244.284259] tg3 0000:04:00.0 enp4s0: transmit timed out, resetting
[ 6244.398892] hrtimer: interrupt took 65509334 ns
[ 6247.090588] tg3 0000:04:00.0 enp4s0: 0x00000000: 0x168714e4,
0x00100506, 0x02000010, 0x00000010
[ 6247.090601] tg3 0000:04:00.0 enp4s0: 0x00000010: 0xe212000c,
0x00000000, 0xe211000c, 0x00000000
[ 6247.090607] tg3 0000:04:00.0 enp4s0: 0x00000020: 0xe210000c,
0x00000000, 0x00000000, 0x2215103c
[ 6247.090610] tg3 0000:04:00.0 enp4s0: 0x00000030: 0x00000000,
0x00000048, 0x00000000, 0x0000010a
[ 6247.090613] tg3 0000:04:00.0 enp4s0: 0x00000040: 0x00000000,
0x39000000, 0xc8035001, 0x16002008
[ 6247.090617] tg3 0000:04:00.0 enp4s0: 0x00000050: 0x00005803,
0x00000000, 0x0086a005, 0x00000000
[ 6247.090622] tg3 0000:04:00.0 enp4s0: 0x00000060: 0x00000000,
0x00000000, 0xf1000298, 0x01f802d1
[ 6247.090625] tg3 0000:04:00.0 enp4s0: 0x00000070: 0x00071010,
0xf6001500, 0x00000000, 0x00000000
[ 6247.090628] tg3 0000:04:00.0 enp4s0: 0x00000080: 0x168714e4,
0x00000018, 0x00000000, 0x00000800
[ 6247.090632] tg3 0000:04:00.0 enp4s0: 0x00000090: 0x00000000,
0x00000171, 0x00000000, 0x0000021d
[ 6247.090636] tg3 0000:04:00.0 enp4s0: 0x000000a0: 0x8005ac11,
0x00000004, 0x00000122, 0x00020010
[ 6247.090639] tg3 0000:04:00.0 enp4s0: 0x000000b0: 0x10008d82,
0x00115400, 0x00475c12, 0x10120043
[ 6247.090643] tg3 0000:04:00.0 enp4s0: 0x000000d0: 0x0008081f,
0x00000000, 0x00000000, 0x00010001
[ 6247.090649] tg3 0000:04:00.0 enp4s0: 0x000000f0: 0x00000000,
0x05762100, 0x00000000, 0xffffffff
[ 6247.090652] tg3 0000:04:00.0 enp4s0: 0x00000100: 0x13c10001,
0x00000000, 0x00000000, 0x00062030
[ 6247.090654] tg3 0000:04:00.0 enp4s0: 0x00000110: 0x00001000,
0x00002000, 0x000000a0, 0x00000000
[ 6247.090658] tg3 0000:04:00.0 enp4s0: 0x00000130: 0x00000000,
0x00000000, 0x00000000, 0x15010003
[ 6247.090660] tg3 0000:04:00.0 enp4s0: 0x00000140: 0xd45792bf,
0x00008cdc, 0x00000000, 0x00000000
[ 6247.090663] tg3 0000:04:00.0 enp4s0: 0x00000150: 0x16010004,
0x00000000, 0x00078116, 0x00000001
[ 6247.090666] tg3 0000:04:00.0 enp4s0: 0x00000160: 0x1b010002,
0x00000000, 0x00000000, 0x00000000
[ 6247.090669] tg3 0000:04:00.0 enp4s0: 0x00000170: 0x00000000,
0x80000001, 0x00000000, 0x00000000
[ 6247.090672] tg3 0000:04:00.0 enp4s0: 0x000001b0: 0x23010018,
0x00000000, 0x00000000, 0x00000000
[ 6247.090676] tg3 0000:04:00.0 enp4s0: 0x00000200: 0x00000000,
0x39000000, 0x00000000, 0xc3000000
[ 6247.090679] tg3 0000:04:00.0 enp4s0: 0x00000210: 0x00000000,
0x51000000, 0x00000000, 0x00000001
[ 6247.090682] tg3 0000:04:00.0 enp4s0: 0x00000220: 0x00000000,
0x00000001, 0x00000000, 0x00000000
[ 6247.090685] tg3 0000:04:00.0 enp4s0: 0x00000260: 0x00000000,
0x00000000, 0x00000000, 0x0000021d
[ 6247.090689] tg3 0000:04:00.0 enp4s0: 0x00000280: 0x00000000,
0x00000800, 0x00000000, 0x00000955
[ 6247.090692] tg3 0000:04:00.0 enp4s0: 0x00000300: 0x00000000,
0x00000171, 0x00000000, 0x00000171
[ 6247.090695] tg3 0000:04:00.0 enp4s0: 0x00000310: 0x00000000,
0x00000171, 0x00000000, 0x00000171
[ 6247.090698] tg3 0000:04:00.0 enp4s0: 0x00000320: 0x00000000,
0x00000171, 0x00000000, 0x00000171
[ 6247.090701] tg3 0000:04:00.0 enp4s0: 0x00000330: 0x00000000,
0x00000171, 0x00000000, 0x00000171
[ 6247.090704] tg3 0000:04:00.0 enp4s0: 0x00000340: 0x00000000,
0x00000171, 0x00000000, 0x00000171
[ 6247.090707] tg3 0000:04:00.0 enp4s0: 0x00000350: 0x00000000,
0x00000171, 0x00000000, 0x00000171
[ 6247.090710] tg3 0000:04:00.0 enp4s0: 0x00000360: 0x00000000,
0x00000171, 0x00000000, 0x00000171
[ 6247.090713] tg3 0000:04:00.0 enp4s0: 0x00000370: 0x00000000,
0x00000171, 0x00000000, 0x00000171
[ 6247.090716] tg3 0000:04:00.0 enp4s0: 0x00000380: 0x00000000,
0x00000171, 0x00000000, 0x00000171
[ 6247.090718] tg3 0000:04:00.0 enp4s0: 0x00000390: 0x00000000,
0x00000171, 0x00000000, 0x00000171
[ 6247.090721] tg3 0000:04:00.0 enp4s0: 0x000003a0: 0x00000000,
0x00000171, 0x00000000, 0x00000171
[ 6247.090724] tg3 0000:04:00.0 enp4s0: 0x000003b0: 0x00000000,
0x00000171, 0x00000000, 0x00000171
[ 6247.090727] tg3 0000:04:00.0 enp4s0: 0x000003c0: 0x00000000,
0x00000171, 0x00000000, 0x00000171
[ 6247.090730] tg3 0000:04:00.0 enp4s0: 0x000003d0: 0x00000000,
0x00000171, 0x00000000, 0x00000171
[ 6247.090733] tg3 0000:04:00.0 enp4s0: 0x000003e0: 0x00000000,
0x00000171, 0x00000000, 0x00000171
[ 6247.090736] tg3 0000:04:00.0 enp4s0: 0x000003f0: 0x00000000,
0x00000171, 0x00000000, 0x00000171
[ 6247.090738] tg3 0000:04:00.0 enp4s0: 0x00000400: 0x18e04808,
0x00400000, 0x00001000, 0x00009b00
[ 6247.090741] tg3 0000:04:00.0 enp4s0: 0x00000410: 0x00008cdc,
0xd45792bf, 0x00008cdc, 0xd45792bf
[ 6247.090744] tg3 0000:04:00.0 enp4s0: 0x00000420: 0x00008cdc,
0xd45792bf, 0x00008cdc, 0xd45792bf
[ 6247.090747] tg3 0000:04:00.0 enp4s0: 0x00000430: 0x00000000,
0x00000000, 0x00000008, 0x000005f2
[ 6247.090750] tg3 0000:04:00.0 enp4s0: 0x00000440: 0x00000000,
0x00000000, 0x00000000, 0x082e0006
[ 6247.090753] tg3 0000:04:00.0 enp4s0: 0x00000450: 0x00000001,
0x00008000, 0x00000000, 0x00000112
[ 6247.090756] tg3 0000:04:00.0 enp4s0: 0x00000460: 0x0000000b,
0x00002620, 0x03ff0006, 0x00000000
[ 6247.090759] tg3 0000:04:00.0 enp4s0: 0x00000470: 0xa0000000,
0x00000000, 0x00000000, 0x50000001
[ 6247.090762] tg3 0000:04:00.0 enp4s0: 0x00000480: 0x42000000,
0x7fffffff, 0x06000004, 0x7fffffff
[ 6247.090765] tg3 0000:04:00.0 enp4s0: 0x00000500: 0x00000008,
0x00000002, 0x00000000, 0x00000000
[ 6247.090768] tg3 0000:04:00.0 enp4s0: 0x00000590: 0x00901001,
0x00000000, 0x00000000, 0x00000000
[ 6247.090771] tg3 0000:04:00.0 enp4s0: 0x00000600: 0xffffffff,
0x00f80011, 0x00000000, 0x40001f0c
[ 6247.090774] tg3 0000:04:00.0 enp4s0: 0x00000610: 0xffffffff,
0x00000000, 0x00000044, 0x00000000
[ 6247.090777] tg3 0000:04:00.0 enp4s0: 0x00000620: 0x00000040,
0x00000000, 0x00000000, 0x00000000
[ 6247.090780] tg3 0000:04:00.0 enp4s0: 0x00000630: 0x01010101,
0x01010101, 0x01010101, 0x01010101
[ 6247.090782] tg3 0000:04:00.0 enp4s0: 0x00000640: 0x01010101,
0x01010101, 0x01010101, 0x01010101
[ 6247.090785] tg3 0000:04:00.0 enp4s0: 0x00000650: 0x01010101,
0x01010101, 0x01010101, 0x01010101
[ 6247.090788] tg3 0000:04:00.0 enp4s0: 0x00000660: 0x01010101,
0x01010101, 0x01010101, 0x01010101
[ 6247.090790] tg3 0000:04:00.0 enp4s0: 0x00000670: 0x43cb3b20,
0x0defd9a3, 0x767fe840, 0x1442a189
[ 6247.090793] tg3 0000:04:00.0 enp4s0: 0x00000680: 0xf210c361,
0xdb0f8709, 0xee76c0a3, 0x3753b863
[ 6247.090796] tg3 0000:04:00.0 enp4s0: 0x00000690: 0x8c5ffafc,
0xba4254bd, 0x00000000, 0x00000000
[ 6247.090798] tg3 0000:04:00.0 enp4s0: 0x000006c0: 0x00000000,
0x00000000, 0x04000000, 0x00000000
[ 6247.090801] tg3 0000:04:00.0 enp4s0: 0x00000800: 0x00000000,
0xffffffff, 0x00000000, 0x00000000
[ 6247.090804] tg3 0000:04:00.0 enp4s0: 0x00000810: 0x00000000,
0xffffffff, 0x00000000, 0x00000000
[ 6247.090806] tg3 0000:04:00.0 enp4s0: 0x00000820: 0x00000000,
0x00000000, 0xffffffff, 0x00000000
[ 6247.090809] tg3 0000:04:00.0 enp4s0: 0x00000830: 0x00000000,
0xffffffff, 0xffffffff, 0xffffffff
[ 6247.090812] tg3 0000:04:00.0 enp4s0: 0x00000840: 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff
[ 6247.090815] tg3 0000:04:00.0 enp4s0: 0x00000850: 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff
[ 6247.090817] tg3 0000:04:00.0 enp4s0: 0x00000860: 0xffffffff,
0xffffffff, 0xffffffff, 0x00000000
[ 6247.090820] tg3 0000:04:00.0 enp4s0: 0x00000880: 0x00000754,
0x00001633, 0x00000000, 0x00000000
[ 6247.090822] tg3 0000:04:00.0 enp4s0: 0x00000890: 0x00000005,
0x0000000c, 0x00000000, 0x00000000
[ 6247.090825] tg3 0000:04:00.0 enp4s0: 0x000008f0: 0x007c0001,
0x00000000, 0x00000000, 0x00000000
[ 6247.090828] tg3 0000:04:00.0 enp4s0: 0x00000900: 0x00095b83,
0xffffffff, 0x00000000, 0x00000000
[ 6247.090831] tg3 0000:04:00.0 enp4s0: 0x00000910: 0x00000002,
0xffffffff, 0x00000000, 0x00000000
[ 6247.090834] tg3 0000:04:00.0 enp4s0: 0x00000920: 0x00000000,
0x00000000, 0xffffffff, 0x00000000
[ 6247.090837] tg3 0000:04:00.0 enp4s0: 0x00000930: 0x00000000,
0xffffffff, 0xffffffff, 0xffffffff
[ 6247.090840] tg3 0000:04:00.0 enp4s0: 0x00000940: 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff
[ 6247.090843] tg3 0000:04:00.0 enp4s0: 0x00000950: 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff
[ 6247.090846] tg3 0000:04:00.0 enp4s0: 0x00000960: 0xffffffff,
0xffffffff, 0xffffffff, 0x000015d7
[ 6247.090849] tg3 0000:04:00.0 enp4s0: 0x00000970: 0x00000036,
0x00000164, 0x00000000, 0x00000000
[ 6247.090852] tg3 0000:04:00.0 enp4s0: 0x00000980: 0x010a92c7,
0x00001633, 0x00000000, 0x000015c8
[ 6247.090855] tg3 0000:04:00.0 enp4s0: 0x00000990: 0x0000a81a,
0x00019e10, 0x00000000, 0x00000000
[ 6247.090858] tg3 0000:04:00.0 enp4s0: 0x00000c00: 0x0000000a,
0x00000000, 0x00000003, 0x00000001
[ 6247.090861] tg3 0000:04:00.0 enp4s0: 0x00000c10: 0x00000000,
0x00000000, 0x00000000, 0x00620000
[ 6247.090864] tg3 0000:04:00.0 enp4s0: 0x00000c80: 0x00001771,
0x00000000, 0x00000000, 0x00000000
[ 6247.090867] tg3 0000:04:00.0 enp4s0: 0x00000ce0: 0xffd07a02,
0x00000000, 0x00000062, 0x00040028
[ 6247.090870] tg3 0000:04:00.0 enp4s0: 0x00000cf0: 0x00000000,
0x50000071, 0x00000000, 0x00000000
[ 6247.090873] tg3 0000:04:00.0 enp4s0: 0x00001000: 0x00000002,
0x00000000, 0xa000e5e6, 0x00000000
[ 6247.090876] tg3 0000:04:00.0 enp4s0: 0x00001010: 0x01711711,
0x0000e5e6, 0x00000000, 0x00000000
[ 6247.090879] tg3 0000:04:00.0 enp4s0: 0x00001400: 0x00000006,
0x00000000, 0x00000000, 0x00000001
[ 6247.090881] tg3 0000:04:00.0 enp4s0: 0x00001440: 0x00000171,
0x00000171, 0x00000171, 0x00000171
[ 6247.090884] tg3 0000:04:00.0 enp4s0: 0x00001450: 0x00000171,
0x00000171, 0x00000171, 0x00000171
[ 6247.090887] tg3 0000:04:00.0 enp4s0: 0x00001460: 0x00000171,
0x00000171, 0x00000171, 0x00000171
[ 6247.090890] tg3 0000:04:00.0 enp4s0: 0x00001470: 0x00000171,
0x00000171, 0x00000171, 0x00000171
[ 6247.090893] tg3 0000:04:00.0 enp4s0: 0x00001800: 0x00000016,
0x00000000, 0x00000171, 0x00000000
[ 6247.090896] tg3 0000:04:00.0 enp4s0: 0x00001840: 0x00000000,
0x00000000, 0x00000200, 0x00000010
[ 6247.090899] tg3 0000:04:00.0 enp4s0: 0x00001850: 0x0000001f,
0x00000000, 0x00004300, 0x01710171
[ 6247.090902] tg3 0000:04:00.0 enp4s0: 0x00001860: 0x01000000,
0x00000000, 0x00000000, 0x00000000
[ 6247.090904] tg3 0000:04:00.0 enp4s0: 0x00001c00: 0x00000002,
0x00000000, 0x00000000, 0x00000000
[ 6247.090907] tg3 0000:04:00.0 enp4s0: 0x00002000: 0x00000002,
0x00000000, 0x00000000, 0x00000000
[ 6247.090910] tg3 0000:04:00.0 enp4s0: 0x00002010: 0x00000181,
0x00000001, 0x007bfffd, 0x00000000
[ 6247.090913] tg3 0000:04:00.0 enp4s0: 0x00002100: 0x000d62b3,
0x0008dc6f, 0x0000009e, 0x00000000
[ 6247.090916] tg3 0000:04:00.0 enp4s0: 0x00002110: 0x000d62b3,
0x0008dc6f, 0x0000009e, 0x00000000
[ 6247.090918] tg3 0000:04:00.0 enp4s0: 0x00002120: 0x000d62b3,
0x0008dc6f, 0x0000009e, 0x00000000
[ 6247.090921] tg3 0000:04:00.0 enp4s0: 0x00002130: 0x000d62b3,
0x0008dc6f, 0x0000009e, 0x00000000
[ 6247.090924] tg3 0000:04:00.0 enp4s0: 0x00002140: 0x000d62b3,
0x0008dc6f, 0x0000009e, 0x00000000
[ 6247.090928] tg3 0000:04:00.0 enp4s0: 0x00002150: 0x000d62b3,
0x0008dc6f, 0x0000009e, 0x00000000
[ 6247.090931] tg3 0000:04:00.0 enp4s0: 0x00002160: 0x000d62b3,
0x0008dc6f, 0x0000009e, 0x00000000
[ 6247.090934] tg3 0000:04:00.0 enp4s0: 0x00002170: 0x000d62b3,
0x0008dc6f, 0x0000009e, 0x00000000
[ 6247.090937] tg3 0000:04:00.0 enp4s0: 0x00002180: 0x000d62b3,
0x0008dc6f, 0x0000009e, 0x00000000
[ 6247.090940] tg3 0000:04:00.0 enp4s0: 0x00002190: 0x000d62b3,
0x0008dc6f, 0x0000009e, 0x00000000
[ 6247.090942] tg3 0000:04:00.0 enp4s0: 0x000021a0: 0x000d62b3,
0x0008dc6f, 0x0000009e, 0x00000000
[ 6247.090945] tg3 0000:04:00.0 enp4s0: 0x000021b0: 0x000d62b3,
0x0008dc6f, 0x0000009e, 0x00000000
[ 6247.090948] tg3 0000:04:00.0 enp4s0: 0x000021c0: 0x000d62b3,
0x0008dc6f, 0x0000009e, 0x00000000
[ 6247.090951] tg3 0000:04:00.0 enp4s0: 0x000021d0: 0x000d62b3,
0x0008dc6f, 0x0000009e, 0x00000000
[ 6247.090953] tg3 0000:04:00.0 enp4s0: 0x000021e0: 0x000d62b3,
0x0008dc6f, 0x0000009e, 0x00000000
[ 6247.090956] tg3 0000:04:00.0 enp4s0: 0x000021f0: 0x000d62b3,
0x0008dc6f, 0x0000009e, 0x00000000
[ 6247.090959] tg3 0000:04:00.0 enp4s0: 0x00002200: 0x00025b63,
0x00000000, 0x00000000, 0x00000000
[ 6247.090962] tg3 0000:04:00.0 enp4s0: 0x00002250: 0x00009a2d,
0x00000000, 0x00000000, 0x00000000
[ 6247.090965] tg3 0000:04:00.0 enp4s0: 0x00002400: 0x00010012,
0x00000000, 0x00000000, 0x00000000
[ 6247.090968] tg3 0000:04:00.0 enp4s0: 0x00002440: 0x00000000,
0x00000000, 0x00000002, 0x00000000
[ 6247.090970] tg3 0000:04:00.0 enp4s0: 0x00002450: 0x00000000,
0xfffe0000, 0x08001800, 0x00006000
[ 6247.090973] tg3 0000:04:00.0 enp4s0: 0x00002470: 0x00000000,
0x0000015f, 0x00000000, 0x00000000
[ 6247.090976] tg3 0000:04:00.0 enp4s0: 0x000024c0: 0x02005101,
0x00000000, 0x00000000, 0x00000000
[ 6247.090979] tg3 0000:04:00.0 enp4s0: 0x00002800: 0x00000006,
0x00000000, 0x00000000, 0x00000000
[ 6247.090982] tg3 0000:04:00.0 enp4s0: 0x00002c00: 0x00000006,
0x00000000, 0x00000000, 0x000001d5
[ 6247.090985] tg3 0000:04:00.0 enp4s0: 0x00002c10: 0x00000000,
0x00000000, 0x00000019, 0x0000000c
[ 6247.090988] tg3 0000:04:00.0 enp4s0: 0x00002c20: 0x00020002,
0x00000000, 0x00000000, 0x00000000
[ 6247.090990] tg3 0000:04:00.0 enp4s0: 0x00002d00: 0x00000080,
0x00000040, 0x00000000, 0x00000000
[ 6247.090993] tg3 0000:04:00.0 enp4s0: 0x00003000: 0x00000006,
0x00000000, 0x00000000, 0x000001d5
[ 6247.090997] tg3 0000:04:00.0 enp4s0: 0x00003600: 0x00034400,
0x00130000, 0x00110000, 0x00000000
[ 6247.090999] tg3 0000:04:00.0 enp4s0: 0x00003610: 0x00131100,
0x00130000, 0x00130000, 0x00000000
[ 6247.091002] tg3 0000:04:00.0 enp4s0: 0x00003620: 0x80110011,
0x00000000, 0x00000004, 0x3c822080
[ 6247.091005] tg3 0000:04:00.0 enp4s0: 0x00003630: 0x00000000,
0x80008000, 0x00001080, 0x00000000
[ 6247.091008] tg3 0000:04:00.0 enp4s0: 0x00003640: 0x0000000a,
0x33f00003, 0x00000020, 0x00000019
[ 6247.091010] tg3 0000:04:00.0 enp4s0: 0x00003650: 0x00000171,
0x00000bff, 0x05762100, 0x00000000
[ 6247.091014] tg3 0000:04:00.0 enp4s0: 0x00003660: 0x00000000,
0x00000000, 0x000400a3, 0x00000202
[ 6247.091017] tg3 0000:04:00.0 enp4s0: 0x00003670: 0x0000002a,
0xfeffff63, 0x0000000a, 0x00000000
[ 6247.091020] tg3 0000:04:00.0 enp4s0: 0x000036b0: 0x001003cc,
0x07ff07ff, 0x07ff07ff, 0x01000004
[ 6247.091022] tg3 0000:04:00.0 enp4s0: 0x000036c0: 0xffffffff,
0x0000a441, 0x00c84caa, 0x0000a558
[ 6247.091025] tg3 0000:04:00.0 enp4s0: 0x000036d0: 0x0000019d,
0x00000000, 0x00000000, 0x00000000
[ 6247.091028] tg3 0000:04:00.0 enp4s0: 0x000036e0: 0x80000b19,
0xa0800799, 0x00500799, 0x00000000
[ 6247.091031] tg3 0000:04:00.0 enp4s0: 0x000036f0: 0x19090900,
0x13180600, 0x00000301, 0x00000001
[ 6247.091034] tg3 0000:04:00.0 enp4s0: 0x00003700: 0x00000000,
0x00000000, 0x00000000, 0x00001388
[ 6247.091037] tg3 0000:04:00.0 enp4s0: 0x00003710: 0x87fffffd,
0x00000000, 0x00000000, 0x000010dc
[ 6247.091039] tg3 0000:04:00.0 enp4s0: 0x00003720: 0x00000000,
0x00002040, 0x88006000, 0xa0002000
[ 6247.091042] tg3 0000:04:00.0 enp4s0: 0x00003750: 0x00000000,
0x00000000, 0x0000080b, 0x00000000
[ 6247.091045] tg3 0000:04:00.0 enp4s0: 0x00003780: 0x0000bff9,
0x00000000, 0x00000000, 0x00000000
[ 6247.091049] tg3 0000:04:00.0 enp4s0: 0x00003c00: 0x00000306,
0x00000000, 0x00000000, 0x00000048
[ 6247.091052] tg3 0000:04:00.0 enp4s0: 0x00003c10: 0x00000000,
0x00000035, 0x00000000, 0x00000000
[ 6247.091055] tg3 0000:04:00.0 enp4s0: 0x00003c20: 0x00000000,
0x00000005, 0x00000000, 0x00000000
[ 6247.091058] tg3 0000:04:00.0 enp4s0: 0x00003c30: 0x00000000,
0x00000000, 0x00000000, 0xffffc000
[ 6247.091061] tg3 0000:04:00.0 enp4s0: 0x00003c40: 0x00000000,
0x00000b00, 0x00000000, 0x00000000
[ 6247.091064] tg3 0000:04:00.0 enp4s0: 0x00003c50: 0x00000000,
0x00000155, 0x00000000, 0x00000000
[ 6247.091066] tg3 0000:04:00.0 enp4s0: 0x00003c80: 0x00000800,
0x00000955, 0x00000000, 0x00000000
[ 6247.091069] tg3 0000:04:00.0 enp4s0: 0x00003cc0: 0x00000171,
0x00000000, 0x00000000, 0x00000000
[ 6247.091072] tg3 0000:04:00.0 enp4s0: 0x00003cd0: 0x00000000,
0x0000000f, 0x00000000, 0x00000000
[ 6247.091075] tg3 0000:04:00.0 enp4s0: 0x00003d00: 0x00000000,
0xffffb000, 0x00000000, 0xffffa000
[ 6247.091078] tg3 0000:04:00.0 enp4s0: 0x00003d80: 0x00000014,
0x00000000, 0x00000005, 0x00000000
[ 6247.091080] tg3 0000:04:00.0 enp4s0: 0x00003d90: 0x00000005,
0x00000000, 0x00000014, 0x00000000
[ 6247.091083] tg3 0000:04:00.0 enp4s0: 0x00003da0: 0x00000005,
0x00000000, 0x00000005, 0x00000000
[ 6247.091086] tg3 0000:04:00.0 enp4s0: 0x00004000: 0x00000002,
0x00000000, 0x00000000, 0x00000000
[ 6247.091088] tg3 0000:04:00.0 enp4s0: 0x00004010: 0x00000000,
0x0026f012, 0x00800420, 0x01006222
[ 6247.091091] tg3 0000:04:00.0 enp4s0: 0x00004020: 0x00000000,
0x00000010, 0x00000010, 0x00000050
[ 6247.091094] tg3 0000:04:00.0 enp4s0: 0x00004030: 0x00000000,
0x01086020, 0x00296010, 0x00000002
[ 6247.091096] tg3 0000:04:00.0 enp4s0: 0x00004040: 0x00400000,
0x00000000, 0x00000010, 0x004e5062
[ 6247.091100] tg3 0000:04:00.0 enp4s0: 0x00004400: 0x00000016,
0x00000000, 0x00010000, 0x0000a000
[ 6247.091103] tg3 0000:04:00.0 enp4s0: 0x00004410: 0x00000000,
0x0000002a, 0x000000a0, 0x00000000
[ 6247.091106] tg3 0000:04:00.0 enp4s0: 0x00004420: 0x000000fd,
0x00000000, 0x00000000, 0x00000000
[ 6247.091109] tg3 0000:04:00.0 enp4s0: 0x00004440: 0x00000000,
0x00000000, 0x00000000, 0x0e5398e8
[ 6247.091112] tg3 0000:04:00.0 enp4s0: 0x00004450: 0x02340226,
0x00970071, 0x00000000, 0x00000000
[ 6247.091116] tg3 0000:04:00.0 enp4s0: 0x00004700: 0x00030002,
0x00100000, 0x00100010, 0xc1250000
[ 6247.091119] tg3 0000:04:00.0 enp4s0: 0x00004710: 0xfffff6e0,
0x00060484, 0x00100010, 0x00000000
[ 6247.091121] tg3 0000:04:00.0 enp4s0: 0x00004720: 0x00000000,
0x00000000, 0xf02c0000, 0xfffff710
[ 6247.091124] tg3 0000:04:00.0 enp4s0: 0x00004770: 0x000c0404,
0x00000002, 0x00000010, 0x00000000
[ 6247.091127] tg3 0000:04:00.0 enp4s0: 0x00004800: 0x380303fe,
0x00000000, 0x00000000, 0x00000100
[ 6247.091130] tg3 0000:04:00.0 enp4s0: 0x00004810: 0x00000000,
0x00000008, 0x00429f80, 0x00008000
[ 6247.091133] tg3 0000:04:00.0 enp4s0: 0x00004820: 0x000000dd,
0x00000000, 0x00000000, 0x00000000
[ 6247.091136] tg3 0000:04:00.0 enp4s0: 0x00004860: 0x000000dd,
0x11400062, 0x001ff800, 0x62000008
[ 6247.091139] tg3 0000:04:00.0 enp4s0: 0x00004870: 0x05ea0080,
0x003e1820, 0x003e1820, 0x00000000
[ 6247.091141] tg3 0000:04:00.0 enp4s0: 0x00004890: 0x280c0c04,
0x00305400, 0x00000000, 0x00000000
[ 6247.091144] tg3 0000:04:00.0 enp4s0: 0x000048a0: 0x000f0010,
0x00000000, 0x00000000, 0x00000000
[ 6247.091147] tg3 0000:04:00.0 enp4s0: 0x00004900: 0x18030002,
0x00000003, 0x30000000, 0x00000120
[ 6247.091149] tg3 0000:04:00.0 enp4s0: 0x00004910: 0x00000040,
0x00000003, 0x0000df94, 0x00000008
[ 6247.091152] tg3 0000:04:00.0 enp4s0: 0x00004920: 0x000000e7,
0x02728000, 0xffd07a01, 0x0f000068
[ 6247.091155] tg3 0000:04:00.0 enp4s0: 0x00004930: 0xffd31201,
0x0f000068, 0xffcdf401, 0x0f000068
[ 6247.091158] tg3 0000:04:00.0 enp4s0: 0x00004940: 0xffebcc01,
0x0f000068, 0x4f4f1212, 0x3e3ea3a3
[ 6247.091161] tg3 0000:04:00.0 enp4s0: 0x00004950: 0xf0330000,
0xffd07a68, 0xaf000000, 0xe7e500e6
[ 6247.091164] tg3 0000:04:00.0 enp4s0: 0x00004960: 0x00000000,
0xffd31268, 0xaf000000, 0x40000171
[ 6247.091167] tg3 0000:04:00.0 enp4s0: 0x00004970: 0x00028202,
0x00205400, 0x0000001c, 0x000000ff
[ 6247.091170] tg3 0000:04:00.0 enp4s0: 0x00004980: 0x000000e7,
0x00000000, 0x00000000, 0x00000000
[ 6247.091172] tg3 0000:04:00.0 enp4s0: 0x00004990: 0x00000000,
0x00000000, 0xffcdf468, 0xaf000000
[ 6247.091175] tg3 0000:04:00.0 enp4s0: 0x000049a0: 0x00f00049,
0x000000e7, 0x00000000, 0x00000000
[ 6247.091178] tg3 0000:04:00.0 enp4s0: 0x000049b0: 0xffd09601,
0xffd2c401, 0xffce7e01, 0xffec7e01
[ 6247.091181] tg3 0000:04:00.0 enp4s0: 0x000049c0: 0xffd07a02,
0xffd31202, 0xffcdf402, 0xffebcc02
[ 6247.091183] tg3 0000:04:00.0 enp4s0: 0x000049d0: 0xffd09602,
0xffd2c402, 0xffce7e02, 0xffec7e02
[ 6247.091186] tg3 0000:04:00.0 enp4s0: 0x000049f0: 0xf0330000,
0xffebcc68, 0xaf000000, 0x0000ffff
[ 6247.091190] tg3 0000:04:00.0 enp4s0: 0x00004c00: 0x200003fe,
0x00000020, 0x00000000, 0x00000000
[ 6247.091193] tg3 0000:04:00.0 enp4s0: 0x00004c10: 0x0000003f,
0x00000000, 0x00000006, 0x00000000
[ 6247.091196] tg3 0000:04:00.0 enp4s0: 0x00004c20: 0x00000000,
0x00000000, 0x00000000, 0x00000006
[ 6247.091199] tg3 0000:04:00.0 enp4s0: 0x00004c30: 0x00000000,
0x00200000, 0x0000007c, 0x0000007c
[ 6247.091201] tg3 0000:04:00.0 enp4s0: 0x00004c40: 0x00000000,
0x09550000, 0x00000000, 0x095407ff
[ 6247.091204] tg3 0000:04:00.0 enp4s0: 0x00004c50: 0x0fff0fff,
0x01550fff, 0x00000000, 0x00553939
[ 6247.091207] tg3 0000:04:00.0 enp4s0: 0x00004c60: 0x00000020,
0x00000000, 0x00000000, 0x00000000
[ 6247.091210] tg3 0000:04:00.0 enp4s0: 0x00005000: 0x00009800,
0x80000000, 0x00000000, 0x00000000
[ 6247.091213] tg3 0000:04:00.0 enp4s0: 0x00005010: 0x00000000,
0x00000000, 0x00000000, 0x08001028
[ 6247.091216] tg3 0000:04:00.0 enp4s0: 0x00005020: 0x30840fff,
0x00000000, 0x00000000, 0x40000020
[ 6247.091218] tg3 0000:04:00.0 enp4s0: 0x00005030: 0x00000000,
0x00000025, 0x00000000, 0x00000000
[ 6247.091222] tg3 0000:04:00.0 enp4s0: 0x00005040: 0x00000000,
0x00000000, 0x080011f4, 0x00000000
[ 6247.091225] tg3 0000:04:00.0 enp4s0: 0x00005080: 0x00009800,
0x80004000, 0x00000000, 0x00000000
[ 6247.091227] tg3 0000:04:00.0 enp4s0: 0x00005090: 0x00000000,
0x00000000, 0x00000000, 0x08001028
[ 6247.091230] tg3 0000:04:00.0 enp4s0: 0x000050a0: 0x30840fff,
0x00000000, 0x00000000, 0x40000020
[ 6247.091233] tg3 0000:04:00.0 enp4s0: 0x000050b0: 0x00000000,
0x00000025, 0x00000000, 0x00000000
[ 6247.091236] tg3 0000:04:00.0 enp4s0: 0x000050c0: 0x00000000,
0x00000000, 0x080011f4, 0x00000000
[ 6247.091238] tg3 0000:04:00.0 enp4s0: 0x00005100: 0x00009800,
0x80000000, 0x00000000, 0x00000000
[ 6247.091241] tg3 0000:04:00.0 enp4s0: 0x00005110: 0x00000000,
0x00000000, 0x00000000, 0x08001028
[ 6247.091244] tg3 0000:04:00.0 enp4s0: 0x00005120: 0x30840fff,
0x00000000, 0x00000000, 0x40000020
[ 6247.091247] tg3 0000:04:00.0 enp4s0: 0x00005130: 0x00000000,
0x00000025, 0x00000000, 0x00000000
[ 6247.091250] tg3 0000:04:00.0 enp4s0: 0x00005140: 0x00000000,
0x00000000, 0x080011f4, 0x00000000
[ 6247.091253] tg3 0000:04:00.0 enp4s0: 0x00005180: 0x00009800,
0x80000000, 0x00000000, 0x00000000
[ 6247.091256] tg3 0000:04:00.0 enp4s0: 0x00005190: 0x00000000,
0x00000000, 0x00000000, 0x08001028
[ 6247.091258] tg3 0000:04:00.0 enp4s0: 0x000051a0: 0x30840fff,
0x00000000, 0x00000000, 0x40000020
[ 6247.091261] tg3 0000:04:00.0 enp4s0: 0x000051b0: 0x00000000,
0x00000025, 0x00000000, 0x00000000
[ 6247.091264] tg3 0000:04:00.0 enp4s0: 0x000051c0: 0x00000000,
0x00000000, 0x080011f4, 0x00000000
[ 6247.091266] tg3 0000:04:00.0 enp4s0: 0x00005200: 0x05762100,
0x00000000, 0x21100010, 0x00000000
[ 6247.091270] tg3 0000:04:00.0 enp4s0: 0x00005210: 0x00010000,
0x00831824, 0xc0000000, 0x14400016
[ 6247.091273] tg3 0000:04:00.0 enp4s0: 0x00005220: 0xc0000000,
0x21100010, 0x00000000, 0x00000000
[ 6247.091276] tg3 0000:04:00.0 enp4s0: 0x00005230: 0x080012bc,
0x03608821, 0x14400016, 0x14830018
[ 6247.091279] tg3 0000:04:00.0 enp4s0: 0x00005240: 0x0800150c,
0x00000000, 0x3c038000, 0x54000003
[ 6247.091282] tg3 0000:04:00.0 enp4s0: 0x00005250: 0x03608821,
0x00010000, 0x14830018, 0x21100010
[ 6247.091285] tg3 0000:04:00.0 enp4s0: 0x00005260: 0x00000000,
0x3c038000, 0x54000003, 0x03608821
[ 6247.091288] tg3 0000:04:00.0 enp4s0: 0x00005270: 0xc0010000,
0x14830018, 0x21100010, 0x00000000
[ 6247.091291] tg3 0000:04:00.0 enp4s0: 0x00005280: 0x00009800,
0x80004000, 0x00000000, 0x00000000
[ 6247.091294] tg3 0000:04:00.0 enp4s0: 0x00005290: 0x00000000,
0x00000000, 0x00000000, 0x0800102c
[ 6247.091297] tg3 0000:04:00.0 enp4s0: 0x000052a0: 0x3c04ff00,
0x00000000, 0x00000000, 0x40000020
[ 6247.091300] tg3 0000:04:00.0 enp4s0: 0x000052b0: 0x00000000,
0x00000025, 0x00000000, 0x00000000
[ 6247.091302] tg3 0000:04:00.0 enp4s0: 0x000052c0: 0x00000000,
0x00000000, 0x08000110, 0x00000000
[ 6247.091305] tg3 0000:04:00.0 enp4s0: 0x00005300: 0x00009800,
0x80004000, 0x00000000, 0x00000000
[ 6247.091308] tg3 0000:04:00.0 enp4s0: 0x00005310: 0x00000000,
0x00000000, 0x00000000, 0x08000100
[ 6247.091311] tg3 0000:04:00.0 enp4s0: 0x00005320: 0x3c04ff00,
0x00000000, 0x00000000, 0x40000020
[ 6247.091314] tg3 0000:04:00.0 enp4s0: 0x00005330: 0x00000000,
0x00000025, 0x00000000, 0x00000000
[ 6247.091317] tg3 0000:04:00.0 enp4s0: 0x00005340: 0x00000000,
0x00000000, 0x08000110, 0x00000000
[ 6247.091320] tg3 0000:04:00.0 enp4s0: 0x00005380: 0x00009800,
0x80004000, 0x00000000, 0x00000000
[ 6247.091323] tg3 0000:04:00.0 enp4s0: 0x00005390: 0x00000000,
0x00000000, 0x00000000, 0x080000f8
[ 6247.091325] tg3 0000:04:00.0 enp4s0: 0x000053a0: 0x3c04ff00,
0x00000000, 0x00000000, 0x40000020
[ 6247.091328] tg3 0000:04:00.0 enp4s0: 0x000053b0: 0x00000000,
0x00000025, 0x00000000, 0x00000000
[ 6247.091331] tg3 0000:04:00.0 enp4s0: 0x000053c0: 0x00000000,
0x00000000, 0x080011f4, 0x00000000
[ 6247.091334] tg3 0000:04:00.0 enp4s0: 0x00005800: 0x00000000,
0x39000000, 0x00000000, 0xc3000000
[ 6247.091337] tg3 0000:04:00.0 enp4s0: 0x00005810: 0x00000000,
0x51000000, 0x00000000, 0x00000001
[ 6247.091340] tg3 0000:04:00.0 enp4s0: 0x00005820: 0x00000000,
0x00000001, 0x00000000, 0x00000000
[ 6247.091342] tg3 0000:04:00.0 enp4s0: 0x00005860: 0x00000000,
0x00000000, 0x00000000, 0x0000021d
[ 6247.091345] tg3 0000:04:00.0 enp4s0: 0x00005880: 0x00000000,
0x00000800, 0x00000000, 0x00000955
[ 6247.091348] tg3 0000:04:00.0 enp4s0: 0x00005900: 0x00000000,
0x00000171, 0x00000000, 0x00000000
[ 6247.091350] tg3 0000:04:00.0 enp4s0: 0x00005980: 0x00000171,
0x00000000, 0x00000000, 0x00000000
[ 6247.091353] tg3 0000:04:00.0 enp4s0: 0x00005a00: 0x000f601f,
0x00000000, 0x00010000, 0x00000000
[ 6247.091356] tg3 0000:04:00.0 enp4s0: 0x00006000: 0x20010082,
0x00000000, 0x00000000, 0x00000000
[ 6247.091359] tg3 0000:04:00.0 enp4s0: 0x00006400: 0x00000000,
0x00000000, 0x00010091, 0xc0000000
[ 6247.091362] tg3 0000:04:00.0 enp4s0: 0x00006410: 0x05000016,
0x05000016, 0x00000000, 0x00000000
[ 6247.091364] tg3 0000:04:00.0 enp4s0: 0x00006430: 0x00000000,
0x14e41687, 0x2215103c, 0x10020000
[ 6247.091367] tg3 0000:04:00.0 enp4s0: 0x00006440: 0x0000304f,
0x000002e4, 0x00000000, 0x00000080
[ 6247.091371] tg3 0000:04:00.0 enp4s0: 0x000064c0: 0x00000005,
0x00000004, 0x00000122, 0x00000000
[ 6247.091374] tg3 0000:04:00.0 enp4s0: 0x000064d0: 0x00000040,
0x10008d82, 0x00000000, 0x00d75e12
[ 6247.091377] tg3 0000:04:00.0 enp4s0: 0x000064e0: 0x00000031,
0x0008001f, 0x00000000, 0x00000000
[ 6247.091379] tg3 0000:04:00.0 enp4s0: 0x000064f0: 0x00000002,
0x00000031, 0x00000000, 0x00000000
[ 6247.091382] tg3 0000:04:00.0 enp4s0: 0x00006500: 0x03e10003,
0xd45792bf, 0x00008cdc, 0x00000003
[ 6247.091385] tg3 0000:04:00.0 enp4s0: 0x00006510: 0x00078116,
0x0005810b, 0x00046105, 0x00000000
[ 6247.091388] tg3 0000:04:00.0 enp4s0: 0x00006530: 0x00000001,
0x00000000, 0x00000000, 0x00000000
[ 6247.091390] tg3 0000:04:00.0 enp4s0: 0x00006540: 0x0028081f,
0x0001001e, 0x00000000, 0x00000000
[ 6247.091393] tg3 0000:04:00.0 enp4s0: 0x00006550: 0x00000001,
0x02800000, 0x0000000f, 0x00000000
[ 6247.091396] tg3 0000:04:00.0 enp4s0: 0x00006560: 0x0000000f,
0x00000000, 0x00000000, 0x00000000
[ 6247.091399] tg3 0000:04:00.0 enp4s0: 0x000065f0: 0x00000000,
0x00000059, 0x00000000, 0x00000000
[ 6247.091402] tg3 0000:04:00.0 enp4s0: 0x00006800: 0x141b0034,
0x20081082, 0x00029118, 0x730cfbb9
[ 6247.091405] tg3 0000:04:00.0 enp4s0: 0x00006810: 0x21100010,
0xffffffff, 0x00000000, 0x000000f0
[ 6247.091408] tg3 0000:04:00.0 enp4s0: 0x00006880: 0x77fff020,
0x00000040, 0x00801687, 0x00000000
[ 6247.091410] tg3 0000:04:00.0 enp4s0: 0x00006890: 0x00800000,
0x00000000, 0x00000000, 0x00000000
[ 6247.091413] tg3 0000:04:00.0 enp4s0: 0x000068a0: 0x00000000,
0x00010001, 0x00000000, 0x00000000
[ 6247.091416] tg3 0000:04:00.0 enp4s0: 0x000068b0: 0x00040000,
0x00000000, 0x00000000, 0x00000000
[ 6247.091419] tg3 0000:04:00.0 enp4s0: 0x000068c0: 0x00000044,
0x00000000, 0x00000000, 0x00000000
[ 6247.091422] tg3 0000:04:00.0 enp4s0: 0x000068f0: 0x00000000,
0x00000000, 0x00000000, 0x04444444
[ 6247.091424] tg3 0000:04:00.0 enp4s0: 0x00006900: 0x6f95a788,
0x14bd0ec2, 0x00000000, 0x00000000
[ 6247.091427] tg3 0000:04:00.0 enp4s0: 0x00006920: 0x00000000,
0x00000000, 0x00000001, 0x00000000
[ 6247.091430] tg3 0000:04:00.0 enp4s0: 0x00006c00: 0x168714e4,
0x00100506, 0x02000010, 0x00000010
[ 6247.091433] tg3 0000:04:00.0 enp4s0: 0x00006c10: 0xe212000c,
0x00000000, 0xe211000c, 0x00000000
[ 6247.091436] tg3 0000:04:00.0 enp4s0: 0x00006c20: 0xe210000c,
0x00000000, 0x00000000, 0x2215103c
[ 6247.091438] tg3 0000:04:00.0 enp4s0: 0x00006c30: 0x00000000,
0x00000048, 0x00000000, 0x0000010a
[ 6247.091441] tg3 0000:04:00.0 enp4s0: 0x00006c40: 0x00000000,
0x00000000, 0xc8035001, 0x16002008
[ 6247.091444] tg3 0000:04:00.0 enp4s0: 0x00006c50: 0x00005803,
0x00000000, 0x0086a005, 0x00000000
[ 6247.091447] tg3 0000:04:00.0 enp4s0: 0x00006c60: 0x00000000,
0x00000000, 0xf1000298, 0x01f802d1
[ 6247.091450] tg3 0000:04:00.0 enp4s0: 0x00006c70: 0x00071010,
0xf6001500, 0x00000000, 0x00000000
[ 6247.091453] tg3 0000:04:00.0 enp4s0: 0x00006ca0: 0x8005ac11,
0x00000004, 0x00000122, 0x00020010
[ 6247.091456] tg3 0000:04:00.0 enp4s0: 0x00006cb0: 0x10008d82,
0x00115400, 0x00475c12, 0x10120043
[ 6247.091459] tg3 0000:04:00.0 enp4s0: 0x00006cd0: 0x0008081f,
0x00000000, 0x00000000, 0x00010001
[ 6247.091462] tg3 0000:04:00.0 enp4s0: 0x00006cf0: 0x00000000,
0x05762100, 0x00000000, 0x00000000
[ 6247.091464] tg3 0000:04:00.0 enp4s0: 0x00006d00: 0x13c10001,
0x00000000, 0x00000000, 0x00062030
[ 6247.091467] tg3 0000:04:00.0 enp4s0: 0x00006d10: 0x00001000,
0x00002000, 0x000000a0, 0x00000000
[ 6247.091470] tg3 0000:04:00.0 enp4s0: 0x00006d30: 0x00000000,
0x00000000, 0x00000000, 0x15010003
[ 6247.091473] tg3 0000:04:00.0 enp4s0: 0x00006d40: 0xd45792bf,
0x00008cdc, 0x00000000, 0x00000000
[ 6247.091476] tg3 0000:04:00.0 enp4s0: 0x00006d50: 0x16010004,
0x00000000, 0x00078116, 0x00000001
[ 6247.091479] tg3 0000:04:00.0 enp4s0: 0x00006d60: 0x1b010002,
0x00000000, 0x00000000, 0x00000000
[ 6247.091482] tg3 0000:04:00.0 enp4s0: 0x00006d70: 0x00000000,
0x80000001, 0x00000000, 0x00000000
[ 6247.091484] tg3 0000:04:00.0 enp4s0: 0x00006db0: 0x23010018,
0x00000000, 0x00000000, 0x00000000
[ 6247.091487] tg3 0000:04:00.0 enp4s0: 0x00006e30: 0x00010017,
0x00050403, 0x00000000, 0x00000000
[ 6247.091490] tg3 0000:04:00.0 enp4s0: 0x00007000: 0x08000008,
0x00000000, 0x00000000, 0x000038d4
[ 6247.091493] tg3 0000:04:00.0 enp4s0: 0x00007010: 0x9928504d,
0x02808083, 0x800500db, 0x03000a00
[ 6247.091496] tg3 0000:04:00.0 enp4s0: 0x00007020: 0x00000000,
0x00000008, 0x00000406, 0x10004000
[ 6247.091499] tg3 0000:04:00.0 enp4s0: 0x00007030: 0x000e0000,
0x000038d8, 0x00230030, 0x80000000
[ 6247.091502] tg3 0000:04:00.0 enp4s0: 0x00007500: 0x00000000,
0x00000000, 0x00000081, 0x00000000
[ 6247.091505] tg3 0000:04:00.0 enp4s0: 0x00007510: 0x00000000,
0xffffdfff, 0x00000000, 0x00000000
[ 6247.091510] tg3 0000:04:00.0 enp4s0: 0: Host status block
[00000001:00000039:(0000:0145:0000):(0000:0167)]
[ 6247.091514] tg3 0000:04:00.0 enp4s0: 0: NAPI info
[00000039:00000039:(0171:0167:01ff):0000:(021d:0000:0000:0000)]
[ 6247.091518] tg3 0000:04:00.0 enp4s0: 1: Host status block
[00000001:000000c3:(0000:0000:0000):(0800:0000)]
[ 6247.091521] tg3 0000:04:00.0 enp4s0: 1: NAPI info
[000000c3:000000c3:(0000:0000:01ff):0800:(0000:0000:0000:0000)]
[ 6247.091524] tg3 0000:04:00.0 enp4s0: 2: Host status block
[00000001:00000051:(0955:0000:0000):(0000:0000)]
[ 6247.091528] tg3 0000:04:00.0 enp4s0: 2: NAPI info
[00000051:00000051:(0000:0000:01ff):0955:(0155:0155:0000:0000)]
[ 6247.135111] tg3 0000:04:00.0 enp4s0: Link is down
[ 6250.868825] tg3 0000:04:00.0 enp4s0: Link is up at 1000 Mbps, full duplex
[ 6250.868845] tg3 0000:04:00.0 enp4s0: Flow control is on for TX and on for RX
[ 6250.868849] tg3 0000:04:00.0 enp4s0: EEE is enabled

^ permalink raw reply

* [PATCH net] macvlan: Fix performance issues with vlan tagged packets
From: Vladislav Yasevich @ 2017-05-11 15:09 UTC (permalink / raw)
  To: netdev; +Cc: jasowang, mst, Vladislav Yasevich

Macvlan always turns on offload features that have sofware
fallback (NETIF_GSO_SOFTWARE).  This allows much higher guest-guest
communications over macvtap.

However, macvtap does not turn on these features for vlan tagged traffic.
As a result, depending on the HW that mactap is configured on, the
performance of guest-guest communication over a vlan is very
inconsistent.  If the HW supports TSO/UFO over vlans, then the
performance will be fine.  If not, the the performance will suffer
greatly since the VM may continue using TSO/UFO, and will force the host
segment the traffic and possibly overlow the macvtap queue.

This patch adds the always on offloads to vlan_features.  This
makes sure that any vlan tagged traffic between 2 guest will not
be segmented needlessly.

Signed-off-by: Vladislav Yasevich <vyasevic@redhat.com>
---
 drivers/net/macvlan.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index b34eaaa..346ad2f 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -789,10 +789,12 @@ static int macvlan_change_mtu(struct net_device *dev, int new_mtu)
  */
 static struct lock_class_key macvlan_netdev_addr_lock_key;
 
-#define ALWAYS_ON_FEATURES \
-	(NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_GSO_SOFTWARE | NETIF_F_LLTX | \
+#define ALWAYS_ON_OFFLOADS \
+	(NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_GSO_SOFTWARE | \
 	 NETIF_F_GSO_ROBUST)
 
+#define ALWAYS_ON_FEATURES (ALWAYS_ON_OFFLOADS | NETIF_F_LLTX)
+
 #define MACVLAN_FEATURES \
 	(NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_HIGHDMA | NETIF_F_FRAGLIST | \
 	 NETIF_F_GSO | NETIF_F_TSO | NETIF_F_UFO | NETIF_F_LRO | \
@@ -827,6 +829,7 @@ static int macvlan_init(struct net_device *dev)
 	dev->features		|= ALWAYS_ON_FEATURES;
 	dev->hw_features	|= NETIF_F_LRO;
 	dev->vlan_features	= lowerdev->vlan_features & MACVLAN_FEATURES;
+	dev->vlan_features	|= ALWAYS_ON_OFFLOADS;
 	dev->gso_max_size	= lowerdev->gso_max_size;
 	dev->gso_max_segs	= lowerdev->gso_max_segs;
 	dev->hard_header_len	= lowerdev->hard_header_len;
-- 
2.7.4

^ permalink raw reply related

* Re: [PATCH] qed: fix uninitialized data in aRFS intrastructure
From: Arnd Bergmann @ 2017-05-11 15:01 UTC (permalink / raw)
  To: Mintz, Yuval
  Cc: David S. Miller, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
In-Reply-To: <BLUPR0701MB20046B7EA7273C97047B02F28DED0@BLUPR0701MB2004.namprd07.prod.outlook.com>

On Thu, May 11, 2017 at 4:37 PM, Mintz, Yuval <Yuval.Mintz@cavium.com> wrote:
>> > For the most part - I'm almost all in favor of this change.
>> > But just to make it clear - the actual fix could have been a one-liner, right?
>> > The rest are style changes.
>
>> Correct. Having the correct length in the memset is a sufficient fix for the warning,
>> but it felt wrong to send it since the root of the problem seems to be the
>> complexity of the code that was hiding it.
>
> ...
>
>> Generally speaking, feel free to treat any of my compile-time warning fix
>> patches as simple bug reports and apply a different fix that seems more
>> appropriate. I mainly send it in patch form since that seems to be the
>> quickest way to address any issues.
>
> Sure.
>
> Once net-next is re-opened I intend to push our next FW version which
> is also going to change some of the aRFS related configurations.
>
> So I think we should stick to the single-liner fix for now,
> and I'll revise the style [if still needed; I'll have to check] on that submission.

Sounds good, thanks!

     Arnd

^ permalink raw reply

* Re: [PATCH] net/smc: mark as BROKEN due to remote memory exposure
From: Bart Van Assche @ 2017-05-11 14:57 UTC (permalink / raw)
  To: hch@lst.de, davem@davemloft.net
  Cc: netdev@vger.kernel.org, linux-rdma@vger.kernel.org,
	stable@vger.kernel.org, ubraun@linux.vnet.ibm.com
In-Reply-To: <20170510072627.12060-1-hch@lst.de>

On Wed, 2017-05-10 at 09:26 +0200, Christoph Hellwig wrote:
> The driver has a lot of quality issues due to the lack of RDMA-side
> review, and explicitly bypasses APIs to register all memory once a
> connection is made, and thus allows remote access to memoery.
> 
> Mark it as broken until at least that part is fixed.

Since this is the only way to get the BROKEN marker in the v4.11 stable
kernel series:

Acked-by: Bart Van Assche <bart.vanassche@sandisk.com>

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox