** Description changed:
+ [Impact]
+ When doing MOD by 1 with a immediate/constant divisor on PPC, the JIT will
produce code that returns the dividend, just like a division, instead of 0.
+
+ Both eBPF and cBPF will fail as well when doing such operations.
+
+ [Test case]
+ $ cat bpf-mod1.c
+ #include <linux/bpf.h>
+ #include <unistd.h>
+ #include <sys/syscall.h>
+ #include <sys/socket.h>
+ #include <stdio.h>
+ #include <sys/prctl.h>
+ #include <stdlib.h>
+ #include <errno.h>
+ #include <limits.h>
+ #include <err.h>
+ #include <string.h>
+ #include <linux/filter.h>
+
+ #define ARRAY_SIZE(array) (sizeof(array)/sizeof(array[0]))
+
+ static int pair[2];
+
+ static int attach()
+ {
+ int r;
+
+ struct sock_filter insn[] = {
+ { BPF_LD | BPF_W | BPF_ABS, 0, 0, 0 },
+ { BPF_ALU | BPF_MOD, 0, 0, 1 },
+ { BPF_RET | BPF_A, 0, 0, 0 },
+ };
+
+ struct sock_fprog prog = {};
+ prog.filter = insn;
+ prog.len = ARRAY_SIZE(insn);
+
+ socketpair(AF_UNIX, SOCK_DGRAM, 0, pair);
+ setsockopt(pair[1], SOL_SOCKET, SO_ATTACH_FILTER, &prog,
sizeof(prog));
+ return 0;
+ }
+
+ int main(int argc, char **argv)
+ {
+ int buf[5];
+ int r;
+ r = attach();
+ if (r < 0) {
+ err(1, "function will error out already");
+ }
+ write(pair[0], "hello", 5);
+ r = recv(pair[1], buf, 5, MSG_DONTWAIT);
+ if (r != -1 || errno != EAGAIN) {
+ err(1, "program failed");
+ }
+ return 0;
+ }
+ $ gcc -o bpf-mod1 bpf-mod1.c
+ $ ./bpf-mod1
+ cbpf-mod1: program failed: Success
+
+ After fix:
+ $ ./bpf-mod1
+ $ echo $?
+ 0
+
+ [Potential regression]
+ BPF programs might be misbehave on ppc64el.
+
+ ========================================================
+
This is a scripted bug report about ADT failures while running linux
tests for linux/5.4.0-90.101 on focal. Whether this is caused by the
dep8 tests of the tested source or the kernel has yet to be determined.
-
Consistently failing on Focal/linux 5.4.0-90.101
13:15:26 DEBUG| [stdout] # selftests: net: test_bpf.sh
13:15:27 DEBUG| [stdout] # test_bpf: [FAIL]
13:15:27 DEBUG| [stdout] not ok 9 selftests: net: test_bpf.sh # exit=1
-
Testing failed on:
ppc64el:
https://autopkgtest.ubuntu.com/results/autopkgtest-focal/focal/ppc64el/l/linux/20211021_141544_eda49@/log.gz
--
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1948351
Title:
ppc64 BPF JIT mod by 1 will not return 0
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1948351/+subscriptions
--
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs