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() is not implemented.
It missed to also adjust net_ctl_set_ownership() to use the same default
values in case the computation of a better value fails.
Instead always initialize i_uid/i_gid inside the sysfs core so
set_ownership() can safely skip setting them.
Fixes: 5ec27ec735ba ("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]>
---
Changes in v3:
- Rebase onto v6.9-rc1
- Reword commit message and mention correct fixed commit
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- Move the fallback logic to the sysctl core
- Link to v1: https://lore.kernel.org/r/[email protected]
---
fs/proc/proc_sysctl.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index 37cde0efee57..9e34ab9c21e4 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -479,12 +479,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, table, &inode->i_uid, &inode->i_gid);
- else {
- inode->i_uid = GLOBAL_ROOT_UID;
- inode->i_gid = GLOBAL_ROOT_GID;
- }
return inode;
}
---
base-commit: 4cece764965020c22cff7665b18a012006359095
change-id: 20240315-sysctl-net-ownership-bc4e17eaeea6
Best regards,
--
Thomas Weißschuh <[email protected]>
On Tue, Apr 02, 2024 at 11:10:34PM +0200, Thomas Wei?schuh wrote:
> 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() is not implemented.
> It missed to also adjust net_ctl_set_ownership() to use the same default
> values in case the computation of a better value fails.
>
> Instead always initialize i_uid/i_gid inside the sysfs core so
> set_ownership() can safely skip setting them.
Added this to sysctl-testing with minor changes in the commit message:
"""
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 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: [email protected]
Signed-off-by: Thomas Wei?schuh <[email protected]>
Signed-off-by: Joel Granados <[email protected]>
"""
Will let it simmer in testing for now.
Best
>
> Fixes: 5ec27ec735ba ("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]>
> ---
> Changes in v3:
> - Rebase onto v6.9-rc1
> - Reword commit message and mention correct fixed commit
> - Link to v2: https://lore.kernel.org/r/[email protected]
>
> Changes in v2:
> - Move the fallback logic to the sysctl core
> - Link to v1: https://lore.kernel.org/r/[email protected]
> ---
> fs/proc/proc_sysctl.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
> index 37cde0efee57..9e34ab9c21e4 100644
> --- a/fs/proc/proc_sysctl.c
> +++ b/fs/proc/proc_sysctl.c
> @@ -479,12 +479,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, table, &inode->i_uid, &inode->i_gid);
> - else {
> - inode->i_uid = GLOBAL_ROOT_UID;
> - inode->i_gid = GLOBAL_ROOT_GID;
> - }
>
> return inode;
> }
>
> ---
> base-commit: 4cece764965020c22cff7665b18a012006359095
> change-id: 20240315-sysctl-net-ownership-bc4e17eaeea6
>
> Best regards,
> --
> Thomas Wei?schuh <[email protected]>
>
--
Joel Granados
On Tue, Apr 02, 2024 at 11:10:34PM +0200, Thomas Wei?schuh wrote:
> 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() is not implemented.
> It missed to also adjust net_ctl_set_ownership() to use the same default
> values in case the computation of a better value fails.
>
> Instead always initialize i_uid/i_gid inside the sysfs core so
> set_ownership() can safely skip setting them.
>
> Fixes: 5ec27ec735ba ("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]>
> ---
> Changes in v3:
> - Rebase onto v6.9-rc1
> - Reword commit message and mention correct fixed commit
> - Link to v2: https://lore.kernel.org/r/[email protected]
>
> Changes in v2:
> - Move the fallback logic to the sysctl core
> - Link to v1: https://lore.kernel.org/r/[email protected]
> ---
> fs/proc/proc_sysctl.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
> index 37cde0efee57..9e34ab9c21e4 100644
> --- a/fs/proc/proc_sysctl.c
> +++ b/fs/proc/proc_sysctl.c
> @@ -479,12 +479,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, table, &inode->i_uid, &inode->i_gid);
> - else {
> - inode->i_uid = GLOBAL_ROOT_UID;
> - inode->i_gid = GLOBAL_ROOT_GID;
> - }
>
> return inode;
> }
>
> ---
> base-commit: 4cece764965020c22cff7665b18a012006359095
> change-id: 20240315-sysctl-net-ownership-bc4e17eaeea6
>
> Best regards,
> --
> Thomas Wei?schuh <[email protected]>
>
Queueing this up for 6.11....
Reviewed-by: Joel Granados <[email protected]>
--
Joel Granados