notifiers: double register detection
PATCH 1/1 notifiers: double register detection
By design notifiers can be registerd once only,
2nd register attempt called by mistake silently corrupts notifiers list.
Proposed check cannot prevent described problem,
however it allows to detect its reason quickly without coredump analyze.
--- kernel/notifier.c | 1 + 1 file changed, 1 insertion(+)
kernel/notifier.c +1 -0
@@ -22,6 +22,7 @@ static int notifier_chain_register(struct notifier_block **nl, struct notifier_block *n) {while ((*nl) !=NULL ) { +WARN_ONCE (((*nl) == n),"double register detected" );if (n->priority > (*nl)->priority)break ; nl = &((*nl)->next);
Signature · 1 line
2.17.1
Dear Andrew,
could you please pick up this patch?
Few years ago I investigated described problem, host was cycled because of notifier's list corruption. I've prepared this patch applied it to OpenVZ kernel and sent this patch first time, but nobody commented it. Later it helped us to detect similar problem on OpenVz kernel.
Mistakes with notifiers register can happen for example during subsystem initilazation from different namespaces, or because of lost unregister in roll-back path on initialization failures.
Thank you,
Vasily Averin
Quoted 24 lines · Vasily Averin
By design notifiers can be registerd once only,
2nd register attempt called by mistake silently corrupts notifiers list.Proposed check cannot prevent described problem,
however it allows to detect its reason quickly without coredump analyze.Signed-off-by Vasily Averin <[email protected]>--- kernel/notifier.c | 1 + 1 file changed, 1 insertion(+)kernel/notifier.c +1
-0@@ -22,6 +22,7 @@ static int notifier_chain_register(struct notifier_block **nl, struct notifier_block *n) {while ((*nl) !=NULL ) { +WARN_ONCE (((*nl) == n),"double register detected" );if (n->priority > (*nl)->priority)break ; nl = &((*nl)->next);