lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 06 Feb 2018 09:21:58 +0000
From:   David Howells <dhowells@...hat.com>
To:     torvalds@...ux-foundation.org
Cc:     dhowells@...hat.com, peterz@...radead.org,
        linux-kernel@...r.kernel.org, me@...in.cc
Subject: [PATCH] printk: Print error pointers as negative integers for %p

The new hashing feature of unadorned printk("%p") makes it hard to spot if
the pointer actually carries an error value.  Make %p print any pointer
that matches IS_ERR() as a negative integer.

Should I set SMALL and the field_width as well, I wonder?

Signed-off-by: David Howells <dhowells@...hat.com>
---

 lib/vsprintf.c |    6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 77ee6ced11b1..d87adca33b12 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -1705,6 +1705,12 @@ static char *ptr_to_id(char *buf, char *end, void *ptr, struct printf_spec spec)
 		return string(buf, end, "(ptrval)", spec);
 	}
 
+	if (IS_ERR(ptr)) {
+		spec.type = FORMAT_TYPE_INT;
+		spec.flags |= SIGN;
+		return number(buf, end, PTR_ERR(ptr), spec);
+	}
+
 #ifdef CONFIG_64BIT
 	hashval = (unsigned long)siphash_1u64((u64)ptr, &ptr_key);
 	/*

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ