On 7/6/26 23:00, Gabriele Monaco wrote:
On Tue, 2026-06-16 at 00:44 +0800, [email protected] wrote:
+/*
+ * Test 2: panic notifier chain is reachable.
+ *
+ * vpanic() calls atomic_notifier_call_chain(&panic_notifier_list, ...).
+ * Drive the chain directly to verify panic notifiers receive the
notification —
+ * the observable side-effect of reactor_panic without halting the system.
+ */
+static void test_panic_notifier_called(struct kunit *test)
+{
+       atomic_notifier_chain_register(&panic_notifier_list, &mock_panic_nb);
+       atomic_notifier_call_chain(&panic_notifier_list, 0,
+                                  "panic violation message");
+       atomic_notifier_chain_unregister(&panic_notifier_list,
&mock_panic_nb);

I just realised this isn't even testing the reactor, it's testing the
notifier_chain thing, I don't think we really need this here or am I missing
something?


Thanks,

Since rv_panic_reaction calls vpanic() which is __noreturn, direct testing is not feasible in KUnit.

A preparatory v2 drops reactor_printk_kunit.c and reactor_panic_kunit.c
entirely, replacing them with a single rv_reactors_kunit.c containing
two suites:

  rv_reactor_registration: register/unregister lifecycle, duplicate
    rejection (-EINVAL), name-too-long rejection, and safe unregister
    of a never-registered reactor.

  rv_react_dispatch: null-callback guard, callback invocation check,
    and the mdelay lockdep stress test.


v2 also adds EXPORT_SYMBOL_GPL for rv_react(), rv_register_reactor(), and rv_unregister_reactor(), and the Kconfig entry is tristate.

Additional fix: rv_unregister_reactor()

Testing exposed a real bug: rv_unregister_reactor() called list_del()
unconditionally.  On a never-registered reactor the list_head is
zero-initialised, so list_del() dereferences NULL->prev and crashes.
v2 adds a patch that iterates rv_reactors_list first and only calls
list_del() when the reactor is found.  test_unregister_nonexistent
documents and guards this behaviour.


--
Best wishes,
Wen





Reply via email to