summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJoel Granados <joel.granados@kernel.org>2026-08-10 15:01:02 +0200
committerPaolo Abeni <pabeni@redhat.com>2026-08-13 13:12:21 +0200
commitef6cb145e216b0378686bce356f3317284d54231 (patch)
treeec58eb5ebb5d26b311f0d781a6b5f7bd3bb4035b /include
parent68b3d4dbaf20539fc3268a2def90aa5e3b79bcb9 (diff)
downloadlinux-ef6cb145e216b0378686bce356f3317284d54231.tar.gz
linux-ef6cb145e216b0378686bce356f3317284d54231.zip
net: enforce net sysctl registration
Replace the warning and file permission change with an error when an "unsafe" net sysctl registration is detected. One of the barriers preventing the const qualification of the ctl_tables in the net directory is the permission (->mode) change in ensure_safe_net_sysctl. This prep commit removes that barrier and ensures that the received ctl_table pointer to the net ctl_table register function is const. Signed-off-by: Joel Granados <joel.granados@kernel.org> Link: https://patch.msgid.link/20260810-jag-net_const_qualify-v4-1-77e888237c69@kernel.org Reviewed-by: Simon Horman <horms@kernel.org> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Diffstat (limited to 'include')
-rw-r--r--include/net/net_namespace.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
index 501af1999fe8..e5ee673b9fcf 100644
--- a/include/net/net_namespace.h
+++ b/include/net/net_namespace.h
@@ -525,12 +525,13 @@ struct ctl_table;
#ifdef CONFIG_SYSCTL
int net_sysctl_init(void);
struct ctl_table_header *register_net_sysctl_sz(struct net *net, const char *path,
- struct ctl_table *table, size_t table_size);
+ const struct ctl_table *table,
+ size_t table_size);
void unregister_net_sysctl_table(struct ctl_table_header *header);
#else
static inline int net_sysctl_init(void) { return 0; }
static inline struct ctl_table_header *register_net_sysctl_sz(struct net *net,
- const char *path, struct ctl_table *table, size_t table_size)
+ const char *path, const struct ctl_table *table, size_t table_size)
{
return NULL;
}