1. 11 1月, 2018 1 次提交
    • D
      bpf: arsh is not supported in 32 bit alu thus reject it · 7891a87e
      Daniel Borkmann 提交于
      The following snippet was throwing an 'unknown opcode cc' warning
      in BPF interpreter:
      
        0: (18) r0 = 0x0
        2: (7b) *(u64 *)(r10 -16) = r0
        3: (cc) (u32) r0 s>>= (u32) r0
        4: (95) exit
      
      Although a number of JITs do support BPF_ALU | BPF_ARSH | BPF_{K,X}
      generation, not all of them do and interpreter does neither. We can
      leave existing ones and implement it later in bpf-next for the
      remaining ones, but reject this properly in verifier for the time
      being.
      
      Fixes: 17a52670 ("bpf: verifier (add verifier core)")
      Reported-by: syzbot+93c4904c5c70348a6890@syzkaller.appspotmail.com
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      7891a87e
  2. 07 1月, 2018 1 次提交
  3. 31 12月, 2017 2 次提交
  4. 28 12月, 2017 1 次提交
  5. 24 12月, 2017 1 次提交
    • T
      x86/ldt: Make the LDT mapping RO · 9f5cb6b3
      Thomas Gleixner 提交于
      Now that the LDT mapping is in a known area when PAGE_TABLE_ISOLATION is
      enabled its a primary target for attacks, if a user space interface fails
      to validate a write address correctly. That can never happen, right?
      
      The SDM states:
      
          If the segment descriptors in the GDT or an LDT are placed in ROM, the
          processor can enter an indefinite loop if software or the processor
          attempts to update (write to) the ROM-based segment descriptors. To
          prevent this problem, set the accessed bits for all segment descriptors
          placed in a ROM. Also, remove operating-system or executive code that
          attempts to modify segment descriptors located in ROM.
      
      So its a valid approach to set the ACCESS bit when setting up the LDT entry
      and to map the table RO. Fixup the selftest so it can handle that new mode.
      
      Remove the manual ACCESS bit setter in set_tls_desc() as this is now
      pointless. Folded the patch from Peter Ziljstra.
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Juergen Gross <jgross@suse.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      9f5cb6b3
  6. 23 12月, 2017 3 次提交
  7. 22 12月, 2017 1 次提交
  8. 21 12月, 2017 4 次提交
    • S
      tools/kvm_stat: sort '-f help' output · aa12f594
      Stefan Raspl 提交于
      Sort the fields returned by specifying '-f help' on the command line.
      While at it, simplify the code a bit, indent the output and eliminate an
      extra blank line at the beginning.
      Signed-off-by: NStefan Raspl <raspl@linux.vnet.ibm.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      aa12f594
    • A
      bpf: do not allow root to mangle valid pointers · 82abbf8d
      Alexei Starovoitov 提交于
      Do not allow root to convert valid pointers into unknown scalars.
      In particular disallow:
       ptr &= reg
       ptr <<= reg
       ptr += ptr
      and explicitly allow:
       ptr -= ptr
      since pkt_end - pkt == length
      
      1.
      This minimizes amount of address leaks root can do.
      In the future may need to further tighten the leaks with kptr_restrict.
      
      2.
      If program has such pointer math it's likely a user mistake and
      when verifier complains about it right away instead of many instructions
      later on invalid memory access it's easier for users to fix their progs.
      
      3.
      when register holding a pointer cannot change to scalar it allows JITs to
      optimize better. Like 32-bit archs could use single register for pointers
      instead of a pair required to hold 64-bit scalars.
      
      4.
      reduces architecture dependent behavior. Since code:
      r1 = r10;
      r1 &= 0xff;
      if (r1 ...)
      will behave differently arm64 vs x64 and offloaded vs native.
      
      A significant chunk of ptr mangling was allowed by
      commit f1174f77 ("bpf/verifier: rework value tracking")
      yet some of it was allowed even earlier.
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      82abbf8d
    • J
      selftests/bpf: add tests for recent bugfixes · 2255f8d5
      Jann Horn 提交于
      These tests should cover the following cases:
      
       - MOV with both zero-extended and sign-extended immediates
       - implicit truncation of register contents via ALU32/MOV32
       - implicit 32-bit truncation of ALU32 output
       - oversized register source operand for ALU32 shift
       - right-shift of a number that could be positive or negative
       - map access where adding the operation size to the offset causes signed
         32-bit overflow
       - direct stack access at a ~4GiB offset
      
      Also remove the F_LOAD_WITH_STRICT_ALIGNMENT flag from a bunch of tests
      that should fail independent of what flags userspace passes.
      Signed-off-by: NJann Horn <jannh@google.com>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      2255f8d5
    • N
      selftests: net: Adding config fragment CONFIG_NUMA=y · 1c8e77fb
      Naresh Kamboju 提交于
      kernel config fragement CONFIG_NUMA=y is need for reuseport_bpf_numa.
      Signed-off-by: NNaresh Kamboju <naresh.kamboju@linaro.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      1c8e77fb
  9. 20 12月, 2017 1 次提交
  10. 19 12月, 2017 2 次提交
    • J
      usbip: fix usbip bind writing random string after command in match_busid · 544c4605
      Juan Zea 提交于
      usbip bind writes commands followed by random string when writing to
      match_busid attribute in sysfs, caused by using full variable size
      instead of string length.
      Signed-off-by: NJuan Zea <juan.zea@qindel.com>
      Acked-by: NShuah Khan <shuahkh@osg.samsung.com>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      544c4605
    • H
      bpf: fix broken BPF selftest build on s390 · c682ccc4
      Hendrik Brueckner 提交于
      With 720f228e ("bpf: fix broken BPF selftest build") the
      inclusion of arch-specific header files changed.  Including the
      asm/bpf_perf_event.h on s390, correctly includes the s390 specific
      header file.  This header file tries then to include the s390
      asm/ptrace.h and the build fails with:
      
      cc -Wall -O2 -I../../../include/uapi -I../../../lib -I../../../../include/generated  -I../../../include    test_verifier.c
      +/root/git/linux/tools/testing/selftests/bpf/libbpf.a /root/git/linux/tools/testing/selftests/bpf/cgroup_helpers.c -lcap -lelf -o
      +/root/git/linux/tools/testing/selftests/bpf/test_verifier
      In file included from ../../../include/uapi/asm/bpf_perf_event.h:4:0,
                       from ../../../include/uapi/linux/bpf_perf_event.h:11,
                       from test_verifier.c:29:
      ../../../include/uapi/../../arch/s390/include/uapi/asm/bpf_perf_event.h:7:9: error: unknown type name 'user_pt_regs'
       typedef user_pt_regs bpf_user_pt_regs_t;
               ^~~~~~~~~~~~
      make: *** [../lib.mk:109: /root/git/linux/tools/testing/selftests/bpf/test_verifier] Error 1
      
      This is caused by a recent update to the s390 asm/ptrace.h file
      that is not (yet) available in the local installation.  That means,
      the s390 asm/ptrace.h must be included from the tools/arch/s390
      directory.
      
      Because there is no proper framework to deal with asm specific
      includes in tools/, slightly modify the s390 asm/bpf_perf_event.h
      to include the local ptrace.h header file.
      
      See also discussion on
      https://marc.info/?l=linux-s390&m=151359424420691&w=2
      
      Please note that this needs to be preserved until tools/ is able to
      correctly handle asm specific headers.
      
      References: https://marc.info/?l=linux-s390&m=151359424420691&w=2
      Fixes: 720f228e ("bpf: fix broken BPF selftest build")
      Signed-off-by: NHendrik Brueckner <brueckner@linux.vnet.ibm.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
      Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      c682ccc4
  11. 18 12月, 2017 4 次提交
    • A
      tools arch s390: Do not include header files from the kernel sources · 10b9baa7
      Arnaldo Carvalho de Melo 提交于
      Long ago we decided to be verbotten including files in the kernel git
      sources from tools/ living source code, to avoid disturbing kernel
      development (and perf's and other tools/) when, say, a kernel hacker
      adds something, tests everything but tools/ and have tools/ build
      broken.
      
      This got broken recently by s/390, fix it by copying
      arch/s390/include/uapi/asm/perf_regs.h to tools/arch/s390/include/uapi/asm/,
      making this one be used by means of <asm/perf_regs.h> and updating
      tools/perf/check_headers.sh to make sure we are notified when the
      original changes, so that we can check if anything is needed on the
      tooling side.
      
      This would have been caught by the 'tarkpg' test entry in:
      
      $ make -C tools/perf build-test
      
      When run on a s/390 build system or container.
      Acked-by: NHeiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
      Cc: Thomas Richter <tmricht@linux.vnet.ibm.com>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Fixes: f704ef44 ("s390/perf: add support for perf_regs and libdw")
      Link: https://lkml.kernel.org/n/tip-n57139ic0v9uffx8wdqi3d8a@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      10b9baa7
    • B
      perf jvmti: Generate correct debug information for inlined code · ca58d7e6
      Ben Gainey 提交于
      tools/perf/jvmti is broken in so far as it generates incorrect debug
      information. Specifically it attributes all debug lines to the original
      method being output even in the case that some code is being inlined
      from elsewhere.  This patch fixes the issue.
      
      To test (from within linux/tools/perf):
      
      export JDIR=/usr/lib/jvm/java-8-openjdk-amd64/
      make
      cat << __EOF > Test.java
      public class Test
      {
          private StringBuilder b = new StringBuilder();
      
          private void loop(int i, String... args)
          {
              for (String a : args)
                  b.append(a);
      
              long hc = b.hashCode() * System.nanoTime();
      
              b = new StringBuilder();
              b.append(hc);
      
              System.out.printf("Iteration %d = %d\n", i, hc);
          }
      
          public void run(String... args)
          {
              for (int i = 0; i < 10000; ++i)
              {
                  loop(i, args);
              }
          }
      
          public static void main(String... args)
          {
              Test t = new Test();
              t.run(args);
          }
      }
      __EOF
      $JDIR/bin/javac Test.java
      ./perf record -F 10000 -g -k mono $JDIR/bin/java -agentpath:`pwd`/libperf-jvmti.so Test
      ./perf inject --jit -i perf.data -o perf.data.jitted
      ./perf annotate -i perf.data.jitted --stdio | grep Test\.java: | sort -u
      
      Before this patch, Test.java line numbers get reported that are greater
      than the number of lines in the Test.java file.  They come from the
      source file of the inlined function, e.g. java/lang/String.java:1085.
      For further validation one can examine those lines in the JDK source
      distribution and confirm that they map to inlined functions called by
      Test.java.
      
      After this patch, the filename of the inlined function is output
      rather than the incorrect original source filename.
      Signed-off-by: NBen Gainey <ben.gainey@arm.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Tested-by: NStephane Eranian <eranian@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ben Gainey <ben.gainey@arm.com>
      Cc: Colin King <colin.king@canonical.com>
      Cc: Darren Hart <dvhart@infradead.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Fixes: 598b7c69 ("perf jit: add source line info support")
      Link: http://lkml.kernel.org/r/20171122182541.d25599a3eb1ada3480d142fa@arm.comSigned-off-by: NKim Phillips <kim.phillips@arm.com>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      ca58d7e6
    • J
      perf tools: Fix up build in hardened environments · 61fb26a6
      Jiri Olsa 提交于
      On Fedora systems the perl and python CFLAGS/LDFLAGS include the
      hardened specs from redhat-rpm-config package. We apply them only for
      perl/python objects, which makes them not compatible with the rest of
      the objects and the build fails with:
      
        /usr/bin/ld: perf-in.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -f
      +PIC
        /usr/bin/ld: libperf.a(libperf-in.o): relocation R_X86_64_32S against `.text' can not be used when making a shared object; recompile w
      +ith -fPIC
        /usr/bin/ld: final link failed: Nonrepresentable section on output
        collect2: error: ld returned 1 exit status
        make[2]: *** [Makefile.perf:507: perf] Error 1
        make[1]: *** [Makefile.perf:210: sub-make] Error 2
        make: *** [Makefile:69: all] Error 2
      
      Mainly it's caused by perl/python objects being compiled with:
      
        -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1
      
      which prevent the final link impossible, because it will check
      for 'proper' objects with following option:
      
        -specs=/usr/lib/rpm/redhat/redhat-hardened-ld
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lkml.kernel.org/r/20171204082437.GC30564@kravaSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      61fb26a6
    • J
      perf tools: Use shell function for perl cflags retrieval · 5cfee7a3
      Jiri Olsa 提交于
      Using the shell function for perl CFLAGS retrieval instead of back
      quotes (``). Both execute shell with the command, but the latter is more
      explicit and seems to be the preferred way.
      
      Also we don't have any other use of the back quotes in perf Makefiles.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20171108102739.30338-2-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      5cfee7a3
  12. 16 12月, 2017 1 次提交
  13. 15 12月, 2017 4 次提交
  14. 14 12月, 2017 10 次提交
  15. 13 12月, 2017 2 次提交
    • M
      tools/lib/lockdep: Add missing declaration of 'pr_cont()' · 92ccc262
      Mengting Zhang 提交于
      Commit:
      
        681fbec8 ("lockdep: Use consistent printing primitives")
      
      has moved lockdep away from using printk() for printing.
      
      The commit added usage of pr_cont() which wasn't wrapped in the
      userspace headers, causing the following warning for the
      liblockdep build:
      
      	../../../kernel/locking/lockdep.c:3544:2: warning: implicit declaration of function 'pr_cont' [-Wimplicit-function-declaration]
      
      Adding an empty declaration of 'pr_cont' fixes the problem.
      Signed-off-by: NMengting Zhang <zhangmengting@huawei.com>
      Signed-off-by: NSasha Levin <alexander.levin@verizon.com>
      Reviewed-by: NAlexander Sverdlin <alexander.sverdlin@gmail.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: a.p.zijlstra@chello.nl
      Link: http://lkml.kernel.org/r/20171212181644.11913-2-alexander.levin@verizon.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      92ccc262
    • D
      bpf: fix broken BPF selftest build · 720f228e
      Daniel Borkmann 提交于
      At least on x86_64, the kernel's BPF selftests seemed to have stopped
      to build due to 618e165b ("selftests/bpf: sync kernel headers and
      introduce arch support in Makefile"):
      
        [...]
        In file included from test_verifier.c:29:0:
        ../../../include/uapi/linux/bpf_perf_event.h:11:32:
           fatal error: asm/bpf_perf_event.h: No such file or directory
         #include <asm/bpf_perf_event.h>
                                      ^
        compilation terminated.
        [...]
      
      While pulling in tools/arch/*/include/uapi/asm/bpf_perf_event.h seems
      to work fine, there's no automated fall-back logic right now that would
      do the same out of tools/include/uapi/asm-generic/bpf_perf_event.h. The
      usual convention today is to add a include/[uapi/]asm/ equivalent that
      would pull in the correct arch header or generic one as fall-back, all
      ifdef'ed based on compiler target definition. It's similarly done also
      in other cases such as tools/include/asm/barrier.h, thus adapt the same
      here.
      
      Fixes: 618e165b ("selftests/bpf: sync kernel headers and introduce arch support in Makefile")
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      Cc: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
      Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
      Acked-by: NAlexei Starovoitov <ast@kernel.org>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      720f228e
  16. 12 12月, 2017 2 次提交