]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
fs/proc/namespaces: make ns_entries const
authorMax Kellermann <max.kellermann@ionos.com>
Tue, 9 Sep 2025 07:55:06 +0000 (09:55 +0200)
committerChristian Brauner <brauner@kernel.org>
Mon, 15 Sep 2025 12:28:37 +0000 (14:28 +0200)
Global variables that are never modified should be "const" so so that
they live in the .rodata section instead of the .data section of the
kernel, gaining the protection of the kernel's strict memory
permissions as described in Documentation/security/self-protection.rst

Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/proc/namespaces.c

index 4403a2e20c165d98a10c7632c68744066acc6128..ea2b597fd92cdb7856358205b09dab0ea962214f 100644 (file)
@@ -12,7 +12,7 @@
 #include "internal.h"
 
 
-static const struct proc_ns_operations *ns_entries[] = {
+static const struct proc_ns_operations *const ns_entries[] = {
 #ifdef CONFIG_NET_NS
        &netns_operations,
 #endif
@@ -117,7 +117,7 @@ static struct dentry *proc_ns_instantiate(struct dentry *dentry,
 static int proc_ns_dir_readdir(struct file *file, struct dir_context *ctx)
 {
        struct task_struct *task = get_proc_task(file_inode(file));
-       const struct proc_ns_operations **entry, **last;
+       const struct proc_ns_operations *const *entry, *const *last;
 
        if (!task)
                return -ENOENT;
@@ -151,7 +151,7 @@ static struct dentry *proc_ns_dir_lookup(struct inode *dir,
                                struct dentry *dentry, unsigned int flags)
 {
        struct task_struct *task = get_proc_task(dir);
-       const struct proc_ns_operations **entry, **last;
+       const struct proc_ns_operations *const *entry, *const *last;
        unsigned int len = dentry->d_name.len;
        struct dentry *res = ERR_PTR(-ENOENT);