From: Linus Torvalds Date: Wed, 29 Nov 2017 19:28:09 +0000 (-0800) Subject: vsprintf: don't use 'restricted_pointer()' when not restricting X-Git-Tag: v4.15-rc2~25 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=ef0010a30935de4e0211cbc7bdffc30446cdee9b;p=users%2Fwilly%2Fxarray.git vsprintf: don't use 'restricted_pointer()' when not restricting Instead, just fall back on the new '%p' behavior which hashes the pointer. Otherwise, '%pK' - that was intended to mark a pointer as restricted - just ends up leaking pointers that a normal '%p' wouldn't leak. Which just make the whole thing pointless. I suspect we should actually get rid of '%pK' entirely, and make it just work as '%p' regardless, but this is the minimal obvious fix. People who actually use 'kptr_restrict' should weigh in on which behavior they want. Cc: Tobin Harding Cc: Kees Cook Signed-off-by: Linus Torvalds --- diff --git a/lib/vsprintf.c b/lib/vsprintf.c index d960aead0336..01c3957b2de6 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -1931,6 +1931,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr, return buf; } case 'K': + if (!kptr_restrict) + break; return restricted_pointer(buf, end, ptr, spec); case 'N': return netdev_bits(buf, end, ptr, fmt);