This bug is awaiting verification that the linux/5.4.0-91.102 kernel in
-proposed solves the problem. Please test the kernel and update this bug
with the results. If the problem is solved, change the tag
'verification-needed-focal' to 'verification-done-focal'. If the problem
still exists, change the tag 'verification-needed-focal' to
'verification-failed-focal'.

If verification is not done by 5 working days from today, this fix will
be dropped from the source code, and this bug will be closed.

See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how
to enable and use -proposed. Thank you!


** Tags added: verification-needed-bionic

-- 
You received this bug notification because you are a member of Kernel
Packages, which is subscribed to linux in Ubuntu.
https://bugs.launchpad.net/bugs/1948351

Title:
  ppc64 BPF JIT mod by 1 will not return 0

Status in linux package in Ubuntu:
  Incomplete
Status in linux source package in Bionic:
  Fix Committed
Status in linux source package in Focal:
  Fix Committed
Status in linux source package in Hirsute:
  Fix Committed
Status in linux source package in Impish:
  Fix Committed

Bug description:
  [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

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1948351/+subscriptions


-- 
Mailing list: https://launchpad.net/~kernel-packages
Post to     : kernel-packages@lists.launchpad.net
Unsubscribe : https://launchpad.net/~kernel-packages
More help   : https://help.launchpad.net/ListHelp

Reply via email to