--- zzzz-none-000/linux-5.4.213/kernel/notifier.c 2022-09-15 10:04:56.000000000 +0000 +++ miami-7690-761/linux-5.4.213/kernel/notifier.c 2024-05-29 11:20:02.000000000 +0000 @@ -64,6 +64,29 @@ return -ENOENT; } +#ifdef CONFIG_SHOW_NOTIFIER_IF_OOPS +int show_notifier_if_oops = -1; + +static void notifier_show_chain(void *nh, struct notifier_block **nl) +{ + struct notifier_block *nb; + + nb = rcu_dereference_raw(*nl); + + if (nb) + pr_info("Following notifiers will be called for chain (check System.map): %ps:\n", + nh); + else + /* chain is empty, no need to print out anything */ + return; + + while (nb) { + pr_info(" - %ps\n", nb->notifier_call); + nb = rcu_dereference_raw(nb->next); + } +} +#endif + /** * notifier_call_chain - Informs the registered notifiers about an event. * @nl: Pointer to head of the blocking notifier chain @@ -95,6 +118,10 @@ continue; } #endif +#ifdef CONFIG_SHOW_NOTIFIER_IF_OOPS + if (show_notifier_if_oops == raw_smp_processor_id()) + pr_info("[notifier] %ps:\n", nb->notifier_call); +#endif ret = nb->notifier_call(nb, val, v); if (nr_calls) @@ -185,6 +212,10 @@ int ret; rcu_read_lock(); +#ifdef CONFIG_SHOW_NOTIFIER_IF_OOPS + if (show_notifier_if_oops == raw_smp_processor_id()) + notifier_show_chain(nh, &nh->head); +#endif ret = notifier_call_chain(&nh->head, val, v, nr_to_call, nr_calls); rcu_read_unlock(); return ret; @@ -319,6 +350,10 @@ */ if (rcu_access_pointer(nh->head)) { down_read(&nh->rwsem); +#ifdef CONFIG_SHOW_NOTIFIER_IF_OOPS + if (show_notifier_if_oops == raw_smp_processor_id()) + notifier_show_chain(nh, &nh->head); +#endif ret = notifier_call_chain(&nh->head, val, v, nr_to_call, nr_calls); up_read(&nh->rwsem); @@ -396,6 +431,10 @@ unsigned long val, void *v, int nr_to_call, int *nr_calls) { +#ifdef CONFIG_SHOW_NOTIFIER_IF_OOPS + if (show_notifier_if_oops == raw_smp_processor_id()) + notifier_show_chain(nh, &nh->head); +#endif return notifier_call_chain(&nh->head, val, v, nr_to_call, nr_calls); } EXPORT_SYMBOL_GPL(__raw_notifier_call_chain); @@ -500,6 +539,10 @@ int idx; idx = srcu_read_lock(&nh->srcu); +#ifdef CONFIG_SHOW_NOTIFIER_IF_OOPS + if (show_notifier_if_oops == raw_smp_processor_id()) + notifier_show_chain(nh, &nh->head); +#endif ret = notifier_call_chain(&nh->head, val, v, nr_to_call, nr_calls); srcu_read_unlock(&nh->srcu, idx); return ret;