Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e63732db authored by Patrick Daly's avatar Patrick Daly Committed by Vinayak Menon
Browse files

lib/vsprintf: Less restrictive hashed pointer printing



Commit ad67b74d ("printk: hash addresses printed with %p") and
Commit ef0010a3 ("vsprintf: don't use 'restricted_pointer()'
when not restricting") effectively removed the ability to display
kernel addresses in the kernel log. While this may be a useful feature
in production builds, it is undesirable when trying to debug.

%px is not a possible alternative, because it is unable to differentiate
between a debug and production build.

Change-Id: I139fae7b8488936d214efdd2b5b807fa1c005467
Signed-off-by: default avatarPatrick Daly <pdaly@codeaurora.org>
[vinmenon@codeaurora.org: fixed the Kconfig conflicts]
Signed-off-by: default avatarVinayak Menon <vinmenon@codeaurora.org>
parent 0e58b739
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -144,6 +144,14 @@ config DEBUG_MODULE_LOAD_INFO

	  If unsure, say N.

config DEBUG_CONSOLE_UNHASHED_POINTERS
	bool "Display unhashed kernel pointers"
	depends on DEBUG_KERNEL
	help
	  Pointers %p and %pK are normally hashed prior to being displayed to
	  prevent leaking kernel addresses. On debug builds, always print
	  actual pointer values, ignoring the kptr_restrict setting.
	  Not to be enabled on production builds.

endmenu # "printk and dmesg options"

+5 −1
Original line number Diff line number Diff line
@@ -1928,7 +1928,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
			return buf;
		}
	case 'K':
		if (!kptr_restrict)
		if (!kptr_restrict ||
		    IS_ENABLED(CONFIG_DEBUG_CONSOLE_UNHASHED_POINTERS))
			break;
		return restricted_pointer(buf, end, ptr, spec);
	case 'N':
@@ -1959,6 +1960,9 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
		return pointer_string(buf, end, ptr, spec);
	}

	if (IS_ENABLED(CONFIG_DEBUG_CONSOLE_UNHASHED_POINTERS))
		return pointer_string(buf, end, ptr, spec);

	/* default is to _not_ leak addresses, hash before printing */
	return ptr_to_id(buf, end, ptr, spec);
}