Skip to content

rcu: Record callback enqueue stacks and add torture tests

Kunwu Chan lkml rcu 2 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest7 patches 0 repliesNew
  2. v15 patches 4 repliesSuperseded

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/7rcu-tasks: Record callback enqueue stackkernel/rcu/tasks.h+4 -00 replies
2/7rcutorture: Require debug_objects flag for debug-objects testkernel/rcu/rcutorture.c+7 -20 replies
3/7rcutorture: Test duplicate call_rcu_tasks() callback enqueuekernel/rcu/rcutorture.c+1 -00 replies
4/7rcutorture: Test duplicate call_rcu_tasks_trace() callback enqueuekernel/rcu/rcutorture.c+1 -00 replies
5/7rcutorture: Add KASAN aux-stack self-testDocumentation/admin-guide/kernel-parameters.txt kernel/rcu/rcutorture.c+55 -00 replies
6/7rcutorture: Add kasan-aux.sh aux-stack checkerDocumentation/RCU/torture.rst tools/testing/selftests/rcutorture/bin/kasan-aux-check.sh tools/testing/selftests/rcutorture/bin/kasan-aux.sh+418 -00 replies
7/7rcutorture: Run KASAN aux-stack checks from torture.shDocumentation/RCU/torture.rst tools/testing/selftests/rcutorture/bin/torture.sh+23 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/7] rcu: Record callback enqueue stacks and add torture tests

This series records the enqueueing stack for RCU Tasks callbacks and adds rcutorture coverage for duplicate callbacks and KASAN auxiliary-stack recording.

Changes since v1, in response to feedback from Joel Fernandes, Paul E. McKenney, and Zqiang:
v1: https://lore.kernel.org/all/[email protected]/

- Dropped the RCU_KASAN_AUX_TEST module, its Kconfig flavor choice, and the five *KASAN01 scenarios. The verification is now an rcutorture self-test that uses the selected flavor's callback and barrier operations, enabled by the new rcutorture.kasan_debug boot parameter, so it can be run from kvm.sh --kasan with existing scenarios.

- rcu_test_debug_objects() now skips flavors that do not set ->debug_objects. The flag previously guarded only the ->call()/->cb_barrier() sanity check, so torture_type=trivial with CONFIG_DEBUG_OBJECTS_RCU_HEAD=y and rcutorture.object_debug=1 invoked a NULL function pointer. This panic was reproduced before the fix and verified fixed after it, with identical rcutorture arguments.

- New in v2: kasan-aux.sh automates the auxiliary-stack checks using kvm.sh --kasan, existing scenarios, and the existing checkers, ending with a single kvm-recheck.sh pass over the filtered logs. kasan-aux.sh can run and check the auxiliary-stack test on its own. The final patch also runs it from torture.sh when both RCU and KASAN testing are enabled.

Tested on x86_64 with kvm.sh --kasan, kasan_multi_shot, and rcutorture.kasan_debug=1 (30-second runs, built kernels reused via kvm-again.sh to select flavors):

  Scenario Flavor         "Last potentially related work creation"
  TASKS01  tasks          call_rcu_tasks_generic
  TASKS01  rcu            __call_rcu_common
  TASKS01  srcu           __call_srcu
  TASKS01  tasks-tracing  __call_srcu
  TINY01   rcu            call_rcu
  TINY01   srcu           call_srcu

kasan-aux.sh checks for rcu_test_kasan() in the auxiliary stack. All runs reached "End of test: SUCCESS" with one intentional report, which the torture summary flags (Bugs: 1) as it flags the intentional warnings from rcutorture.object_debug=1.

Also verified:
- tasks with object_debug=1 and kasan_debug=1, 3-minute run:
the four intentional debugobjects warnings, then the KASAN report, then SUCCESS with barrier: 633/633.
- Direct kvm.sh runs of trivial, tasks-rude, and busted with one or both self-tests enabled: clean skip messages, no splats, exit code 0. kasan-aux.sh expects these flavors to skip.
- TASKS01 without KASAN and kasan_debug=1: test skipped, exit code 0.
- tasks with both self-tests disabled: no splats, exit code 0.
- kasan-aux.sh --check negatives: a TINY01 build with kasan_record_aux_stack() compiled out of call_rcu() fails with a missing auxiliary stack, and a non-KASAN run is rejected at the configuration check.

Keep this test out of runs intended to find real KASAN bugs:
KASAN suppresses reports after the first unless kasan_multi_shot is also supplied, and the report taints the kernel.

The seventh patch runs kasan-aux.sh from torture.sh on the scenarios selected by --configs-rcutorture, so the added kernel builds scale with that selection; --no-kasan or dropping that patch avoids them entirely. Feedback on whether that default is worthwhile would be welcome.

For example:

  tools/testing/selftests/rcutorture/bin/kvm.sh --configs TASKS01 \
    --kasan --duration 30s \
    --bootargs "rcutorture.kasan_debug=1 kasan_multi_shot"

tools/testing/selftests/rcutorture/bin/kasan-aux.sh

This series was tested on top of [1] with Joel's RCU Tasks barrier debugobjects fix [2] applied.

[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/

Kunwu Chan (7):
rcu-tasks: Record callback enqueue stack
rcutorture: Require debug_objects flag for debug-objects test
rcutorture: Test duplicate call_rcu_tasks() callback enqueue
rcutorture: Test duplicate call_rcu_tasks_trace() callback enqueue
rcutorture: Add KASAN aux-stack self-test
rcutorture: Add kasan-aux.sh aux-stack checker
rcutorture: Run KASAN aux-stack checks from torture.sh

 Documentation/RCU/torture.rst                 |  46 ++++
 .../admin-guide/kernel-parameters.txt         |  11 +
 kernel/rcu/rcutorture.c                       |  55 ++++-
 kernel/rcu/tasks.h                            |   4 +
 .../rcutorture/bin/kasan-aux-check.sh         | 158 ++++++++++++
 .../selftests/rcutorture/bin/kasan-aux.sh     | 228 ++++++++++++++++++
 .../selftests/rcutorture/bin/torture.sh       |   9 +
 7 files changed, 509 insertions(+), 2 deletions(-)
 create mode 100755 tools/testing/selftests/rcutorture/bin/kasan-aux-check.sh
 create mode 100755 tools/testing/selftests/rcutorture/bin/kasan-aux.sh
Signature · 1 line
2.43.0