[PATCH RFC 1/9] sysctl: Add struct ctl_table_tmpl as a distinct template type

From: Joel Granados

Date: Thu Nov 26 2026 - 06:48:25 EST


Introduce a new ctl_table template type identical to ctl_table for when
the table caries several different versions/values of the same path
(think namespaces).

This is a prep commit introducing the struct, no functional change
expected. Sysctl core expects these two to be identical except for the
name; ensure this with a build assert.

Signed-off-by: Joel Granados <joel.granados@xxxxxxxxxx>
---
include/linux/sysctl.h | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index e5d7226ab6f5af34a33829883ad5d1b405e19c86..4faa3bc189e7afbc270f4ba14b04b32a3f2d1413 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/build_bug.h>
#include <linux/list.h>
#include <linux/rcupdate.h>
#include <linux/wait.h>
@@ -230,6 +231,15 @@ struct ctl_table {
void *extra2;
} __randomize_layout;

+/* Template version of struct ctl_table. Used for registering ctl_table templates */
+struct ctl_table_tmpl {
+ struct ctl_table t;
+};
+
+static_assert(sizeof(struct ctl_table_tmpl) == sizeof(struct ctl_table));
+static_assert(__alignof__(struct ctl_table_tmpl) == __alignof__(struct ctl_table));
+static_assert(offsetof(struct ctl_table_tmpl, t) == 0);
+
struct ctl_node {
struct rb_node node;
struct ctl_table_header *header;

--
2.50.1