[PATCH 15/17] notifier: assert static storage for locking notifier heads

From: Yury Norov

Date: Mon Sep 14 2026 - 23:18:33 EST


Atomic, blocking and SRCU notifier head declarations statically initialize
locks or SRCU state that require persistent lockdep class keys.

Apply ASSERT_STATIC_STORAGE() to ATOMIC_NOTIFIER_HEAD(),
BLOCKING_NOTIFIER_HEAD() and the common _SRCU_NOTIFIER_HEAD() wrapper,
including both Tree SRCU and Tiny SRCU variants. Leave RAW_NOTIFIER_HEAD()
unchanged because it has no such initialization requirement.

Assisted-by: OpenAI Codex
Signed-off-by: Yury Norov <ynorov@xxxxxxxxxx>
---
include/linux/notifier.h | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/include/linux/notifier.h b/include/linux/notifier.h
index 01b6c9d9956f..4f6330360df2 100644
--- a/include/linux/notifier.h
+++ b/include/linux/notifier.h
@@ -10,6 +10,7 @@

#ifndef _LINUX_NOTIFIER_H
#define _LINUX_NOTIFIER_H
+#include <linux/compiler.h>
#include <linux/errno.h>
#include <linux/mutex.h>
#include <linux/rwsem.h>
@@ -114,10 +115,12 @@ extern void srcu_init_notifier_head(struct srcu_notifier_head *nh);

#define ATOMIC_NOTIFIER_HEAD(name) \
struct atomic_notifier_head name = \
- ATOMIC_NOTIFIER_INIT(name)
+ ATOMIC_NOTIFIER_INIT(name); \
+ ASSERT_STATIC_STORAGE(name)
#define BLOCKING_NOTIFIER_HEAD(name) \
struct blocking_notifier_head name = \
- BLOCKING_NOTIFIER_INIT(name)
+ BLOCKING_NOTIFIER_INIT(name); \
+ ASSERT_STATIC_STORAGE(name)
#define RAW_NOTIFIER_HEAD(name) \
struct raw_notifier_head name = \
RAW_NOTIFIER_INIT(name)
@@ -126,12 +129,14 @@ extern void srcu_init_notifier_head(struct srcu_notifier_head *nh);
#define _SRCU_NOTIFIER_HEAD(name, mod) \
static DEFINE_PER_CPU(struct srcu_data, name##_head_srcu_data); \
mod struct srcu_notifier_head name = \
- SRCU_NOTIFIER_INIT(name, name##_head_srcu_data)
+ SRCU_NOTIFIER_INIT(name, name##_head_srcu_data); \
+ ASSERT_STATIC_STORAGE(name)

#else
#define _SRCU_NOTIFIER_HEAD(name, mod) \
mod struct srcu_notifier_head name = \
- SRCU_NOTIFIER_INIT(name, name)
+ SRCU_NOTIFIER_INIT(name, name); \
+ ASSERT_STATIC_STORAGE(name)

#endif

--
2.53.0