Skip to contentSkip to conversation

proc: use set_puts() at /proc/*/wchan

PATCH In review Alexey Dobriyan 4 participants 6 messages Feb 17, 2018 – Feb 21, 2018 Proc filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 2/2 proc: use set_puts() at /proc/*/wchan

---

 fs/proc/base.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/proc/base.c +1 -1
@@ -396,7 +396,7 @@ static int proc_pid_wchan(struct seq_file *m, struct pid_namespace *ns,
 
 	wchan = get_wchan(task);
 	if (wchan && !lookup_symbol_name(wchan, symname)) {
-		seq_printf(m, "%s", symname);
+		seq_puts(m, symname);
 		return 0;
 	}
 
#1 lore raw

fs/proc/base.c static int proc_pid_wchan(struct seq_file *m, struct pid_namespace *ns, · line 399

Quoted 5 lines · Alexey Dobriyan
fs/proc/base.c +1 -1
-               seq_printf(m, "%s", symname);
+               seq_puts(m, symname);

While this might have no security concerns, the pattern might be brainlessly used by some janitors and there would have security implications.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#2 lore raw
Quoted 7 lines · Andy Shevchenko

fs/proc/base.c static int proc_pid_wchan(struct seq_file *m, struct pid_namespace *ns, · line 399

Quoted 2 lines · Alexey Dobriyan
fs/proc/base.c +1 -1
-               seq_printf(m, "%s", symname);
+               seq_puts(m, symname);

While this might have no security concerns, the pattern might be brainlessly used by some janitors and there would have security implications.

Unless there is some kind of preprocessor which seamlessly converts one to another I'd continue converting.

#3 lore raw
In reply to Andy Shevchenko
Quoted 10 lines · On Sat, 17 Feb 2018 16:06:42 +0200 Andy Shevchenko <[email protected]>…

fs/proc/base.c static int proc_pid_wchan(struct seq_file *m, struct pid_namespace *ns, · line 399

Quoted 5 lines · Alexey Dobriyan
fs/proc/base.c +1 -1
-               seq_printf(m, "%s", symname);
+               seq_puts(m, symname);

While this might have no security concerns, the pattern might be brainlessly used by some janitors and there would have security implications.

And I'd like to see a changelog, please. One which explains why `symname' cannot have a %s (etc) in it, and never will.

#4 lore raw
Quoted 9 lines · Andrew Morton
Quoted 7 lines · On Sat, 17 Feb 2018 16:06:42 +0200 Andy Shevchenko <[email protected]>…
Quoted 5 lines · Alexey Dobriyan
fs/proc/base.c +1 -1
-               seq_printf(m, "%s", symname);
+               seq_puts(m, symname);
Quoted 6 lines
Quoted 3 lines

While this might have no security concerns, the pattern might be brainlessly used by some janitors and there would have security implications.

And I'd like to see a changelog, please. One which explains why `symname' cannot have a %s (etc) in it, and never will.

OK, since #youtoo: It doesn't _matter_ if symname is "%pHAHAHA %fooled you <unicode for evil grin emoji>", seq_puts does not interpret it at all. There are _never_ security implications with the above replacement. Sure, seq_printf(m, symname) would be bad, but that's not what is being done.

AFAICT, this should always lead to slightly smaller code (one less parameter passed) and in all likelyhood also slightly faster (no format interpretation, no slow char-by-char handling by the string() function etc.). So the only case where I'd think this should not necessarily be done would be in a long sequence of seq_printf, where only one or two could be replaced by seq_puts/seq_putc.

Rasmus

#5 lore raw
Quoted 14 lines · On Wed, 21 Feb 2018 09:57:49 +0100 Rasmus Villemoes…
Quoted 13 lines · Andrew Morton
Quoted 10 lines · On Sat, 17 Feb 2018 16:06:42 +0200 Andy Shevchenko <[email protected]>…

fs/proc/base.c static int proc_pid_wchan(struct seq_file *m, struct pid_namespace *ns, · line 399

Quoted 5 lines · Alexey Dobriyan
fs/proc/base.c +1 -1
-               seq_printf(m, "%s", symname);
+               seq_puts(m, symname);

While this might have no security concerns, the pattern might be brainlessly used by some janitors and there would have security implications.

Quoted 8 lines
Quoted 2 lines

And I'd like to see a changelog, please. One which explains why `symname' cannot have a %s (etc) in it, and never will.

OK, since #youtoo: It doesn't _matter_ if symname is "%pHAHAHA %fooled you <unicode for evil grin emoji>", seq_puts does not interpret it at all. There are _never_ security implications with the above replacement. Sure, seq_printf(m, symname) would be bad, but that's not what is being done.

doh, OK, sorry. RTFP, Andrew.