All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] vsprintf: BUG on %n
@ 2014-01-27 23:03 Kees Cook
  2014-01-27 23:11 ` Ryan Mallon
  2014-01-27 23:12 ` Joe Perches
  0 siblings, 2 replies; 7+ messages in thread
From: Kees Cook @ 2014-01-27 23:03 UTC (permalink / raw)
  To: linux-kernel
  Cc: Andrew Morton, Jiri Kosina, Joe Perches, Al Viro, Olof Johansson,
	Stepan Moskovchenko, Daniel Borkmann, Ryan Mallon

Now that there has been a full release of the kernel, and all users
of %n have been dropped, switch to %n use triggering a BUG. Ignoring
arguments could be used to assist in information leaks if an arbitrary
format string was under the control of an attacker.

Signed-off-by: Kees Cook <keescook@chromium.org>
---
 lib/vsprintf.c |   13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 185b6d300ebc..a27fd7f61325 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -1735,15 +1735,12 @@ 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,
+			 * BUG when encountering %n, since there are no
+			 * legitimate users and skipping arguments could
+			 * assist information leak attacks.
 			 */
-			void *skip_arg;
-
-			WARN_ONCE(1, "Please remove ignored %%n in '%s'\n",
-					old_fmt);
-
-			skip_arg = va_arg(args, void *);
-			break;
+			BUG();
 		}
 
 		default:
-- 
1.7.9.5


-- 
Kees Cook
Chrome OS Security

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

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

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-27 23:03 [PATCH] vsprintf: BUG on %n Kees Cook
2014-01-27 23:11 ` Ryan Mallon
2014-01-27 23:56   ` Kees Cook
2014-01-28  0:11     ` Ryan Mallon
2014-01-28  0:19       ` Kees Cook
2014-01-27 23:12 ` Joe Perches
2014-01-27 23:17   ` Andrew Morton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.