public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] vsprintf: ignore arguments to %n
@ 2014-01-28  0:39 Kees Cook
  2014-01-28  0:59 ` Joe Perches
  2014-01-28  1:02 ` Ryan Mallon
  0 siblings, 2 replies; 6+ messages in thread
From: Kees Cook @ 2014-01-28  0:39 UTC (permalink / raw)
  To: linux-kernel
  Cc: Andrew Morton, Ryan Mallon, Jiri Kosina, Joe Perches, Al Viro,
	Olof Johansson, Stepan Moskovchenko, Daniel Borkmann

If arguments are consumed without output when encountering %n, it
could be used to benefit or improve information leak attacks that were
exposed via a limited size buffer. Since %n is not used by the kernel,
there is no reason to make an info leak attack any easier.

Signed-off-by: Kees Cook <keescook@chromium.org>
Cc: stable@vger.kernel.org # 3.13+
---
 lib/vsprintf.c |   10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 185b6d300ebc..9d5c48b705f9 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -1735,14 +1735,10 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
 		case FORMAT_TYPE_NRCHARS: {
 			/*
 			 * Since %n poses a greater security risk than
-			 * utility, ignore %n and skip its argument.
+			 * utility, it should not be implemented. Instead,
+			 * when encountering %n, ignore the arguments.
 			 */
-			void *skip_arg;
-
-			WARN_ONCE(1, "Please remove ignored %%n in '%s'\n",
-					old_fmt);
-
-			skip_arg = va_arg(args, void *);
+			WARN_ONCE(1, "Ignored %%n in '%s'\n", old_fmt);
 			break;
 		}
 
-- 
1.7.9.5


-- 
Kees Cook
Chrome OS Security

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

end of thread, other threads:[~2014-01-28 21:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-28  0:39 [PATCH] vsprintf: ignore arguments to %n Kees Cook
2014-01-28  0:59 ` Joe Perches
2014-01-28  1:02 ` Ryan Mallon
2014-01-28 20:51   ` Kees Cook
2014-01-28 18:54     ` Ryan Mallon
2014-01-28 21:16       ` Kees Cook

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