Forum | Documentation | Website | Blog

Skip to content
Snippets Groups Projects
  1. Jan 20, 2022
  2. Jan 18, 2022
  3. Jan 15, 2022
  4. Jan 13, 2022
  5. Jan 12, 2022
    • Eric Dumazet's avatar
      ref_tracker: use __GFP_NOFAIL more carefully · c12837d1
      Eric Dumazet authored
      syzbot was able to trigger this warning from new_slab()
      		/*
      		 * All existing users of the __GFP_NOFAIL are blockable, so warn
      		 * of any new users that actually require GFP_NOWAIT
      		 */
      		if (WARN_ON_ONCE(!can_direct_reclaim))
      			goto fail;
      
      Indeed, we should use __GFP_NOFAIL if direct reclaim is possible.
      
      Hopefully in the future we will be able to use SLAB_NOFAILSLAB
      option so that syzbot can benefit from full ref_tracker
      even in the presence of memory fault injections.
      
      WARNING: CPU: 0 PID: 13 at mm/page_alloc.c:5081 __alloc_pages_slowpath.constprop.0+0x1b7b/0x20d0 mm/page_alloc.c:5081 mm/page_alloc.c:5081
      Modules linked in:
      CPU: 0 PID: 13 Comm: ksoftirqd/0 Not tainted 5.16.0-rc5-syzkaller #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      RIP: 0010:__alloc_pages_slowpath.constprop.0+0x1b7b/0x20d0 mm/page_alloc.c:5081 mm/page_alloc.c:5081
      Code: 90 08 00 00 48 81 c7 d8 04 00 00 48 89 f8 48 c1 e8 03 42 80 3c 30 00 0f 84 f0 ea ff ff e8 3d 82 09 00 e9 e6 ea ff ff 4d 89 fd <0f> 0b 48 b8 00 00 00 00 00 fc ff df 48 8b 54 24 30 48 c1 ea 03 80
      RSP: 0018:ffffc90000d272b8 EFLAGS: 00010246
      
      RAX: 0000000000000000 RBX: ffff88813fffc300 RCX: 0000000000000000
      RDX: 0000000000000000 RSI: 0000000000000002 RDI: ffff88813fffc348
      RBP: ffff88813fffc300 R08: 00000000000013dc R09: 00000000000013c8
      R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000
      R13: ffffc90000d274e8 R14: dffffc0000000000 R15: ffffc90000d274e8
      FS:  0000000000000000(0000) GS:ffff8880b9c00000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 00007ffefe6000f8 CR3: 000000001d21e000 CR4: 00000000003506f0
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      Call Trace:
       <TASK>
       __alloc_pages+0x412/0x500 mm/page_alloc.c:5382 mm/page_alloc.c:5382
       alloc_pages+0x1a7/0x300 mm/mempolicy.c:2191 mm/mempolicy.c:2191
       alloc_slab_page mm/slub.c:1793 [inline]
       allocate_slab mm/slub.c:1938 [inline]
       alloc_slab_page mm/slub.c:1793 [inline] mm/slub.c:1993
       allocate_slab mm/slub.c:1938 [inline] mm/slub.c:1993
       new_slab+0x349/0x4a0 mm/slub.c:1993 mm/slub.c:1993
       ___slab_alloc+0x918/0xfe0 mm/slub.c:3022 mm/slub.c:3022
       __slab_alloc.constprop.0+0x4d/0xa0 mm/slub.c:3109 mm/slub.c:3109
       slab_alloc_node mm/slub.c:3200 [inline]
       slab_alloc mm/slub.c:3242 [inline]
       slab_alloc_node mm/slub.c:3200 [inline] mm/slub.c:3259
       slab_alloc mm/slub.c:3242 [inline] mm/slub.c:3259
       kmem_cache_alloc_trace+0x289/0x2c0 mm/slub.c:3259 mm/slub.c:3259
       kmalloc include/linux/slab.h:590 [inline]
       kzalloc include/linux/slab.h:724 [inline]
       kmalloc include/linux/slab.h:590 [inline] lib/ref_tracker.c:74
       kzalloc include/linux/slab.h:724 [inline] lib/ref_tracker.c:74
       ref_tracker_alloc+0xe1/0x430 lib/ref_tracker.c:74 lib/ref_tracker.c:74
       netdev_tracker_alloc include/linux/netdevice.h:3855 [inline]
       dev_hold_track include/linux/netdevice.h:3872 [inline]
       netdev_tracker_alloc include/linux/netdevice.h:3855 [inline] net/core/dst.c:52
       dev_hold_track include/linux/netdevice.h:3872 [inline] net/core/dst.c:52
       dst_init+0xe0/0x520 net/core/dst.c:52 net/core/dst.c:52
       dst_alloc+0x16b/0x1f0 net/core/dst.c:96 net/core/dst.c:96
       rt_dst_alloc+0x73/0x450 net/ipv4/route.c:1614 net/ipv4/route.c:1614
       ip_route_input_mc net/ipv4/route.c:1720 [inline]
       ip_route_input_mc net/ipv4/route.c:1720 [inline] net/ipv4/route.c:2465
       ip_route_input_rcu.part.0+0x4fe/0xcc0 net/ipv4/route.c:2465 net/ipv4/route.c:2465
       ip_route_input_rcu net/ipv4/route.c:2420 [inline]
       ip_route_input_rcu net/ipv4/route.c:2420 [inline] net/ipv4/route.c:2416
       ip_route_input_noref+0x1b8/0x2a0 net/ipv4/route.c:2416 net/ipv4/route.c:2416
       ip_rcv_finish_core.constprop.0+0x288/0x1e90 net/ipv4/ip_input.c:354 net/ipv4/ip_input.c:354
       ip_rcv_finish+0x135/0x2f0 net/ipv4/ip_input.c:427 net/ipv4/ip_input.c:427
       NF_HOOK include/linux/netfilter.h:307 [inline]
       NF_HOOK include/linux/netfilter.h:301 [inline]
       NF_HOOK include/linux/netfilter.h:307 [inline] net/ipv4/ip_input.c:540
       NF_HOOK include/linux/netfilter.h:301 [inline] net/ipv4/ip_input.c:540
       ip_rcv+0xaa/0xd0 net/ipv4/ip_input.c:540 net/ipv4/ip_input.c:540
       __netif_receive_skb_one_core+0x114/0x180 net/core/dev.c:5350 net/core/dev.c:5350
       __netif_receive_skb+0x24/0x1b0 net/core/dev.c:5464 net/core/dev.c:5464
       process_backlog+0x2a5/0x6c0 net/core/dev.c:5796 net/core/dev.c:5796
       __napi_poll+0xaf/0x440 net/core/dev.c:6364 net/core/dev.c:6364
       napi_poll net/core/dev.c:6431 [inline]
       napi_poll net/core/dev.c:6431 [inline] net/core/dev.c:6518
       net_rx_action+0x801/0xb40 net/core/dev.c:6518 net/core/dev.c:6518
       __do_softirq+0x29b/0x9c2 kernel/softirq.c:558 kernel/softirq.c:558
       run_ksoftirqd kernel/softirq.c:921 [inline]
       run_ksoftirqd kernel/softirq.c:921 [inline] kernel/softirq.c:913
       run_ksoftirqd+0x2d/0x60 kernel/softirq.c:913 kernel/softirq.c:913
       smpboot_thread_fn+0x645/0x9c0 kernel/smpboot.c:164 kernel/smpboot.c:164
       kthread+0x405/0x4f0 kernel/kthread.c:327 kernel/kthread.c:327
       ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295 arch/x86/entry/entry_64.S:295
      
      Fixes: 4e66934e
      
       ("lib: add reference counting tracking infrastructure")
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      c12837d1
  6. Jan 08, 2022
  7. Jan 06, 2022
  8. Jan 04, 2022
  9. Dec 28, 2021
  10. Dec 27, 2021
  11. Dec 24, 2021
  12. Dec 21, 2021
  13. Dec 13, 2021
    • David Gow's avatar
      kunit: Report test parameter results as (K)TAP subtests · 44b7da5f
      David Gow authored
      
      Currently, the results for individial parameters in a parameterised test
      are simply output as (K)TAP diagnostic lines.
      
      As kunit_tool now supports nested subtests, report each parameter as its
      own subtest.
      
      For example, here's what the output now looks like:
      	# Subtest: inode_test_xtimestamp_decoding
      	ok 1 - 1901-12-13 Lower bound of 32bit < 0 timestamp, no extra bits
      	ok 2 - 1969-12-31 Upper bound of 32bit < 0 timestamp, no extra bits
      	ok 3 - 1970-01-01 Lower bound of 32bit >=0 timestamp, no extra bits
      	ok 4 - 2038-01-19 Upper bound of 32bit >=0 timestamp, no extra bits
      	ok 5 - 2038-01-19 Lower bound of 32bit <0 timestamp, lo extra sec bit on
      	ok 6 - 2106-02-07 Upper bound of 32bit <0 timestamp, lo extra sec bit on
      	ok 7 - 2106-02-07 Lower bound of 32bit >=0 timestamp, lo extra sec bit on
      	ok 8 - 2174-02-25 Upper bound of 32bit >=0 timestamp, lo extra sec bit on
      	ok 9 - 2174-02-25 Lower bound of 32bit <0 timestamp, hi extra sec bit on
      	ok 10 - 2242-03-16 Upper bound of 32bit <0 timestamp, hi extra sec bit on
      	ok 11 - 2242-03-16 Lower bound of 32bit >=0 timestamp, hi extra sec bit on
      	ok 12 - 2310-04-04 Upper bound of 32bit >=0 timestamp, hi extra sec bit on
      	ok 13 - 2310-04-04 Upper bound of 32bit>=0 timestamp, hi extra sec bit 1. 1 ns
      	ok 14 - 2378-04-22 Lower bound of 32bit>= timestamp. Extra sec bits 1. Max ns
      	ok 15 - 2378-04-22 Lower bound of 32bit >=0 timestamp. All extra sec bits on
      	ok 16 - 2446-05-10 Upper bound of 32bit >=0 timestamp. All extra sec bits on
      	# inode_test_xtimestamp_decoding: pass:16 fail:0 skip:0 total:16
      	ok 1 - inode_test_xtimestamp_decoding
      
      Signed-off-by: default avatarDavid Gow <davidgow@google.com>
      Reviewed-by: default avatarDaniel Latypov <dlatypov@google.com>
      Reviewed-by: default avatarBrendan Higgins <brendanhiggins@google.com>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      44b7da5f
    • David Gow's avatar
      kunit: Don't crash if no parameters are generated · 37dbb4c7
      David Gow authored
      
      It's possible that a parameterised test could end up with zero
      parameters. At the moment, the test function will nevertheless be called
      with NULL as the parameter. Instead, don't try to run the test code, and
      just mark the test as SKIPped.
      
      Reported-by: default avatarDaniel Latypov <dlatypov@google.com>
      Signed-off-by: default avatarDavid Gow <davidgow@google.com>
      Reviewed-by: default avatarDaniel Latypov <dlatypov@google.com>
      Reviewed-by: default avatarBrendan Higgins <brendanhiggins@google.com>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      37dbb4c7
    • Eric W. Biederman's avatar
      exit: Rename complete_and_exit to kthread_complete_and_exit · cead1855
      Eric W. Biederman authored
      
      Update complete_and_exit to call kthread_exit instead of do_exit.
      
      Change the name to reflect this change in functionality.  All of the
      users of complete_and_exit are causing the current kthread to exit so
      this change makes it clear what is happening.
      
      Move the implementation of kthread_complete_and_exit from
      kernel/exit.c to to kernel/kthread.c.  As this function is kthread
      specific it makes most sense to live with the kthread functions.
      
      There are no functional change.
      
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      cead1855
    • Mark Rutland's avatar
      locking/atomic: atomic64: Remove unusable atomic ops · 5fb6e8cf
      Mark Rutland authored
      The generic atomic64 implementation provides:
      
      * atomic64_and_return()
      * atomic64_or_return()
      * atomic64_xor_return()
      
      ... but none of these exist in the standard atomic64 API as described by
      scripts/atomic/atomics.tbl, and none of these have prototypes exposed by
      <asm-generic/atomic64.h>.
      
      The lkp kernel test robot noted this results in warnings when building with
      W=1:
      
        lib/atomic64.c:82:5: warning: no previous prototype for 'generic_atomic64_and_return' [-Wmissing-prototypes]
      
        lib/atomic64.c:82:5: warning: no previous prototype for 'generic_atomic64_or_return' [-Wmissing-prototypes]
      
        lib/atomic64.c:82:5: warning: no previous prototype for 'generic_atomic64_xor_return' [-Wmissing-prototypes]
      
      This appears to have been a thinko in commit:
      
        28aa2bda
      
       ("locking/atomic: Implement atomic{,64,_long}_fetch_{add,sub,and,andnot,or,xor}{,_relaxed,_acquire,_release}()")
      
      ... where we grouped add/sub separately from and/ox/xor, so that we could avoid
      implementing _return forms for the latter group, but forgot to remove
      ATOMIC64_OP_RETURN() for that group.
      
      This doesn't cause any functional problem, but it's pointless to build code
      which cannot be used. Remove the unusable code. This does not affect add/sub,
      for which _return forms will still be built.
      
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Acked-by: default avatarBoqun Feng <boqun.feng@gmail.com>
      Link: https://lore.kernel.org/r/20211126115923.41489-1-mark.rutland@arm.com
      5fb6e8cf
  14. Dec 09, 2021
    • Marco Elver's avatar
      kcsan: Support WEAK_MEMORY with Clang where no objtool support exists · bd3d5bd1
      Marco Elver authored
      Clang and GCC behave a little differently when it comes to the
      __no_sanitize_thread attribute, which has valid reasons, and depending
      on context either one could be right.
      
      Traditionally, user space ThreadSanitizer [1] still expects instrumented
      builtin atomics (to avoid false positives) and __tsan_func_{entry,exit}
      (to generate meaningful stack traces), even if the function has the
      attribute no_sanitize("thread").
      
      [1] https://clang.llvm.org/docs/ThreadSanitizer.html#attribute-no-sanitize-thread
      
      
      
      GCC doesn't follow the same policy (for better or worse), and removes
      all kinds of instrumentation if no_sanitize is added. Arguably, since
      this may be a problem for user space ThreadSanitizer, we expect this may
      change in future.
      
      Since KCSAN != ThreadSanitizer, the likelihood of false positives even
      without barrier instrumentation everywhere, is much lower by design.
      
      At least for Clang, however, to fully remove all sanitizer
      instrumentation, we must add the disable_sanitizer_instrumentation
      attribute, which is available since Clang 14.0.
      
      Signed-off-by: default avatarMarco Elver <elver@google.com>
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      bd3d5bd1
    • Marco Elver's avatar
      kcsan: Add core support for a subset of weak memory modeling · 69562e49
      Marco Elver authored
      
      Add support for modeling a subset of weak memory, which will enable
      detection of a subset of data races due to missing memory barriers.
      
      KCSAN's approach to detecting missing memory barriers is based on
      modeling access reordering, and enabled if `CONFIG_KCSAN_WEAK_MEMORY=y`,
      which depends on `CONFIG_KCSAN_STRICT=y`. The feature can be enabled or
      disabled at boot and runtime via the `kcsan.weak_memory` boot parameter.
      
      Each memory access for which a watchpoint is set up, is also selected
      for simulated reordering within the scope of its function (at most 1
      in-flight access).
      
      We are limited to modeling the effects of "buffering" (delaying the
      access), since the runtime cannot "prefetch" accesses (therefore no
      acquire modeling). Once an access has been selected for reordering, it
      is checked along every other access until the end of the function scope.
      If an appropriate memory barrier is encountered, the access will no
      longer be considered for reordering.
      
      When the result of a memory operation should be ordered by a barrier,
      KCSAN can then detect data races where the conflict only occurs as a
      result of a missing barrier due to reordering accesses.
      
      Suggested-by: default avatarDmitry Vyukov <dvyukov@google.com>
      Signed-off-by: default avatarMarco Elver <elver@google.com>
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      69562e49