public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Rosenberg <drosenberg@vsecurity.com>
To: Stevie Trujillo <stevie.trujillo@gmail.com>
Cc: linux-kernel@vger.kernel.org, Andrew Morton <akpm@linux-foundation.org>
Subject: Re: kptr_restrict: pK-error in SysRq show-all-timers(Q)
Date: Fri, 13 Jul 2012 19:22:31 -0400	[thread overview]
Message-ID: <5000ADB7.7060307@vsecurity.com> (raw)
In-Reply-To: <CAJiZuY2c1TVVGDxqSDSVC04t5KHK7k=ysJ99Bw6QKvEYdeWO3A@mail.gmail.com>

On 06/26/2012 05:20 PM, Stevie Trujillo wrote:
> Hello,
>
> if I press 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
>
> --
> Stevie Trujillo

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.

Signed-off-by: Dan Rosenberg <dan.j.rosenberg@gmail.com>
Cc: stable@vger.kernel.org
---
 lib/vsprintf.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index c3f36d41..598a73e 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -1030,7 +1030,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 = default_width;
 			return string(buf, end, "pK-error", spec);


      reply	other threads:[~2012-07-13 23:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-26 21:20 kptr_restrict: pK-error in SysRq show-all-timers(Q) Stevie Trujillo
2012-07-13 23:22 ` Dan Rosenberg [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5000ADB7.7060307@vsecurity.com \
    --to=drosenberg@vsecurity.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stevie.trujillo@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox