From: Dan Rosenberg Date: Mon, 30 Jul 2012 21:40:26 +0000 (-0700) Subject: lib/vsprintf.c: kptr_restrict: fix pK-error in SysRq show-all-timers(Q) X-Git-Tag: v3.4.81~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=26fead641f8e2a5052aa3cfc88caf876f0e84941;p=platform%2Fkernel%2Flinux-stable.git lib/vsprintf.c: kptr_restrict: fix pK-error in SysRq show-all-timers(Q) commit 3715c5309f6d175c3053672b73fd4f73be16fd07 upstream. When using ALT+SysRq+Q all the pointers are replaced with "pK-error" like this: [23153.208033] .base: pK-error with echo h > /proc/sysrq-trigger it works: [23107.776363] .base: ffff88023e60d540 The intent behind this behavior was to return "pK-error" in cases where the %pK format specifier was used in interrupt context, because the CAP_SYSLOG check wouldn't be meaningful. Clearly this should only apply when kptr_restrict is actually enabled though. Reported-by: Stevie Trujillo Signed-off-by: Dan Rosenberg Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Ben Hutchings Cc: Li Zefan Signed-off-by: Greg Kroah-Hartman --- diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 73e2c45..cd0aab7 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -926,7 +926,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr, * %pK cannot be used in IRQ context because its test * for CAP_SYSLOG would be meaningless. */ - if (in_irq() || in_serving_softirq() || in_nmi()) { + if (kptr_restrict && (in_irq() || in_serving_softirq() || + in_nmi())) { if (spec.field_width == -1) spec.field_width = 2 * sizeof(void *); return string(buf, end, "pK-error", spec);