Skip to content

Commit 98ca62b

Browse files
t-8chJoelgranados
authored andcommitted
sysctl: always initialize i_uid/i_gid
Always initialize i_uid/i_gid inside the sysfs core so set_ownership() can safely skip setting them. Commit 5ec27ec ("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: 5ec27ec ("fs/proc/proc_sysctl.c: fix the default values of i_uid/i_gid on /proc/sys inodes.") Cc: [email protected] Signed-off-by: Thomas Weißschuh <[email protected]> Signed-off-by: Joel Granados <[email protected]>
1 parent c3f38fa commit 98ca62b

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

fs/proc/proc_sysctl.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -476,12 +476,10 @@ static struct inode *proc_sys_make_inode(struct super_block *sb,
476476
make_empty_dir_inode(inode);
477477
}
478478

479+
inode->i_uid = GLOBAL_ROOT_UID;
480+
inode->i_gid = GLOBAL_ROOT_GID;
479481
if (root->set_ownership)
480482
root->set_ownership(head, &inode->i_uid, &inode->i_gid);
481-
else {
482-
inode->i_uid = GLOBAL_ROOT_UID;
483-
inode->i_gid = GLOBAL_ROOT_GID;
484-
}
485483

486484
return inode;
487485
}

0 commit comments

Comments
 (0)