]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
sysctl: always initialize i_uid/i_gid
authorThomas Weißschuh <linux@weissschuh.net>
Tue, 2 Apr 2024 21:10:34 +0000 (23:10 +0200)
committerJoel Granados <j.granados@samsung.com>
Mon, 3 Jun 2024 13:11:58 +0000 (15:11 +0200)
Always initialize i_uid/i_gid inside the sysfs core so set_ownership()
can safely skip setting them.

Commit 5ec27ec735ba ("fs/proc/proc_sysctl.c: fix the default values of
i_uid/i_gid on /proc/sys inodes.") added defaults for i_uid/i_gid when
set_ownership() was not implemented. It also missed adjusting
net_ctl_set_ownership() to use the same default values in case the
computation of a better value failed.

Fixes: 5ec27ec735ba ("fs/proc/proc_sysctl.c: fix the default values of i_uid/i_gid on /proc/sys inodes.")
Cc: stable@vger.kernel.org
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Signed-off-by: Joel Granados <j.granados@samsung.com>
fs/proc/proc_sysctl.c

index b1c2c0b821161f158d8b24df1b5806886508c313..dd7b462387a00d9df66e86556720ca17d68824d2 100644 (file)
@@ -476,12 +476,10 @@ static struct inode *proc_sys_make_inode(struct super_block *sb,
                        make_empty_dir_inode(inode);
        }
 
+       inode->i_uid = GLOBAL_ROOT_UID;
+       inode->i_gid = GLOBAL_ROOT_GID;
        if (root->set_ownership)
                root->set_ownership(head, &inode->i_uid, &inode->i_gid);
-       else {
-               inode->i_uid = GLOBAL_ROOT_UID;
-               inode->i_gid = GLOBAL_ROOT_GID;
-       }
 
        return inode;
 }