Thread (28 messages) 28 messages, 7 authors, 8d ago

[PATCH 17/17] sysctl: assert static storage for DEFINE_CTL_TABLE_POLL()

flat view
COOLING8d

From: Yury Norov <hidden>
Date: 2026-09-15 03:14:33
Also in: linux-fsdevel, linux-mm, linux-rt-devel, linuxppc-dev, lkml, llvm, rcu, virtualization
Subsystem: proc sysctl, the rest · Maintainers: Kees Cook, Joel Granados, Linus Torvalds

DEFINE_CTL_TABLE_POLL() statically initializes an embedded wait queue.
An automatic local poll object cannot provide the persistent lockdep
class key expected by its wait queue lock.

Add ASSERT_STATIC_STORAGE() to reject automatic declarations while
preserving file-scope and static local definitions. Leave the underlying
initializer available for embedded objects.

Assisted-by: OpenAI Codex
Signed-off-by: Yury Norov <redacted>
---
 include/linux/sysctl.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index e5d7226ab6f5..be79359346af 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -22,6 +22,7 @@
 #ifndef _LINUX_SYSCTL_H
 #define _LINUX_SYSCTL_H
 
+#include <linux/compiler.h>
 #include <linux/list.h>
 #include <linux/rcupdate.h>
 #include <linux/wait.h>
@@ -216,7 +217,8 @@ static inline void *proc_sys_poll_event(struct ctl_table_poll *poll)
 	.wait = __WAIT_QUEUE_HEAD_INITIALIZER(name.wait) }
 
 #define DEFINE_CTL_TABLE_POLL(name)					\
-	struct ctl_table_poll name = __CTL_TABLE_POLL_INITIALIZER(name)
+	struct ctl_table_poll name = __CTL_TABLE_POLL_INITIALIZER(name);	\
+	ASSERT_STATIC_STORAGE(name)
 
 /* A sysctl table is an array of struct ctl_table: */
 struct ctl_table {
-- 
2.53.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help