Forum | Documentation | Website | Blog

Skip to content
Snippets Groups Projects
  1. Apr 22, 2022
    • Matthew Wilcox (Oracle)'s avatar
      XArray: Disallow sibling entries of nodes · 63b1898f
      Matthew Wilcox (Oracle) authored
      
      There is a race between xas_split() and xas_load() which can result in
      the wrong page being returned, and thus data corruption.  Fortunately,
      it's hard to hit (syzbot took three months to find it) and often guarded
      with VM_BUG_ON().
      
      The anatomy of this race is:
      
      thread A			thread B
      order-9 page is stored at index 0x200
      				lookup of page at index 0x274
      page split starts
      				load of sibling entry at offset 9
      stores nodes at offsets 8-15
      				load of entry at offset 8
      
      The entry at offset 8 turns out to be a node, and so we descend into it,
      and load the page at index 0x234 instead of 0x274.  This is hard to fix
      on the split side; we could replace the entire node that contains the
      order-9 page instead of replacing the eight entries.  Fixing it on
      the lookup side is easier; just disallow sibling entries that point
      to nodes.  This cannot ever be a useful thing as the descent would not
      know the correct offset to use within the new node.
      
      The test suite continues to pass, but I have not added a new test for
      this bug.
      
      Reported-by: default avatar <syzbot+cf4cf13056f85dec2c40@syzkaller.appspotmail.com>
      Tested-by: default avatar <syzbot+cf4cf13056f85dec2c40@syzkaller.appspotmail.com>
      Fixes: 6b24ca4a
      
       ("mm: Use multi-index entries in the page cache")
      Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
      63b1898f
  2. Apr 08, 2022
  3. Apr 05, 2022
  4. Mar 31, 2022
    • Matthew Wilcox (Oracle)'s avatar
      XArray: Update the LRU list in xas_split() · 3ed4bb77
      Matthew Wilcox (Oracle) authored
      When splitting a value entry, we may need to add the new nodes to the LRU
      list and remove the parent node from the LRU list.  The WARN_ON checks
      in shadow_lru_isolate() catch this oversight.  This bug was latent
      until we stopped splitting folios in shrink_page_list() with commit
      820c4e2e ("mm/vmscan: Free non-shmem folios without splitting them").
      That allows the creation of large shadow entries, and subsequently when
      trying to page in a small page, we will split the large shadow entry
      in __filemap_add_folio().
      
      Fixes: 8fc75643
      
       ("XArray: add xas_split")
      Reported-by: default avatarHugh Dickins <hughd@google.com>
      Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
      3ed4bb77
  5. Mar 29, 2022
  6. Mar 28, 2022
    • Matthew Wilcox (Oracle)'s avatar
      XArray: Fix xas_create_range() when multi-order entry present · 3e3c6580
      Matthew Wilcox (Oracle) authored
      If there is already an entry present that is of order >= XA_CHUNK_SHIFT
      when we call xas_create_range(), xas_create_range() will misinterpret
      that entry as a node and dereference xa_node->parent, generally leading
      to a crash that looks something like this:
      
      general protection fault, probably for non-canonical address 0xdffffc0000000001:
      0000 [#1] PREEMPT SMP KASAN
      KASAN: null-ptr-deref in range [0x0000000000000008-0x000000000000000f]
      CPU: 0 PID: 32 Comm: khugepaged Not tainted 5.17.0-rc8-syzkaller-00003-g56e337f2cf13 #0
      RIP: 0010:xa_parent_locked include/linux/xarray.h:1207 [inline]
      RIP: 0010:xas_create_range+0x2d9/0x6e0 lib/xarray.c:725
      
      It's deterministically reproducable once you know what the problem is,
      but producing it in a live kernel requires khugepaged to hit a race.
      While the problem has been present since xas_create_range() was
      introduced, I'm not aware of a way to hit it before the page cache was
      converted to use multi-index entries.
      
      Fixes: 6b24ca4a
      
       ("mm: Use multi-index entries in the page cache")
      Reported-by: default avatar <syzbot+0d2b0bf32ca5cfd09f2e@syzkaller.appspotmail.com>
      Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
      3e3c6580
  7. Mar 24, 2022
  8. Mar 23, 2022
  9. Mar 22, 2022
  10. Mar 21, 2022
    • Ming Lei's avatar
      lib/sbitmap: allocate sb->map via kvzalloc_node · 863a66cd
      Ming Lei authored
      
      sbitmap has been used in scsi for replacing atomic operations on
      sdev->device_busy, so IOPS on some fast scsi storage can be improved.
      
      However, sdev->device_busy can be changed in fast path, so we have to
      allocate the sb->map statically. sdev->device_busy has been capped to 1024,
      but some drivers may configure the default depth as < 8, then
      cause each sbitmap word to hold only one bit. Finally 1024 * 128(
      sizeof(sbitmap_word)) bytes is needed for sb->map, given it is order 5
      allocation, sometimes it may fail.
      
      Avoid the issue by using kvzalloc_node() for allocating sb->map.
      
      Cc: Ewan D. Milne <emilne@redhat.com>
      Signed-off-by: default avatarMing Lei <ming.lei@redhat.com>
      Reviewed-by: default avatarChaitanya Kulkarni <kch@nvidia.com>
      Link: https://lore.kernel.org/r/20220316012708.354668-1-ming.lei@redhat.com
      
      
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      863a66cd
    • Kees Cook's avatar
      lib: stackinit: Convert to KUnit · 02788ebc
      Kees Cook authored
      
      Convert stackinit unit tests to KUnit, for better integration
      into the kernel self test framework. Includes a rename of
      test_stackinit.c to stackinit_kunit.c, and CONFIG_TEST_STACKINIT to
      CONFIG_STACKINIT_KUNIT_TEST.
      
      Adjust expected test results based on which stack initialization method
      was chosen:
      
       $ CMD="./tools/testing/kunit/kunit.py run stackinit --raw_output \
              --arch=x86_64 --kconfig_add"
      
       $ $CMD | grep stackinit:
       # stackinit: pass:36 fail:0 skip:29 total:65
      
       $ $CMD CONFIG_GCC_PLUGIN_STRUCTLEAK_USER=y | grep stackinit:
       # stackinit: pass:37 fail:0 skip:28 total:65
      
       $ $CMD CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF=y | grep stackinit:
       # stackinit: pass:55 fail:0 skip:10 total:65
      
       $ $CMD CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL=y | grep stackinit:
       # stackinit: pass:62 fail:0 skip:3 total:65
      
       $ $CMD CONFIG_INIT_STACK_ALL_PATTERN=y --make_option LLVM=1 | grep stackinit:
       # stackinit: pass:60 fail:0 skip:5 total:65
      
       $ $CMD CONFIG_INIT_STACK_ALL_ZERO=y --make_option LLVM=1 | grep stackinit:
       # stackinit: pass:60 fail:0 skip:5 total:65
      
      Temporarily remove the userspace-build mode, which will be restored in a
      later patch.
      
      Expand the size of the pre-case switch variable so it doesn't get
      accidentally cleared.
      
      Cc: David Gow <davidgow@google.com>
      Cc: Daniel Latypov <dlatypov@google.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      ---
      v1: https://lore.kernel.org/lkml/20220224055145.1853657-1-keescook@chromium.org
      v2:
       - split "userspace KUnit stub" into separate header and patch (Daniel)
       - Improve commit log and comments (David)
       - Provide mapping of expected XFAIL tests to CONFIGs (David)
      02788ebc
  11. Mar 17, 2022
  12. Mar 12, 2022
    • Jason A. Donenfeld's avatar
      random: replace custom notifier chain with standard one · 5acd3548
      Jason A. Donenfeld authored
      
      We previously rolled our own randomness readiness notifier, which only
      has two users in the whole kernel. Replace this with a more standard
      atomic notifier block that serves the same purpose with less code. Also
      unexport the symbols, because no modules use it, only unconditional
      builtins. The only drawback is that it's possible for a notification
      handler returning the "stop" code to prevent further processing, but
      given that there are only two users, and that we're unexporting this
      anyway, that doesn't seem like a significant drawback for the
      simplification we receive here.
      
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Theodore Ts'o <tytso@mit.edu>
      Reviewed-by: default avatarDominik Brodowski <linux@dominikbrodowski.net>
      Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
      5acd3548
  13. Mar 11, 2022
  14. Mar 08, 2022
    • Paul Menzel's avatar
      lib/raid6: Include <asm/ppc-opcode.h> for VPERMXOR · 5b401e4e
      Paul Menzel authored
      
      On Ubuntu 21.10 (ppc64le) building raid6test with gcc (Ubuntu
      11.2.0-7ubuntu2) 11.2.0 fails with the error below.
      
          gcc -I.. -I ../../../include -g -O2                       \
                   -I../../../arch/powerpc/include -DCONFIG_ALTIVEC \
                   -c -o vpermxor1.o vpermxor1.c
          vpermxor1.c: In function ‘raid6_vpermxor1_gen_syndrome_real’:
          vpermxor1.c:64:29: error: expected string literal before ‘VPERMXOR’
             64 |   asm(VPERMXOR(%0,%1,%2,%3):"=v"(wq0):"v"(gf_high), "v"(gf_low), "v"(wq0));
                |       ^~~~~~~~
          make: *** [Makefile:58: vpermxor1.o] Error 1
      
      So, include the header asm/ppc-opcode.h defining this macro also when
      not building the Linux kernel but only this too.
      
      Cc: Matt Brown <matthew.brown.dev@gmail.com>
      Signed-off-by: default avatarPaul Menzel <pmenzel@molgen.mpg.de>
      Signed-off-by: default avatarSong Liu <song@kernel.org>
      5b401e4e
    • Paul Menzel's avatar
      lib/raid6/test/Makefile: Use $(pound) instead of \# for Make 4.3 · 633174a7
      Paul Menzel authored
      Buidling raid6test on Ubuntu 21.10 (ppc64le) with GNU Make 4.3 shows the
      errors below:
      
          $ cd lib/raid6/test/
          $ make
          <stdin>:1:1: error: stray ‘\’ in program
          <stdin>:1:2: error: stray ‘#’ in program
          <stdin>:1:11: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ \
              before ‘<’ token
      
          [...]
      
      The errors come from the HAS_ALTIVEC test, which fails, and the POWER
      optimized versions are not built. That’s also reason nobody noticed on the
      other architectures.
      
      GNU Make 4.3 does not remove the backslash anymore. From the 4.3 release
      announcment:
      
      > * WARNING: Backward-incompatibility!
      >   Number signs (#) appearing inside a macro reference or function invocation
      >   no longer introduce comments and should not be escaped with backslashes:
      >   thus a call such as:
      >     foo := $(shell echo '#')
      >   is legal.  Previously the number sign needed to be escaped, for example:
      >     foo := $(shell echo '\#')
      >   Now this latter will resolve to "\#".  If you want to write makefiles
      >   portable to both versions, assign the number sign to a variable:
      >     H := \#
      >     foo := $(shell echo '$H')
      >   This was claimed to be fixed in 3.81, but wasn't, for some reason.
      >   To detect this change search for 'nocomment' in the .FEATURES variable.
      
      So, do the same as commit 9564a8cf ("Kbuild: fix # escaping in .cmd
      files for future Make") and commit 929bef46 ("bpf: Use $(pound) instead
      of \# in Makefiles") and define and use a $(pound) variable.
      
      Reference for the change in make:
      https://git.savannah.gnu.org/cgit/make.git/commit/?id=c6966b323811c37acedff05b57
      
      
      
      Cc: Matt Brown <matthew.brown.dev@gmail.com>
      Signed-off-by: default avatarPaul Menzel <pmenzel@molgen.mpg.de>
      Signed-off-by: default avatarSong Liu <song@kernel.org>
      633174a7
    • Dirk Müller's avatar
      lib/raid6/test: fix multiple definition linking error · a5359ddd
      Dirk Müller authored
      
      GCC 10+ defaults to -fno-common, which enforces proper declaration of
      external references using "extern". without this change a link would
      fail with:
      
        lib/raid6/test/algos.c:28: multiple definition of `raid6_call';
        lib/raid6/test/test.c:22: first defined here
      
      the pq.h header that is included already includes an extern declaration
      so we can just remove the redundant one here.
      
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarDirk Müller <dmueller@suse.de>
      Reviewed-by: default avatarPaul Menzel <pmenzel@molgen.mpg.de>
      Signed-off-by: default avatarSong Liu <song@kernel.org>
      a5359ddd
  15. Mar 07, 2022
  16. Mar 03, 2022
  17. Mar 02, 2022
  18. Feb 28, 2022
  19. Feb 27, 2022
  20. Feb 26, 2022
  21. Feb 25, 2022