linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] notifiers: double register detection
@ 2019-03-12  8:06 Vasily Averin
  2019-03-12  8:20 ` Vasily Averin
  0 siblings, 1 reply; 2+ messages in thread
From: Vasily Averin @ 2019-03-12  8:06 UTC (permalink / raw)
  To: linux-kernel, Andrew Morton

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 <vvs@virtuozzo.com>
---
 kernel/notifier.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/notifier.c b/kernel/notifier.c
index 6196af8a8223..bfc95b3e4235 100644
--- a/kernel/notifier.c
+++ b/kernel/notifier.c
@@ -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);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] notifiers: double register detection
  2019-03-12  8:06 [PATCH] notifiers: double register detection Vasily Averin
@ 2019-03-12  8:20 ` Vasily Averin
  0 siblings, 0 replies; 2+ messages in thread
From: Vasily Averin @ 2019-03-12  8:20 UTC (permalink / raw)
  To: linux-kernel, Andrew Morton

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

On 3/12/19 11:06 AM, Vasily Averin wrote:
> 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 <vvs@virtuozzo.com>
> ---
>  kernel/notifier.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/kernel/notifier.c b/kernel/notifier.c
> index 6196af8a8223..bfc95b3e4235 100644
> --- a/kernel/notifier.c
> +++ b/kernel/notifier.c
> @@ -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);
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-03-12  8:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-12  8:06 [PATCH] notifiers: double register detection Vasily Averin
2019-03-12  8:20 ` Vasily Averin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).