public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sysctl: terminate strings also on \r
@ 2014-10-21 20:21 Kees Cook
  2014-10-22 10:03 ` Aaron Tomlin
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Kees Cook @ 2014-10-21 20:21 UTC (permalink / raw)
  To: linux-kernel
  Cc: Andrew Morton, Ingo Molnar, Rik van Riel, David Rientjes,
	Aaron Tomlin, Dario Faggioli, Andi Kleen, Peter Zijlstra,
	Jens Axboe, Paul E. McKenney

From: Paul Wise <pabs3@bonedaddy.net>

This partially mitigates a common strategy used by attackers for hiding
the full contents of strings in procfs from naive sysadmins who use cat,
more or sysctl to inspect the contents of strings in procfs.

References: http://www.jakoblell.com/blog/2014/05/07/hacking-contest-hiding-stuff-from-the-terminal/
Signed-off-by: Paul Wise <pabs3@bonedaddy.net>
Signed-off-by: Kees Cook <keescook@chromium.org>
---
 kernel/sysctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 4aada6d9fe74..c34c9414caac 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -1739,7 +1739,7 @@ static int _proc_do_string(char *data, int maxlen, int write,
 		while ((p - buffer) < *lenp && len < maxlen - 1) {
 			if (get_user(c, p++))
 				return -EFAULT;
-			if (c == 0 || c == '\n')
+			if (c == 0 || c == '\n' || c == '\r')
 				break;
 			data[len++] = c;
 		}
-- 
1.9.1


-- 
Kees Cook
Chrome OS Security

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2014-10-27 12:01 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-21 20:21 [PATCH] sysctl: terminate strings also on \r Kees Cook
2014-10-22 10:03 ` Aaron Tomlin
2014-10-22 13:39 ` Paul E. McKenney
2014-10-22 22:49 ` David Rientjes
2014-10-22 23:26 ` Andrew Morton
2014-10-22 23:43   ` Kees Cook
2014-10-23  2:00     ` Andrew Morton
2014-10-23 16:39       ` Kees Cook
2014-10-23 18:23         ` Andrew Morton
2014-10-23 18:50           ` Kees Cook
2014-10-27  9:56     ` Pavel Machek
2014-10-27 10:11       ` Geert Uytterhoeven
2014-10-27 12:01         ` Pavel Machek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox