netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Tobin C. Harding" <me@tobin.cc>
To: kernel-hardening@lists.openwall.com
Cc: "Tobin C. Harding" <me@tobin.cc>,
	Steven Rostedt <rostedt@goodmis.org>,
	Tycho Andersen <tycho@tycho.ws>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Kees Cook <keescook@chromium.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Masahiro Yamada <yamada.masahiro@socionext.com>,
	Alexei Starovoitov <ast@kernel.org>,
	linux-kernel@vger.kernel.org,
	Network Development <netdev@vger.kernel.org>
Subject: [PATCH 1/3] kallsyms: don't leak address when symbol not found
Date: Mon, 18 Dec 2017 10:53:30 +1100	[thread overview]
Message-ID: <1513554812-13014-2-git-send-email-me@tobin.cc> (raw)
In-Reply-To: <1513554812-13014-1-git-send-email-me@tobin.cc>

Currently if kallsyms_lookup() fails to find the symbol then the address
is printed. This potentially leaks sensitive information. Instead of
printing the address we can return an error, giving the calling code the
option to print the address or print some sanitized message.

Return error instead of printing address to argument buffer. Leave
buffer in a sane state.

Signed-off-by: Tobin C. Harding <me@tobin.cc>
---
 kernel/kallsyms.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
index d5fa4116688a..23b9336c1461 100644
--- a/kernel/kallsyms.c
+++ b/kernel/kallsyms.c
@@ -394,8 +394,10 @@ static int __sprint_symbol(char *buffer, unsigned long address,
 
 	address += symbol_offset;
 	name = kallsyms_lookup(address, &size, &offset, &modname, buffer);
-	if (!name)
-		return sprintf(buffer, "0x%lx", address - symbol_offset);
+	if (!name) {
+		buffer[0] = '\0';
+		return -1;
+	}
 
 	if (name != buffer)
 		strcpy(buffer, name);
-- 
2.7.4

  reply	other threads:[~2017-12-17 23:53 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-17 23:53 [PATCH 0/3] kallsyms: don't leak address Tobin C. Harding
2017-12-17 23:53 ` Tobin C. Harding [this message]
2017-12-18  9:55   ` [PATCH 1/3] kallsyms: don't leak address when symbol not found Felix Fietkau
2017-12-18 22:41     ` Tobin C. Harding
2017-12-18 23:43       ` Steven Rostedt
2017-12-19  0:24         ` Tobin C. Harding
2017-12-17 23:53 ` [PATCH 2/3] vsprintf: print <no-symbol> if " Tobin C. Harding
2017-12-18  0:04   ` Joe Perches
2017-12-18  1:04     ` Tobin C. Harding
2017-12-17 23:53 ` [PATCH 3/3] trace: print address " Tobin C. Harding
2017-12-18 16:49   ` Steven Rostedt
2017-12-18 21:16     ` Tobin C. Harding
2017-12-18 23:51       ` Steven Rostedt
2017-12-19  0:22         ` Tobin C. Harding
2017-12-19  3:00         ` Tobin C. Harding
2017-12-19  3:02           ` Tobin C. Harding
2017-12-19  3:37           ` Steven Rostedt
2017-12-19  4:20             ` Tobin C. Harding
2017-12-18 22:35     ` Tobin C. Harding
2017-12-19 23:19   ` kbuild test robot
2017-12-19 23:39   ` kbuild test robot
2017-12-18  5:31 ` [kernel-hardening] [PATCH 0/3] kallsyms: don't leak address Michael Ellerman
2017-12-18  6:00   ` Tobin C. Harding
2017-12-18  9:17     ` Tobin C. Harding

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=1513554812-13014-2-git-send-email-me@tobin.cc \
    --to=me@tobin.cc \
    --cc=akpm@linux-foundation.org \
    --cc=ast@kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=keescook@chromium.org \
    --cc=kernel-hardening@lists.openwall.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=torvalds@linux-foundation.org \
    --cc=tycho@tycho.ws \
    --cc=yamada.masahiro@socionext.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;
as well as URLs for NNTP newsgroup(s).