]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
selinux: hooks: use __getname() to allocate path buffer
authorMike Rapoport (Microsoft) <rppt@kernel.org>
Wed, 20 May 2026 08:18:56 +0000 (11:18 +0300)
committerPaul Moore <paul@paul-moore.com>
Wed, 27 May 2026 23:42:40 +0000 (19:42 -0400)
selinux_genfs_get_sid() allocates memory for a path with __get_free_page()
although there is a dedicated helper for allocation of file paths:
__getname().

Replace __get_free_page() for allocation of a path buffer with __getname().

Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Signed-off-by: Paul Moore <paul@paul-moore.com>
security/selinux/hooks.c

index 97801966bf32c23383a5e3775a030a03f23e5f86..95d0fb20d84ec38d8a714d553193ddc39c8b74b9 100644 (file)
@@ -1336,7 +1336,7 @@ static int selinux_genfs_get_sid(struct dentry *dentry,
        struct super_block *sb = dentry->d_sb;
        char *buffer, *path;
 
-       buffer = (char *)__get_free_page(GFP_KERNEL);
+       buffer = __getname();
        if (!buffer)
                return -ENOMEM;
 
@@ -1361,7 +1361,7 @@ static int selinux_genfs_get_sid(struct dentry *dentry,
                        rc = 0;
                }
        }
-       free_page((unsigned long)buffer);
+       __putname(buffer);
        return rc;
 }