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

Joel Granados <[email protected]>
Newsgroups org.kernel.vger.linux-fsdevel,dev.linux.lists.linux-rt-devel,dev.linux.lists.llvm,dev.linux.lists.virtualization,org.kernel.vger.linux-kernel,org.kernel.vger.netdev,org.kernel.vger.rcu,org.kvack.linux-mm,org.ozlabs.lists.linuxppc-dev
Message-ID <av3s3fgets23siaqxbtyu5gvcekqpq2nmyey6oa6o6amfj6jbi@zomsnfvvxtf4>
On Mon, Sep 14, 2026 at 11:13:32PM -0400, Yury Norov wrote:
> 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 <[email protected]>
> ---
>  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
> 

This looks OK for sysctl and the two users of DEFINE_CTL_TABLE_POLL in
utsname_sysctl.c (hostname_poll and domainname_poll)

Reviewed-by: Joel Granados <[email protected]>

Best
signature.asc (application/pgp-signature, 659 B)
-----BEGIN PGP SIGNATURE-----

iQGzBAABCgAdFiEErkcJVyXmMSXOyyeQupfNUreWQU8FAmqs5mgACgkQupfNUreW
QU+Slwv/V1va9Xy3ewVVGpZbKof7lX0SuxpAV+wYGoQU9hE6Ofexe2lgpstvBg5q
R4BplT9ThJvF8d3hzCkPNWmWHuXW19VfnmKKdy7zNHYo8lyVLEyFmOlw+3sZ6czr
e7JVfspT2rWbf/0oF8GiQvMCV31pFqQty+c4bb5ZV64xBCKqIxBX9DMXYOstdt1z
hRlSyBTjYabun1LJPo7Nkj/puYlCklMcipRzJNONXZgWt0LFRsCYSZRrAdk2ISeP
y7e87NG2DiVBd/d58WvPvdwdpmhX4vHSNXdSbeLwTn26F3bg7yaNsXd2sCSVTu/o
4S0G/bMFUP/e2oNe/wtaO+XBnDhJYPk3DGvYkFf/C8DFyCVi36tjb4SrQv3D0QV9
PGWE2Hek8KHr3W4oRbZIQm6zMUwg9/fu4speRR5+1xnuBlVsRXtEOQgEr/DkWYHw
8SYHe3rOXtaFsbMWdItXR1CRib516haep77aGjErq93c3ViZF1JEEMBQdXjqjWmm
LKs/7uqR
=5LAv
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.