All of lore.kernel.org
 help / color / mirror / Atom feed
* + vsprintf-kptr_restrict-is-okay-in-irq-when-2.patch added to -mm tree
@ 2016-02-08 23:45 akpm
  0 siblings, 0 replies; only message in thread
From: akpm @ 2016-02-08 23:45 UTC (permalink / raw)
  To: Jason, keescook, linux, mm-commits


The patch titled
     Subject: vsprintf: kptr_restrict is okay in IRQ when 2
has been added to the -mm tree.  Its filename is
     vsprintf-kptr_restrict-is-okay-in-irq-when-2.patch

This patch should soon appear at
    http://ozlabs.org/~akpm/mmots/broken-out/vsprintf-kptr_restrict-is-okay-in-irq-when-2.patch
and later at
    http://ozlabs.org/~akpm/mmotm/broken-out/vsprintf-kptr_restrict-is-okay-in-irq-when-2.patch

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/SubmitChecklist when testing your code ***

The -mm tree is included into linux-next and is updated
there every 3-4 working days

------------------------------------------------------
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
Subject: vsprintf: kptr_restrict is okay in IRQ when 2

The kptr_restrict flag, when set to 1, only prints the kernel address when
the user has CAP_SYSLOG.  When it is set to 2, the kernel address is
always printed as zero.  When set to 1, this needs to check whether or not
we're in IRQ.  However, when set to 2, this check is unneccessary, and
produces confusing results in dmesg.  Thus, only make sure we're not in
IRQ when mode 1 is used, but not mode 2.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Kees Cook <keescook@chromium.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 lib/vsprintf.c |   26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff -puN lib/vsprintf.c~vsprintf-kptr_restrict-is-okay-in-irq-when-2 lib/vsprintf.c
--- a/lib/vsprintf.c~vsprintf-kptr_restrict-is-okay-in-irq-when-2
+++ a/lib/vsprintf.c
@@ -1663,22 +1663,23 @@ char *pointer(const char *fmt, char *buf
 			return buf;
 		}
 	case 'K':
-		/*
-		 * %pK cannot be used in IRQ context because its test
-		 * for CAP_SYSLOG would be meaningless.
-		 */
-		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);
-		}
-
 		switch (kptr_restrict) {
 		case 0:
 			/* Always print %pK values */
 			break;
 		case 1: {
+			const struct cred *cred;
+
+			/*
+			 * kptr_restrict==1 cannot be used in IRQ context because
+			 * its test for CAP_SYSLOG would be meaningless.
+			 */
+			if (in_irq() || in_serving_softirq() || in_nmi()) {
+				if (spec.field_width == -1)
+					spec.field_width = default_width;
+				return string(buf, end, "pK-error", spec);
+			}
+
 			/*
 			 * Only print the real pointer value if the current
 			 * process has CAP_SYSLOG and is running with the
@@ -1688,8 +1689,7 @@ char *pointer(const char *fmt, char *buf
 			 * leak pointer values if a binary opens a file using
 			 * %pK and then elevates privileges before reading it.
 			 */
-			const struct cred *cred = current_cred();

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-02-08 23:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-08 23:45 + vsprintf-kptr_restrict-is-okay-in-irq-when-2.patch added to -mm tree akpm

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.