Skip to contentSkip to conversation

proc/sysctl: make protected_* world readable

PATCH Applied Julius Hemanth Pitti 3 participants 3 messages Jul 9, 2020 – Jul 29, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 proc/sysctl: make protected_* world readable

protected_* files have 600 permissions which prevents non-superuser from reading them.

Container like "AWS greengrass" refuse to launch unless protected_hardlinks and protected_symlinks are set. When containers like these run with "userns-remap" or "--user" mapping container's root to non-superuser on host, they fail to run due to denied read access to these files.

As these protections are hardly a secret, and do not possess any security risk, making them world readable.

Though above greengrass usecase needs read access to only protected_hardlinks and protected_symlinks files, setting all other protected_* files to 644 to keep consistency.

Fixes 800179c9b8a1 ("fs: add link restrictions")
---
 kernel/sysctl.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
kernel/sysctl.c +4 -4
index db1ce7a..aeca2fd 100644
@@ -3223,7 +3223,7 @@ int proc_do_static_key(struct ctl_table *table, int write,
 		.procname	= "protected_symlinks",
 		.data		= &sysctl_protected_symlinks,
 		.maxlen		= sizeof(int),
-		.mode		= 0600,
+		.mode		= 0644,
 		.proc_handler	= proc_dointvec_minmax,
 		.extra1		= SYSCTL_ZERO,
 		.extra2		= SYSCTL_ONE,
@@ -3232,7 +3232,7 @@ int proc_do_static_key(struct ctl_table *table, int write,
 		.procname	= "protected_hardlinks",
 		.data		= &sysctl_protected_hardlinks,
 		.maxlen		= sizeof(int),
-		.mode		= 0600,
+		.mode		= 0644,
 		.proc_handler	= proc_dointvec_minmax,
 		.extra1		= SYSCTL_ZERO,
 		.extra2		= SYSCTL_ONE,
@@ -3241,7 +3241,7 @@ int proc_do_static_key(struct ctl_table *table, int write,
 		.procname	= "protected_fifos",
 		.data		= &sysctl_protected_fifos,
 		.maxlen		= sizeof(int),
-		.mode		= 0600,
+		.mode		= 0644,
 		.proc_handler	= proc_dointvec_minmax,
 		.extra1		= SYSCTL_ZERO,
 		.extra2		= &two,
@@ -3250,7 +3250,7 @@ int proc_do_static_key(struct ctl_table *table, int write,
 		.procname	= "protected_regular",
 		.data		= &sysctl_protected_regular,
 		.maxlen		= sizeof(int),
-		.mode		= 0600,
+		.mode		= 0644,
 		.proc_handler	= proc_dointvec_minmax,
 		.extra1		= SYSCTL_ZERO,
 		.extra2		= &two,
Signature · 1 line
1.7.1
Acked-by on v1 1/1
#1 lore raw
Quoted 12 lines · Julius Hemanth Pitti

protected_* files have 600 permissions which prevents non-superuser from reading them.

Container like "AWS greengrass" refuse to launch unless protected_hardlinks and protected_symlinks are set. When containers like these run with "userns-remap" or "--user" mapping container's root to non-superuser on host, they fail to run due to denied read access to these files.

As these protections are hardly a secret, and do not possess any security risk, making them world readable.

Quoted 7 lines

Though above greengrass usecase needs read access to only protected_hardlinks and protected_symlinks files, setting all other protected_* files to 644 to keep consistency.

Fixes 800179c9b8a1 ("fs: add link restrictions")

I had originally proposed it as 0644, but Ingo asked that it have a more conservative default value[1]. I figured that given the settings can be discovered easily, it's not worth much. And if there are legit cases where things are improved, I don't have a problem switching this back.

Ingo, any thoughts on this now, 8 years later in the age of containers? :)

(One devil's advocate question: as a workaround, you are able to just change those files to 0644 after mounting /proc, yes? But regardless, why get in people's way for no justifiable reason.)

-Kees

[1] https://lore.kernel.org/lkml/[email protected]/

Signature · 1 line
Kees Cook
#2 lore raw
Quoted 21 lines · Kees Cook
Quoted 12 lines · Julius Hemanth Pitti

protected_* files have 600 permissions which prevents non-superuser from reading them.

Container like "AWS greengrass" refuse to launch unless protected_hardlinks and protected_symlinks are set. When containers like these run with "userns-remap" or "--user" mapping container's root to non-superuser on host, they fail to run due to denied read access to these files.

As these protections are hardly a secret, and do not possess any security risk, making them world readable.

Quoted 7 lines

Though above greengrass usecase needs read access to only protected_hardlinks and protected_symlinks files, setting all other protected_* files to 644 to keep consistency.

Fixes 800179c9b8a1 ("fs: add link restrictions")
Quoted 7 lines

I had originally proposed it as 0644, but Ingo asked that it have a more conservative default value[1]. I figured that given the settings can be discovered easily, it's not worth much. And if there are legit cases where things are improved, I don't have a problem switching this back.

If we're going to to do this, can we please document why these are "protected" then?

Luis

Quoted 14 lines

Ingo, any thoughts on this now, 8 years later in the age of containers? :)

(One devil's advocate question: as a workaround, you are able to just change those files to 0644 after mounting /proc, yes? But regardless, why get in people's way for no justifiable reason.)

-Kees

[1] https://lore.kernel.org/lkml/[email protected]/

Signature · 1 line
Kees Cook