Skip to contentSkip to conversation

seccomp: Remove bogus __user annotations

PATCH Superseded Jann Horn 2 participants 3 messages Nov 20, 2020 Secure computing

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Jann Horn

author
#0 lore raw

PATCH 1/1 seccomp: Remove bogus __user annotations

Buffers that are passed to read_actions_logged() and write_actions_logged() are in kernel memory; the sysctl core takes care of copying from/to userspace.

Fixes 0ddec0fc8900 ("seccomp: Sysctl to configure actions that are allowed to be logged")
---
 kernel/seccomp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/seccomp.c +2 -2
index 8ad7a293255a..c2bff3561846 100644
@@ -1968,7 +1968,7 @@ static bool seccomp_actions_logged_from_names(u32 *actions_logged, char *names)
 	return true;
 }
 
-static int read_actions_logged(struct ctl_table *ro_table, void __user *buffer,
+static int read_actions_logged(struct ctl_table *ro_table, void *buffer,
 			       size_t *lenp, loff_t *ppos)
 {
 	char names[sizeof(seccomp_actions_avail)];
@@ -1986,7 +1986,7 @@ static int read_actions_logged(struct ctl_table *ro_table, void __user *buffer,
 	return proc_dostring(&table, 0, buffer, lenp, ppos);
 }
 
-static int write_actions_logged(struct ctl_table *ro_table, void __user *buffer,
+static int write_actions_logged(struct ctl_table *ro_table, void *buffer,
 				size_t *lenp, loff_t *ppos, u32 *actions_logged)
 {
 	char names[sizeof(seccomp_actions_avail)];

base-commit: 4d02da974ea85a62074efedf354e82778f910d82

Signature · 1 line
2.29.2.454.gaff20da3a2-goog
Reviewed-by on v1 1/1
#1 lore raw

Hey Jann - Thanks for cleaning this up!

Quoted 5 lines · Jann Horn

Buffers that are passed to read_actions_logged() and write_actions_logged() are in kernel memory; the sysctl core takes care of copying from/to userspace.

Fixes 0ddec0fc8900 ("seccomp: Sysctl to configure actions that are allowed to be logged")

After tracing back through the code, I was struggling to understand why I thought the __user annotation was needed back then. It turns out that __user was correct when I wrote 0ddec0fc8900 and that the Fixes tag should be changed to this:

Fixes 32927393dc1c ("sysctl: pass kernel pointers to ->proc_handler")

If you agree, please adjust and resubmit with:

Thank you!

Tyler

Quoted 32 lines
---
 kernel/seccomp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/seccomp.c +2 -2
index 8ad7a293255a..c2bff3561846 100644
@@ -1968,7 +1968,7 @@ static bool seccomp_actions_logged_from_names(u32 *actions_logged, char *names)
 	return true;
 }
 
-static int read_actions_logged(struct ctl_table *ro_table, void __user *buffer,
+static int read_actions_logged(struct ctl_table *ro_table, void *buffer,
 			       size_t *lenp, loff_t *ppos)
 {
 	char names[sizeof(seccomp_actions_avail)];
@@ -1986,7 +1986,7 @@ static int read_actions_logged(struct ctl_table *ro_table, void __user *buffer,
 	return proc_dostring(&table, 0, buffer, lenp, ppos);
 }
 
-static int write_actions_logged(struct ctl_table *ro_table, void __user *buffer,
+static int write_actions_logged(struct ctl_table *ro_table, void *buffer,
 				size_t *lenp, loff_t *ppos, u32 *actions_logged)
 {
 	char names[sizeof(seccomp_actions_avail)];

base-commit: 4d02da974ea85a62074efedf354e82778f910d82

Signature · 1 line
2.29.2.454.gaff20da3a2-goog
author
#2 lore raw
Quoted 14 lines · Tyler Hicks

Hey Jann - Thanks for cleaning this up!

Quoted 5 lines · Jann Horn

Buffers that are passed to read_actions_logged() and write_actions_logged() are in kernel memory; the sysctl core takes care of copying from/to userspace.

Fixes 0ddec0fc8900 ("seccomp: Sysctl to configure actions that are allowed to be logged")

After tracing back through the code, I was struggling to understand why I thought the __user annotation was needed back then. It turns out that __user was correct when I wrote 0ddec0fc8900 and that the Fixes tag should be changed to this:

Quoted 7 lines
Fixes 32927393dc1c ("sysctl: pass kernel pointers to ->proc_handler")

If you agree, please adjust and resubmit with:

Thank you!

Aaaah, that makes sense. Thanks, will do.