From patchwork Thu Nov 9 01:50:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobin Harding X-Patchwork-Id: 10049969 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1363A601EB for ; Thu, 9 Nov 2017 01:51:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 04F2D2A7E7 for ; Thu, 9 Nov 2017 01:51:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EDAE42A7EE; Thu, 9 Nov 2017 01:51:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id 391FF2A7E7 for ; Thu, 9 Nov 2017 01:51:04 +0000 (UTC) Received: (qmail 29789 invoked by uid 550); 9 Nov 2017 01:51:02 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 29765 invoked from network); 9 Nov 2017 01:51:01 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tobin.cc; h=cc :date:from:message-id:subject:to:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=BRYjLTRRoC17mZ2It00WMddUpYR0byM4pqMwRkNTW tE=; b=BlGPrzBZhm9U8hk25HnmNUGlrIxJXZKGdZ8rymkVPW1Mx70UmAxSCxKiG IGRsFwSuTwdf2FMCorrH2PAO9mpjEA0gN6Dyb+xhrMOOzOc3c4vEwskrPKsM5dVU 4KAGV/ZcLpVNFYrWZudutuWJfesuB4SQviLUC8fV6tDK0OSmPQZlVDSvxFbsLTdm ehblGYpBDxiCPc0gbh64e+6ewxIimrigZXHAEOqzxIA4tdjJ3kjILeXy9+XHX8vN +IdrKyVcybursNdXx+kQE6HZuUnM5nN6O5B6XV2eRnENit1eFcgWtqMhixsqitAb JroN1FqjTGCMiAzRJMCM+NFG0nNnw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:message-id:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=BRYjLTRRoC17mZ2It 00WMddUpYR0byM4pqMwRkNTWtE=; b=MIag1fjtnJuZ7K9rYU1rqGpdAdhJYo+s8 SxYzv9hIROIE4xG5T8a6MIb2HTWKoFPu9DOlA6A7TKXMvoWvh/XHLhYEuu7CSfIV d62hZQeXs/AzdMO1ZY/PAVAdvZF6B7Bll4oDytQR4bNhJGB4+6t9lgk8RCwkwEuW 1x1XZDJCXh/AukX9Wz453RxjL9W9XqE2DhWsgVA9lOdSWcIjLS3IQMK1K8iKQelf dx+68ro+v4RTt7dYW2zWyebRABRj0QZ/Z9tVbhouMQ6sN3dcQgT/NHYP8UmIRU5e Dbl6Y7CocLZOokIyPC+c6eWjB73067VPUfU6PXqOveaubViIxf4+Q== X-ME-Sender: From: "Tobin C. Harding" To: kernel-hardening@lists.openwall.com Cc: "Tobin C. Harding" , "Jason A. Donenfeld" , Theodore Ts'o , Linus Torvalds , Kees Cook , Paolo Bonzini , Tycho Andersen , "Roberts, William C" , Tejun Heo , Jordan Glover , Greg KH , Petr Mladek , Joe Perches , Ian Campbell , Sergey Senozhatsky , Catalin Marinas , Will Deacon , Steven Rostedt , Chris Fries , Dave Weinstein , Daniel Micay , Djalal Harouni , "Paul E. McKenney" , Andy Lutomirski , Peter Zijlstra , David Miller , Network Development , linux-kernel@vger.kernel.org Date: Thu, 9 Nov 2017 12:50:29 +1100 Message-Id: <1510192229-20038-1-git-send-email-me@tobin.cc> X-Mailer: git-send-email 2.7.4 Subject: [kernel-hardening] [PATCH] kallsyms: don't leak address when printing symbol X-Virus-Scanned: ClamAV using ClamSMTP Currently if a pointer is printed using %p[ssB] and the symbol is not found (kallsyms_lookup() fails) then we print the actual address. This leaks kernel addresses. We should instead print something _safe_. Print "" instead of kernel address. Signed-off-by: Tobin C. Harding --- kernel/kallsyms.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c index 127e7cfafa55..182e7592be9c 100644 --- a/kernel/kallsyms.c +++ b/kernel/kallsyms.c @@ -390,7 +390,7 @@ 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); + return sprintf(buffer, ""); if (name != buffer) strcpy(buffer, name);