lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 8 Feb 2018 13:37:08 +0100
From:   Daniel Borkmann <daniel@...earbox.net>
To:     Naresh Kamboju <naresh.kamboju@...aro.org>, netdev@...r.kernel.org
Cc:     deller@....de, davem@...emloft.net, kraig@...gle.com,
        alexei.starovoitov@...il.com
Subject: Re: selftests: net: reuseport_bpf failed intermittently

On 02/08/2018 12:41 PM, Naresh Kamboju wrote:
> selftests/net/reuseport_bpf FAILED in full run on x86_64 and the
> independent test execution resulted as PASS.
> 
> Test failed output log:
> -----------------------------
> Testing too many filters...
> Testing filters on non-SO_REUSEPORT socket...
> ./reuseport_bpf : ebpf error: Operation not permitted
> 
> One more experiment,
> The same test case "reuseport_bpf" run 10 times in a row.
> The first run pass and other runs failed.
> 
> Running tests for 10 times
> + cd /opt/kselftests/mainline/net
> + ./reuseport_bpf
[...]
> ---- IPv6 TCP w/ mapped IPv4 ----
> Testing EBPF mod 10...
> Reprograming, testing mod 5...
> Testing CBPF mod 10...
> Reprograming, testing mod 5...
> Testing filter add without bind...
> SUCCESS
> + echo PASS
> PASS
> + ./reuseport_bpf
> ---- IPv4 UDP ----
> Testing EBPF mod 10...
> Reprograming, testing mod 5...
> ./reuseport_bpf: ebpf error. log:
> 0: (bf) r6 = r1
> 1: (20) r0 = *(u32 *)skb[0]
> 2: (97) r0 %= 10
> 3: (95) exit
> processed 4 insns
> : Operation not permitted
> + echo FAIL
> FAIL
> + ./reuseport_bpf
> ---- IPv4 UDP ----
> Testing EBPF mod 10...
> Reprograming, testing mod 5...
> ./reuseport_bpf: ebpf error. log:
> 0: (bf) r6 = r1
> 1: (20) r0 = *(u32 *)skb[0]
> 2: (97) r0 %= 10
> 3: (95) exit
> processed 4 insns
> : Operation not permitted
> + echo FAIL
> FAIL
> + ./reuseport_bpf
> ---- IPv4 UDP ----
> Testing EBPF mod 10...
> Reprograming, testing mod 5...
> Testing EBPF mod 20...
> Reprograming, testing mod 10...
> Testing CBPF mod 10...
> Reprograming, testing mod 5...
> Testing CBPF mod 20...
> Reprograming, testing mod 10...
> Testing too many filters...
> Testing filters on non-SO_REUSEPORT socket...
> ---- IPv6 UDP ----
> Testing EBPF mod 10...
> Reprograming, testing mod 5...
> Testing EBPF mod 20...
> Reprograming, testing mod 10...
> Testing CBPF mod 10...
> Reprograming, testing mod 5...
> Testing CBPF mod 20...
> Reprograming, testing mod 10...
> Testing too many filters...
> Testing filters on non-SO_REUSEPORT socket...
> ---- IPv6 UDP w/ mapped IPv4 ----
> Testing EBPF mod 20...
> Reprograming, testing mod 10...
> Testing EBPF mod 10...
> Reprograming, testing mod 5...
> Testing CBPF mod 10...
> Reprograming, testing mod 5...
> Testing CBPF mod 20...
> Reprograming, testing mod 10...
> ---- IPv4 TCP ----
> Testing EBPF mod 10...
> ./reuseport_bpf: failed to bind send socket: Address already in use
> + echo FAIL
[...]
> 
> Please refer this bug link for more details
> https://bugs.linaro.org/show_bug.cgi?id=3502
> 
> We are using x86_64 machine and the rootfs is mounted on NFS.
> Please guide me in solving this test case failure.

[ +Alexei ]

Below should fix these two issues. (For checking the bpf selftests, we should
probably adapt similar scheme with ctor/dtor to act more graceful.)

 tools/testing/selftests/net/reuseport_bpf.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/net/reuseport_bpf.c b/tools/testing/selftests/net/reuseport_bpf.c
index 4a82174..cad14cd 100644
--- a/tools/testing/selftests/net/reuseport_bpf.c
+++ b/tools/testing/selftests/net/reuseport_bpf.c
@@ -21,6 +21,7 @@
 #include <sys/epoll.h>
 #include <sys/types.h>
 #include <sys/socket.h>
+#include <sys/resource.h>
 #include <unistd.h>

 #ifndef ARRAY_SIZE
@@ -190,11 +191,14 @@ static void send_from(struct test_params p, uint16_t sport, char *buf,
 	struct sockaddr * const saddr = new_any_sockaddr(p.send_family, sport);
 	struct sockaddr * const daddr =
 		new_loopback_sockaddr(p.send_family, p.recv_port);
-	const int fd = socket(p.send_family, p.protocol, 0);
+	const int fd = socket(p.send_family, p.protocol, 0), one = 1;

 	if (fd < 0)
 		error(1, errno, "failed to create send socket");

+	if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)))
+		error(1, errno, "failed to set reuseaddr");
+
 	if (bind(fd, saddr, sockaddr_size()))
 		error(1, errno, "failed to bind send socket");

@@ -433,6 +437,21 @@ void enable_fastopen(void)
 	}
 }

+static struct rlimit rlim_old, rlim_new;
+
+static  __attribute__((constructor)) void main_ctor(void)
+{
+	getrlimit(RLIMIT_MEMLOCK, &rlim_old);
+	rlim_new.rlim_cur = rlim_old.rlim_cur + (1UL << 20);
+	rlim_new.rlim_max = rlim_old.rlim_max + (1UL << 20);
+	setrlimit(RLIMIT_MEMLOCK, &rlim_new);
+}
+
+static __attribute__((destructor)) void main_dtor(void)
+{
+	setrlimit(RLIMIT_MEMLOCK, &rlim_old);
+}
+
 int main(void)
 {
 	fprintf(stderr, "---- IPv4 UDP ----\n");
-- 
2.9.5

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ