1. 06 3月, 2020 1 次提交
  2. 11 2月, 2020 1 次提交
  3. 04 2月, 2020 1 次提交
    • M
      kbuild: rename hostprogs-y/always to hostprogs/always-y · 5f2fb52f
      Masahiro Yamada 提交于
      In old days, the "host-progs" syntax was used for specifying host
      programs. It was renamed to the current "hostprogs-y" in 2004.
      
      It is typically useful in scripts/Makefile because it allows Kbuild to
      selectively compile host programs based on the kernel configuration.
      
      This commit renames like follows:
      
        always       ->  always-y
        hostprogs-y  ->  hostprogs
      
      So, scripts/Makefile will look like this:
      
        always-$(CONFIG_BUILD_BIN2C) += ...
        always-$(CONFIG_KALLSYMS)    += ...
            ...
        hostprogs := $(always-y) $(always-m)
      
      I think this makes more sense because a host program is always a host
      program, irrespective of the kernel configuration. We want to specify
      which ones to compile by CONFIG options, so always-y will be handier.
      
      The "always", "hostprogs-y", "hostprogs-m" will be kept for backward
      compatibility for a while.
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      5f2fb52f
  4. 01 2月, 2020 2 次提交
    • D
      kcov: ignore fault-inject and stacktrace · 43e76af8
      Dmitry Vyukov 提交于
      Don't instrument 3 more files that contain debugging facilities and
      produce large amounts of uninteresting coverage for every syscall.
      
      The following snippets are sprinkled all over the place in kcov traces
      in a debugging kernel.  We already try to disable instrumentation of
      stack unwinding code and of most debug facilities.  I guess we did not
      use fault-inject.c at the time, and stacktrace.c was somehow missed (or
      something has changed in kernel/configs).  This change both speeds up
      kcov (kernel doesn't need to store these PCs, user-space doesn't need to
      process them) and frees trace buffer capacity for more useful coverage.
      
        should_fail
        lib/fault-inject.c:149
        fail_dump
        lib/fault-inject.c:45
      
        stack_trace_save
        kernel/stacktrace.c:124
        stack_trace_consume_entry
        kernel/stacktrace.c:86
        stack_trace_consume_entry
        kernel/stacktrace.c:89
        ... a hundred frames skipped ...
        stack_trace_consume_entry
        kernel/stacktrace.c:93
        stack_trace_consume_entry
        kernel/stacktrace.c:86
      
      Link: http://lkml.kernel.org/r/20200116111449.217744-1-dvyukov@gmail.comSigned-off-by: NDmitry Vyukov <dvyukov@google.com>
      Reviewed-by: NAndrey Konovalov <andreyknvl@google.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      43e76af8
    • M
      lib/zlib: add s390 hardware support for kernel zlib_deflate · aa5b395b
      Mikhail Zaslonko 提交于
      Patch series "S390 hardware support for kernel zlib", v3.
      
      With IBM z15 mainframe the new DFLTCC instruction is available.  It
      implements deflate algorithm in hardware (Nest Acceleration Unit - NXU)
      with estimated compression and decompression performance orders of
      magnitude faster than the current zlib.
      
      This patchset adds s390 hardware compression support to kernel zlib.
      The code is based on the userspace zlib implementation:
      
      	https://github.com/madler/zlib/pull/410
      
      The coding style is also preserved for future maintainability.  There is
      only limited set of userspace zlib functions represented in kernel.
      Apart from that, all the memory allocation should be performed in
      advance.  Thus, the workarea structures are extended with the parameter
      lists required for the DEFLATE CONVENTION CALL instruction.
      
      Since kernel zlib itself does not support gzip headers, only Adler-32
      checksum is processed (also can be produced by DFLTCC facility).  Like
      it was implemented for userspace, kernel zlib will compress in hardware
      on level 1, and in software on all other levels.  Decompression will
      always happen in hardware (when enabled).
      
      Two DFLTCC compression calls produce the same results only when they
      both are made on machines of the same generation, and when the
      respective buffers have the same offset relative to the start of the
      page.  Therefore care should be taken when using hardware compression
      when reproducible results are desired.  However it does always produce
      the standard conform output which can be inflated anyway.
      
      The new kernel command line parameter 'dfltcc' is introduced to
      configure s390 zlib hardware support:
      
          Format: { on | off | def_only | inf_only | always }
           on:       s390 zlib hardware support for compression on
                     level 1 and decompression (default)
           off:      No s390 zlib hardware support
           def_only: s390 zlib hardware support for deflate
                     only (compression on level 1)
           inf_only: s390 zlib hardware support for inflate
                     only (decompression)
           always:   Same as 'on' but ignores the selected compression
                     level always using hardware support (used for debugging)
      
      The main purpose of the integration of the NXU support into the kernel
      zlib is the use of hardware deflate in btrfs filesystem with on-the-fly
      compression enabled.  Apart from that, hardware support can also be used
      during boot for decompressing the kernel or the ramdisk image
      
      With the patch for btrfs expanding zlib buffer from 1 to 4 pages (patch
      6) the following performance results have been achieved using the
      ramdisk with btrfs.  These are relative numbers based on throughput rate
      and compression ratio for zlib level 1:
      
        Input data              Deflate rate   Inflate rate   Compression ratio
                                NXU/Software   NXU/Software   NXU/Software
        stream of zeroes        1.46           1.02           1.00
        random ASCII data       10.44          3.00           0.96
        ASCII text (dickens)    6,21           3.33           0.94
        binary data (vmlinux)   8,37           3.90           1.02
      
      This means that s390 hardware deflate can provide up to 10 times faster
      compression (on level 1) and up to 4 times faster decompression (refers
      to all compression levels) for btrfs zlib.
      
      Disclaimer: Performance results are based on IBM internal tests using DD
      command-line utility on btrfs on a Fedora 30 based internal driver in
      native LPAR on a z15 system.  Results may vary based on individual
      workload, configuration and software levels.
      
      This patch (of 9):
      
      Create zlib_dfltcc library with the s390 DEFLATE CONVERSION CALL
      implementation and related compression functions.  Update zlib_deflate
      functions with the hooks for s390 hardware support and adjust workspace
      structures with extra parameter lists required for hardware deflate.
      
      Link: http://lkml.kernel.org/r/20200103223334.20669-2-zaslonko@linux.ibm.comSigned-off-by: NIlya Leoshkevich <iii@linux.ibm.com>
      Signed-off-by: NMikhail Zaslonko <zaslonko@linux.ibm.com>
      Co-developed-by: NIlya Leoshkevich <iii@linux.ibm.com>
      Cc: Chris Mason <clm@fb.com>
      Cc: Christian Borntraeger <borntraeger@de.ibm.com>
      Cc: David Sterba <dsterba@suse.com>
      Cc: Eduard Shishkin <edward6@linux.ibm.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Josef Bacik <josef@toxicpanda.com>
      Cc: Richard Purdie <rpurdie@rpsys.net>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      aa5b395b
  5. 14 1月, 2020 1 次提交
  6. 09 1月, 2020 1 次提交
  7. 17 11月, 2019 1 次提交
    • A
      crypto: chacha - move existing library code into lib/crypto · 5fb8ef25
      Ard Biesheuvel 提交于
      Currently, our generic ChaCha implementation consists of a permute
      function in lib/chacha.c that operates on the 64-byte ChaCha state
      directly [and which is always included into the core kernel since it
      is used by the /dev/random driver], and the crypto API plumbing to
      expose it as a skcipher.
      
      In order to support in-kernel users that need the ChaCha streamcipher
      but have no need [or tolerance] for going through the abstractions of
      the crypto API, let's expose the streamcipher bits via a library API
      as well, in a way that permits the implementation to be superseded by
      an architecture specific one if provided.
      
      So move the streamcipher code into a separate module in lib/crypto,
      and expose the init() and crypt() routines to users of the library.
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      5fb8ef25
  8. 07 11月, 2019 1 次提交
  9. 05 11月, 2019 1 次提交
  10. 02 11月, 2019 1 次提交
    • D
      lib/list-test: add a test for the 'list' doubly linked list · ea2dd7c0
      David Gow 提交于
      Add a KUnit test for the kernel doubly linked list implementation in
      include/linux/list.h
      
      Each test case (list_test_x) is focused on testing the behaviour of the
      list function/macro 'x'. None of the tests pass invalid lists to these
      macros, and so should behave identically with DEBUG_LIST enabled and
      disabled.
      
      Note that, at present, it only tests the list_ types (not the
      singly-linked hlist_), and does not yet test all of the
      list_for_each_entry* macros (and some related things like
      list_prepare_entry).
      
      Ignoring checkpatch.pl spurious errors related to its handling of for_each
      and other list macros. checkpatch.pl expects anything with for_each in its
      name to be a loop and expects that the open brace is placed on the same
      line as for a for loop. In this case, test case naming scheme includes
      name of the macro it is testing, which results in the spurious errors.
      Commit message updated by Shuah Khan <skhan@linuxfoundation.org>
      Signed-off-by: NDavid Gow <davidgow@google.com>
      Reviewed-by: NBrendan Higgins <brendanhiggins@google.com>
      Tested-by: NBrendan Higgins <brendanhiggins@google.com>
      Signed-off-by: NShuah Khan <skhan@linuxfoundation.org>
      ea2dd7c0
  11. 17 10月, 2019 1 次提交
    • R
      printf: add support for printing symbolic error names · 57f5677e
      Rasmus Villemoes 提交于
      It has been suggested several times to extend vsnprintf() to be able
      to convert the numeric value of ENOSPC to print "ENOSPC". This
      implements that as a %p extension: With %pe, one can do
      
        if (IS_ERR(foo)) {
          pr_err("Sorry, can't do that: %pe\n", foo);
          return PTR_ERR(foo);
        }
      
      instead of what is seen in quite a few places in the kernel:
      
        if (IS_ERR(foo)) {
          pr_err("Sorry, can't do that: %ld\n", PTR_ERR(foo));
          return PTR_ERR(foo);
        }
      
      If the value passed to %pe is an ERR_PTR, but the library function
      errname() added here doesn't know about the value, the value is simply
      printed in decimal. If the value passed to %pe is not an ERR_PTR, we
      treat it as an ordinary %p and thus print the hashed value (passing
      non-ERR_PTR values to %pe indicates a bug in the caller, but we can't
      do much about that).
      
      With my embedded hat on, and because it's not very invasive to do,
      I've made it possible to remove this. The errname() function and
      associated lookup tables take up about 3K. For most, that's probably
      quite acceptable and a price worth paying for more readable
      dmesg (once this starts getting used), while for those that disable
      printk() it's of very little use - I don't see a
      procfs/sysfs/seq_printf() file reasonably making use of this - and
      they clearly want to squeeze vmlinux as much as possible. Hence the
      default y if PRINTK.
      
      The symbols to include have been found by massaging the output of
      
        find arch include -iname 'errno*.h' | xargs grep -E 'define\s*E'
      
      In the cases where some common aliasing exists
      (e.g. EAGAIN=EWOULDBLOCK on all platforms, EDEADLOCK=EDEADLK on most),
      I've moved the more popular one (in terms of 'git grep -w Efoo | wc)
      to the bottom so that one takes precedence.
      
      Link: http://lkml.kernel.org/r/20191015190706.15989-1-linux@rasmusvillemoes.dk
      To: "Jonathan Corbet" <corbet@lwn.net>
      To: linux-kernel@vger.kernel.org
      Cc: "Andy Shevchenko" <andy.shevchenko@gmail.com>
      Cc: "Andrew Morton" <akpm@linux-foundation.org>
      Cc: "Joe Perches" <joe@perches.com>
      Cc: linux-doc@vger.kernel.org
      Signed-off-by: NRasmus Villemoes <linux@rasmusvillemoes.dk>
      Acked-by: NUwe Kleine-König <uwe@kleine-koenig.org>
      Reviewed-by: NPetr Mladek <pmladek@suse.com>
      [andy.shevchenko@gmail.com: use abs()]
      Acked-by: NAndy Shevchenko <andy.shevchenko@gmail.com>
      Signed-off-by: NPetr Mladek <pmladek@suse.com>
      57f5677e
  12. 01 10月, 2019 1 次提交
  13. 14 8月, 2019 1 次提交
    • M
      lib: Remove redundant ftrace flag removal · 41b57d1b
      Mark Rutland 提交于
      Since architectures can implement ftrace using a variety of mechanisms,
      generic code should always use CC_FLAGS_FTRACE rather than assuming that
      ftrace is built using -pg.
      
      Since commit:
      
        2464a609 ("ftrace: do not trace library functions")
      
      ... lib/Makefile has removed CC_FLAGS_FTRACE from KBUILD_CFLAGS, so ftrace is
      disabled for all files under lib/.
      
      Given that, we shouldn't explicitly remove -pg when building
      lib/string.o, as this is redundant and bad form.
      
      Clean things up accordingly.
      
      There should be no functional change as a result of this patch.
      Signed-off-by: NMark Rutland <mark.rutland@arm.com>
      Signed-off-by: NBorislav Petkov <bp@suse.de>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Coly Li <colyli@suse.de>
      Cc: Gary R Hook <gary.hook@amd.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Kent Overstreet <kent.overstreet@gmail.com>
      Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
      Cc: Matthew Wilcox <willy@infradead.org>
      Link: https://lkml.kernel.org/r/20190806162539.51918-1-mark.rutland@arm.com
      41b57d1b
  14. 03 8月, 2019 1 次提交
    • A
      ubsan: build ubsan.c more conservatively · af700eae
      Arnd Bergmann 提交于
      objtool points out several conditions that it does not like, depending
      on the combination with other configuration options and compiler
      variants:
      
      stack protector:
        lib/ubsan.o: warning: objtool: __ubsan_handle_type_mismatch()+0xbf: call to __stack_chk_fail() with UACCESS enabled
        lib/ubsan.o: warning: objtool: __ubsan_handle_type_mismatch_v1()+0xbe: call to __stack_chk_fail() with UACCESS enabled
      
      stackleak plugin:
        lib/ubsan.o: warning: objtool: __ubsan_handle_type_mismatch()+0x4a: call to stackleak_track_stack() with UACCESS enabled
        lib/ubsan.o: warning: objtool: __ubsan_handle_type_mismatch_v1()+0x4a: call to stackleak_track_stack() with UACCESS enabled
      
      kasan:
        lib/ubsan.o: warning: objtool: __ubsan_handle_type_mismatch()+0x25: call to memcpy() with UACCESS enabled
        lib/ubsan.o: warning: objtool: __ubsan_handle_type_mismatch_v1()+0x25: call to memcpy() with UACCESS enabled
      
      The stackleak and kasan options just need to be disabled for this file
      as we do for other files already.  For the stack protector, we already
      attempt to disable it, but this fails on clang because the check is
      mixed with the gcc specific -fno-conserve-stack option.  According to
      Andrey Ryabinin, that option is not even needed, dropping it here fixes
      the stackprotector issue.
      
      Link: http://lkml.kernel.org/r/20190722125139.1335385-1-arnd@arndb.de
      Link: https://lore.kernel.org/lkml/20190617123109.667090-1-arnd@arndb.de/t/
      Link: https://lore.kernel.org/lkml/20190722091050.2188664-1-arnd@arndb.de/t/
      Fixes: d08965a2 ("x86/uaccess, ubsan: Fix UBSAN vs. SMAP")
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Reviewed-by: NAndrey Ryabinin <aryabinin@virtuozzo.com>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      af700eae
  15. 17 7月, 2019 1 次提交
  16. 02 7月, 2019 1 次提交
  17. 26 6月, 2019 1 次提交
  18. 20 6月, 2019 1 次提交
  19. 17 6月, 2019 1 次提交
  20. 15 5月, 2019 1 次提交
  21. 03 5月, 2019 1 次提交
  22. 30 4月, 2019 1 次提交
    • G
      x86/mm/mem_encrypt: Disable all instrumentation for early SME setup · b51ce374
      Gary Hook 提交于
      Enablement of AMD's Secure Memory Encryption feature is determined very
      early after start_kernel() is entered. Part of this procedure involves
      scanning the command line for the parameter 'mem_encrypt'.
      
      To determine intended state, the function sme_enable() uses library
      functions cmdline_find_option() and strncmp(). Their use occurs early
      enough such that it cannot be assumed that any instrumentation subsystem
      is initialized.
      
      For example, making calls to a KASAN-instrumented function before KASAN
      is set up will result in the use of uninitialized memory and a boot
      failure.
      
      When AMD's SME support is enabled, conditionally disable instrumentation
      of these dependent functions in lib/string.c and arch/x86/lib/cmdline.c.
      
       [ bp: Get rid of intermediary nostackp var and cleanup whitespace. ]
      
      Fixes: aca20d54 ("x86/mm: Add support to make use of Secure Memory Encryption")
      Reported-by: NLi RongQing <lirongqing@baidu.com>
      Signed-off-by: NGary R Hook <gary.hook@amd.com>
      Signed-off-by: NBorislav Petkov <bp@suse.de>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Boris Brezillon <bbrezillon@kernel.org>
      Cc: Coly Li <colyli@suse.de>
      Cc: "dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Kent Overstreet <kent.overstreet@gmail.com>
      Cc: "luto@kernel.org" <luto@kernel.org>
      Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: "mingo@redhat.com" <mingo@redhat.com>
      Cc: "peterz@infradead.org" <peterz@infradead.org>
      Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: x86-ml <x86@kernel.org>
      Link: https://lkml.kernel.org/r/155657657552.7116.18363762932464011367.stgit@sosrh3.amd.com
      b51ce374
  23. 09 4月, 2019 1 次提交
  24. 03 4月, 2019 1 次提交
    • P
      x86/uaccess, ubsan: Fix UBSAN vs. SMAP · d08965a2
      Peter Zijlstra 提交于
      UBSAN can insert extra code in random locations; including AC=1
      sections. Typically this code is not safe and needs wrapping.
      
      So far, only __ubsan_handle_type_mismatch* have been observed in AC=1
      sections and therefore only those are annotated.
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      d08965a2
  25. 14 3月, 2019 1 次提交
  26. 13 3月, 2019 2 次提交
  27. 06 3月, 2019 1 次提交
    • U
      vmalloc: add test driver to analyse vmalloc allocator · 3f21a6b7
      Uladzislau Rezki (Sony) 提交于
      This adds a new kernel module for analysis of vmalloc allocator.  It is
      only enabled as a module.  There are two main reasons this module should
      be used for: performance evaluation and stressing of vmalloc subsystem.
      
      It consists of several test cases.  As of now there are 8.  The module
      has five parameters we can specify to change its the behaviour.
      
      1) run_test_mask - set of tests to be run
      
      id: 1,   name: fix_size_alloc_test
      id: 2,   name: full_fit_alloc_test
      id: 4,   name: long_busy_list_alloc_test
      id: 8,   name: random_size_alloc_test
      id: 16,  name: fix_align_alloc_test
      id: 32,  name: random_size_align_alloc_test
      id: 64,  name: align_shift_alloc_test
      id: 128, name: pcpu_alloc_test
      
      By default all tests are in run test mask.  If you want to select some
      specific tests it is possible to pass the mask.  For example for first,
      second and fourth tests we go 11 value.
      
      2) test_repeat_count - how many times each test should be repeated
      By default it is one time per test. It is possible to pass any number.
      As high the value is the test duration gets increased.
      
      3) test_loop_count - internal test loop counter. By default it is set
      to 1000000.
      
      4) single_cpu_test - use one CPU to run the tests
      By default this parameter is set to false. It means that all online
      CPUs execute tests. By setting it to 1, the tests are executed by
      first online CPU only.
      
      5) sequential_test_order - run tests in sequential order
      By default this parameter is set to false. It means that before running
      tests the order is shuffled. It is possible to make it sequential, just
      set it to 1.
      
      Performance analysis:
      In order to evaluate performance of vmalloc allocations, usually it
      makes sense to use only one CPU that runs tests, use sequential order,
      number of repeat tests can be different as well as set of test mask.
      
      For example if we want to run all tests, to use one CPU and repeat each
      test 3 times. Insert the module passing following parameters:
      
      single_cpu_test=1 sequential_test_order=1 test_repeat_count=3
      
      with following output:
      
      <snip>
      Summary: fix_size_alloc_test passed: 3 failed: 0 repeat: 3 loops: 1000000 avg: 901177 usec
      Summary: full_fit_alloc_test passed: 3 failed: 0 repeat: 3 loops: 1000000 avg: 1039341 usec
      Summary: long_busy_list_alloc_test passed: 3 failed: 0 repeat: 3 loops: 1000000 avg: 11775763 usec
      Summary: random_size_alloc_test passed 3: failed: 0 repeat: 3 loops: 1000000 avg: 6081992 usec
      Summary: fix_align_alloc_test passed: 3 failed: 0 repeat: 3, loops: 1000000 avg: 2003712 usec
      Summary: random_size_align_alloc_test passed: 3 failed: 0 repeat: 3 loops: 1000000 avg: 2895689 usec
      Summary: align_shift_alloc_test passed: 0 failed: 3 repeat: 3 loops: 1000000 avg: 573 usec
      Summary: pcpu_alloc_test passed: 3 failed: 0 repeat: 3 loops: 1000000 avg: 95802 usec
      All test took CPU0=192945605995 cycles
      <snip>
      
      The align_shift_alloc_test is expected to be failed.
      
      Stressing:
      In order to stress the vmalloc subsystem we run all available test cases
      on all available CPUs simultaneously. In order to prevent constant behaviour
      pattern, the test cases array is shuffled by default to randomize the order
      of test execution.
      
      For example if we want to run all tests(default), use all online CPUs(default)
      with shuffled order(default) and to repeat each test 30 times. The command
      would be like:
      
      modprobe vmalloc_test test_repeat_count=30
      
      Expected results are the system is alive, there are no any BUG_ONs or Kernel
      Panics the tests are completed, no memory leaks.
      
      [urezki@gmail.com: fix 32-bit builds]
        Link: http://lkml.kernel.org/r/20190106214839.ffvjvmrn52uqog7k@pc636
      [urezki@gmail.com: make CONFIG_TEST_VMALLOC depend on CONFIG_MMU]
        Link: http://lkml.kernel.org/r/20190219085441.s6bg2gpy4esny5vw@pc636
      Link: http://lkml.kernel.org/r/20190103142108.20744-3-urezki@gmail.comSigned-off-by: NUladzislau Rezki (Sony) <urezki@gmail.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Michal Hocko <mhocko@suse.com>
      Cc: Oleksiy Avramchenko <oleksiy.avramchenko@sonymobile.com>
      Cc: Shuah Khan <shuah@kernel.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      3f21a6b7
  28. 05 3月, 2019 1 次提交
    • K
      lib: Introduce test_stackinit module · 50ceaa95
      Kees Cook 提交于
      Adds test for stack initialization coverage. We have several build options
      that control the level of stack variable initialization. This test lets us
      visualize which options cover which cases, and provide tests for some of
      the pathological padding conditions the compiler will sometimes fail to
      initialize.
      
      All options pass the explicit initialization cases and the partial
      initializers (even with padding):
      
      test_stackinit: u8_zero ok
      test_stackinit: u16_zero ok
      test_stackinit: u32_zero ok
      test_stackinit: u64_zero ok
      test_stackinit: char_array_zero ok
      test_stackinit: small_hole_zero ok
      test_stackinit: big_hole_zero ok
      test_stackinit: trailing_hole_zero ok
      test_stackinit: packed_zero ok
      test_stackinit: small_hole_dynamic_partial ok
      test_stackinit: big_hole_dynamic_partial ok
      test_stackinit: trailing_hole_dynamic_partial ok
      test_stackinit: packed_dynamic_partial ok
      test_stackinit: small_hole_static_partial ok
      test_stackinit: big_hole_static_partial ok
      test_stackinit: trailing_hole_static_partial ok
      test_stackinit: packed_static_partial ok
      test_stackinit: packed_static_all ok
      test_stackinit: packed_dynamic_all ok
      test_stackinit: packed_runtime_all ok
      
      The results of the other tests (which contain no explicit initialization),
      change based on the build's configured compiler instrumentation.
      
      No options:
      
      test_stackinit: small_hole_static_all FAIL (uninit bytes: 3)
      test_stackinit: big_hole_static_all FAIL (uninit bytes: 61)
      test_stackinit: trailing_hole_static_all FAIL (uninit bytes: 7)
      test_stackinit: small_hole_dynamic_all FAIL (uninit bytes: 3)
      test_stackinit: big_hole_dynamic_all FAIL (uninit bytes: 61)
      test_stackinit: trailing_hole_dynamic_all FAIL (uninit bytes: 7)
      test_stackinit: small_hole_runtime_partial FAIL (uninit bytes: 23)
      test_stackinit: big_hole_runtime_partial FAIL (uninit bytes: 127)
      test_stackinit: trailing_hole_runtime_partial FAIL (uninit bytes: 24)
      test_stackinit: packed_runtime_partial FAIL (uninit bytes: 24)
      test_stackinit: small_hole_runtime_all FAIL (uninit bytes: 3)
      test_stackinit: big_hole_runtime_all FAIL (uninit bytes: 61)
      test_stackinit: trailing_hole_runtime_all FAIL (uninit bytes: 7)
      test_stackinit: u8_none FAIL (uninit bytes: 1)
      test_stackinit: u16_none FAIL (uninit bytes: 2)
      test_stackinit: u32_none FAIL (uninit bytes: 4)
      test_stackinit: u64_none FAIL (uninit bytes: 8)
      test_stackinit: char_array_none FAIL (uninit bytes: 16)
      test_stackinit: switch_1_none FAIL (uninit bytes: 8)
      test_stackinit: switch_2_none FAIL (uninit bytes: 8)
      test_stackinit: small_hole_none FAIL (uninit bytes: 24)
      test_stackinit: big_hole_none FAIL (uninit bytes: 128)
      test_stackinit: trailing_hole_none FAIL (uninit bytes: 32)
      test_stackinit: packed_none FAIL (uninit bytes: 32)
      test_stackinit: user FAIL (uninit bytes: 32)
      test_stackinit: failures: 25
      
      CONFIG_GCC_PLUGIN_STRUCTLEAK_USER=y
      This only tries to initialize structs with __user markings, so
      only the difference from above is now the "user" test passes:
      
      test_stackinit: small_hole_static_all FAIL (uninit bytes: 3)
      test_stackinit: big_hole_static_all FAIL (uninit bytes: 61)
      test_stackinit: trailing_hole_static_all FAIL (uninit bytes: 7)
      test_stackinit: small_hole_dynamic_all FAIL (uninit bytes: 3)
      test_stackinit: big_hole_dynamic_all FAIL (uninit bytes: 61)
      test_stackinit: trailing_hole_dynamic_all FAIL (uninit bytes: 7)
      test_stackinit: small_hole_runtime_partial FAIL (uninit bytes: 23)
      test_stackinit: big_hole_runtime_partial FAIL (uninit bytes: 127)
      test_stackinit: trailing_hole_runtime_partial FAIL (uninit bytes: 24)
      test_stackinit: packed_runtime_partial FAIL (uninit bytes: 24)
      test_stackinit: small_hole_runtime_all FAIL (uninit bytes: 3)
      test_stackinit: big_hole_runtime_all FAIL (uninit bytes: 61)
      test_stackinit: trailing_hole_runtime_all FAIL (uninit bytes: 7)
      test_stackinit: u8_none FAIL (uninit bytes: 1)
      test_stackinit: u16_none FAIL (uninit bytes: 2)
      test_stackinit: u32_none FAIL (uninit bytes: 4)
      test_stackinit: u64_none FAIL (uninit bytes: 8)
      test_stackinit: char_array_none FAIL (uninit bytes: 16)
      test_stackinit: switch_1_none FAIL (uninit bytes: 8)
      test_stackinit: switch_2_none FAIL (uninit bytes: 8)
      test_stackinit: small_hole_none FAIL (uninit bytes: 24)
      test_stackinit: big_hole_none FAIL (uninit bytes: 128)
      test_stackinit: trailing_hole_none FAIL (uninit bytes: 32)
      test_stackinit: packed_none FAIL (uninit bytes: 32)
      test_stackinit: user ok
      test_stackinit: failures: 24
      
      CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF=y
      This initializes all structures passed by reference (scalars and strings
      remain uninitialized):
      
      test_stackinit: small_hole_static_all ok
      test_stackinit: big_hole_static_all ok
      test_stackinit: trailing_hole_static_all ok
      test_stackinit: small_hole_dynamic_all ok
      test_stackinit: big_hole_dynamic_all ok
      test_stackinit: trailing_hole_dynamic_all ok
      test_stackinit: small_hole_runtime_partial ok
      test_stackinit: big_hole_runtime_partial ok
      test_stackinit: trailing_hole_runtime_partial ok
      test_stackinit: packed_runtime_partial ok
      test_stackinit: small_hole_runtime_all ok
      test_stackinit: big_hole_runtime_all ok
      test_stackinit: trailing_hole_runtime_all ok
      test_stackinit: u8_none FAIL (uninit bytes: 1)
      test_stackinit: u16_none FAIL (uninit bytes: 2)
      test_stackinit: u32_none FAIL (uninit bytes: 4)
      test_stackinit: u64_none FAIL (uninit bytes: 8)
      test_stackinit: char_array_none FAIL (uninit bytes: 16)
      test_stackinit: switch_1_none FAIL (uninit bytes: 8)
      test_stackinit: switch_2_none FAIL (uninit bytes: 8)
      test_stackinit: small_hole_none ok
      test_stackinit: big_hole_none ok
      test_stackinit: trailing_hole_none ok
      test_stackinit: packed_none ok
      test_stackinit: user ok
      test_stackinit: failures: 7
      
      CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL=y
      This initializes all variables, so it matches above with the scalars
      and arrays included:
      
      test_stackinit: small_hole_static_all ok
      test_stackinit: big_hole_static_all ok
      test_stackinit: trailing_hole_static_all ok
      test_stackinit: small_hole_dynamic_all ok
      test_stackinit: big_hole_dynamic_all ok
      test_stackinit: trailing_hole_dynamic_all ok
      test_stackinit: small_hole_runtime_partial ok
      test_stackinit: big_hole_runtime_partial ok
      test_stackinit: trailing_hole_runtime_partial ok
      test_stackinit: packed_runtime_partial ok
      test_stackinit: small_hole_runtime_all ok
      test_stackinit: big_hole_runtime_all ok
      test_stackinit: trailing_hole_runtime_all ok
      test_stackinit: u8_none ok
      test_stackinit: u16_none ok
      test_stackinit: u32_none ok
      test_stackinit: u64_none ok
      test_stackinit: char_array_none ok
      test_stackinit: switch_1_none ok
      test_stackinit: switch_2_none ok
      test_stackinit: small_hole_none ok
      test_stackinit: big_hole_none ok
      test_stackinit: trailing_hole_none ok
      test_stackinit: packed_none ok
      test_stackinit: user ok
      test_stackinit: all tests passed!
      Signed-off-by: NKees Cook <keescook@chromium.org>
      Reviewed-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      50ceaa95
  29. 12 1月, 2019 1 次提交
  30. 20 11月, 2018 1 次提交
    • E
      crypto: chacha20-generic - refactor to allow varying number of rounds · 1ca1b917
      Eric Biggers 提交于
      In preparation for adding XChaCha12 support, rename/refactor
      chacha20-generic to support different numbers of rounds.  The
      justification for needing XChaCha12 support is explained in more detail
      in the patch "crypto: chacha - add XChaCha12 support".
      
      The only difference between ChaCha{8,12,20} are the number of rounds
      itself; all other parts of the algorithm are the same.  Therefore,
      remove the "20" from all definitions, structures, functions, files, etc.
      that will be shared by all ChaCha versions.
      
      Also make ->setkey() store the round count in the chacha_ctx (previously
      chacha20_ctx).  The generic code then passes the round count through to
      chacha_block().  There will be a ->setkey() function for each explicitly
      allowed round count; the encrypt/decrypt functions will be the same.  I
      decided not to do it the opposite way (same ->setkey() function for all
      round counts, with different encrypt/decrypt functions) because that
      would have required more boilerplate code in architecture-specific
      implementations of ChaCha and XChaCha.
      Reviewed-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      Acked-by: NMartin Willi <martin@strongswan.org>
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      1ca1b917
  31. 16 11月, 2018 1 次提交
  32. 01 11月, 2018 1 次提交
  33. 23 10月, 2018 1 次提交
    • Z
      lib: Add umoddi3 and udivmoddi4 of GCC library routines · 6315730e
      Zong Li 提交于
      Add umoddi3 and udivmoddi4 support for 32-bit.
      
      The RV32 need the umoddi3 to do modulo when the operands are long long
      type, like other libraries implementation such as ucmpdi2, lshrdi3 and
      so on.
      
      I encounter the undefined reference 'umoddi3' when I use the in
      house dma driver, although it is in house driver, but I think that
      umoddi3 is a common function for RV32.
      
      The udivmoddi4 and umoddi3 are copies from libgcc in gcc. There are other
      functions use the udivmoddi4 in libgcc, so I separate the umoddi3 and
      udivmoddi4 for flexible extension in the future.
      Signed-off-by: NZong Li <zong@andestech.com>
      Signed-off-by: NPalmer Dabbelt <palmer@sifive.com>
      6315730e
  34. 21 10月, 2018 2 次提交
  35. 16 10月, 2018 1 次提交
    • A
      lib: Fix ia64 bootloader linkage · 93048c09
      Alexander Shishkin 提交于
      kbuild robot reports that since commit ce76d938 ("lib: Add memcat_p():
      paste 2 pointer arrays together") the ia64/hp/sim/boot fails to link:
      
      > LD      arch/ia64/hp/sim/boot/bootloader
      > lib/string.o: In function `__memcat_p':
      > string.c:(.text+0x1f22): undefined reference to `__kmalloc'
      > string.c:(.text+0x1ff2): undefined reference to `__kmalloc'
      > make[1]: *** [arch/ia64/hp/sim/boot/Makefile:37: arch/ia64/hp/sim/boot/bootloader] Error 1
      
      The reason is, the above commit, via __memcat_p(), adds a call to
      __kmalloc to string.o, which happens to be used in the bootloader, but
      there's no kmalloc or slab or anything.
      
      Since the linker would only pull in objects that contain referenced
      symbols, moving __memcat_p() to a different compilation unit solves the
      problem.
      
      Fixes: ce76d938 ("lib: Add memcat_p(): paste 2 pointer arrays together")
      Signed-off-by: NAlexander Shishkin <alexander.shishkin@linux.intel.com>
      Reported-by: Nkbuild test robot <lkp@intel.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: Tony Luck <tony.luck@intel.com>
      Cc: Joe Perches <joe@perches.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      93048c09
  36. 12 10月, 2018 1 次提交
    • A
      lib/bch: fix possible stack overrun · f0fe77f6
      Arnd Bergmann 提交于
      The previous patch introduced very large kernel stack usage and a Makefile
      change to hide the warning about it.
      
      From what I can tell, a number of things went wrong here:
      
      - The BCH_MAX_T constant was set to the maximum value for 'n',
        not the maximum for 't', which is much smaller.
      
      - The stack usage is actually larger than the entire kernel stack
        on some architectures that can use 4KB stacks (m68k, sh, c6x), which
        leads to an immediate overrun.
      
      - The justification in the patch description claimed that nothing
        changed, however that is not the case even without the two points above:
        the configuration is machine specific, and most boards  never use the
        maximum BCH_ECC_WORDS() length but instead have something much smaller.
        That maximum would only apply to machines that use both the maximum
        block size and the maximum ECC strength.
      
      The largest value for 't' that I could find is '32', which in turn leads
      to a 60 byte array instead of 2048 bytes. Making it '64' for future
      extension seems also worthwhile, with 120 bytes for the array. Anything
      larger won't fit into the OOB area on NAND flash.
      
      With that changed, the warning can be enabled again.
      
      Only linux-4.19+ contains the breakage, so this is only needed
      as a stable backport if it does not make it into the release.
      
      Fixes: 02361bc7 ("lib/bch: Remove VLA usage")
      Reported-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: stable@vger.kernel.org
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NBoris Brezillon <boris.brezillon@bootlin.com>
      f0fe77f6
  37. 11 10月, 2018 1 次提交