Commit 5eb3829f authored by Thomas Weißschuh's avatar Thomas Weißschuh Committed by Long Li
Browse files

sysctl: always initialize i_uid/i_gid

stable inclusion
from stable-v6.6.44
commit ffde3af4b29bf97d62d82e1d45275587e10a991a
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/IAKQ93
CVE: CVE-2024-42312

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=tags/v6.6.45&id=ffde3af4b29bf97d62d82e1d45275587e10a991a



--------------------------------

[ Upstream commit 98ca62ba9e2be5863c7d069f84f7166b45a5b2f4 ]

Always initialize i_uid/i_gid inside the sysfs core so set_ownership()
can safely skip setting them.

Commit 5ec27ec7 ("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: 5ec27ec7 ("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: default avatarThomas Weißschuh <linux@weissschuh.net>
Signed-off-by: default avatarJoel Granados <j.granados@samsung.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Conflicts:
	fs/proc/proc_sysctl.c
[Conflicts due not merged 96f1d909cdd7 ("sysctl: treewide: drop unused
argument ctl_table_root::set_ownership(table)")]
Signed-off-by: default avatarLong Li <leo.lilong@huawei.com>
parent 711eae2d
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -480,12 +480,10 @@ static struct inode *proc_sys_make_inode(struct super_block *sb,
			make_empty_dir_inode(inode);
	}

	if (root->set_ownership)
		root->set_ownership(head, table, &inode->i_uid, &inode->i_gid);
	else {
	inode->i_uid = GLOBAL_ROOT_UID;
	inode->i_gid = GLOBAL_ROOT_GID;
	}
	if (root->set_ownership)
		root->set_ownership(head, table, &inode->i_uid, &inode->i_gid);

	return inode;
}