From patchwork Mon Nov 27 22:30:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobin Harding X-Patchwork-Id: 10078289 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 C096F602BD for ; Mon, 27 Nov 2017 22:30:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B3D2528FCF for ; Mon, 27 Nov 2017 22:30:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A874A290B0; Mon, 27 Nov 2017 22:30:53 +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 E5F66290AC for ; Mon, 27 Nov 2017 22:30:52 +0000 (UTC) Received: (qmail 11575 invoked by uid 550); 27 Nov 2017 22:30:49 -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 11423 invoked from network); 27 Nov 2017 22:30:48 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tobin.cc; h=cc :date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=1Eu9/+Hv6nOfyH6LK 76zHnT/6pf9D0txRdknphWZpC4=; b=u6VtU5UHrMJiBR0+7S3ktP2bmn6agV6jE 3IjZ2Fp88GwXuSgcLlIHxdCvd1UpBAKlcEA8uxOaaJ3Gaa6S84k/DX5Jkx+sZ3g9 MZtSZp2Wt95RbOJnZpl5ObxS9qqCoXBkeZ7Kptn6w1Kymt6RUURWvBqAOWDj93RZ hBrmI8QDQdc9e91QU4DAjfI073FBW/dsNMed8+AGqZB7/ewqeFwcNxu5u9OaOOsr RRLdgnP3azMMH1fKB9sbIddIXoA8Q8OW4111L7gb/JNviGGnC95t6by9qjrAyTe4 OreV75mw9p7/tjIddMj9WcKd99y/LMLRgJk57uNJ5rFto5QfYeUEw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=1Eu9/+Hv6nOfyH6LK76zHnT/6pf9D0txRdknphWZpC4=; b=Uo6inUCL 9p/2EhwxIOKMVE80pT1oS2AEBwP66P8b0sZCVWTl34+wD0/quutGaVFQ14/1C6YT kVS4drRxKG0EBo4lO6gbfKRmTbDiVtAZtPUJ9mPKtMlQn4ckT8MmtxTJ4L0kLOzH r6N8eJtliLZRzShwJb/XJvWVluWfuLRxJLW5etQ2fR8wacua+hZn1ne2f63HJPbV RrmTnRmAVSaTiR+5FApVN63B9YTOuL6U5jNzLRt2wKVf5DlHtvAySsszoGWcXTu+ iY325ftqMxXoHR1KH47olx/rqCCyLaD+/26IA7YWQZhPHZAWP+7AhtmfVAhlTvyT 5kMgsssj4wld1A== X-ME-Sender: From: "Tobin C. Harding" To: kernel-hardening@lists.openwall.com Cc: "Tobin C. Harding" , linux-kernel@vger.kernel.org, Network Development , Steven Rostedt , Tycho Andersen , Daniel Borkmann , Masahiro Yamada , "David S. Miller" , Alexei Starovoitov Date: Tue, 28 Nov 2017 09:30:17 +1100 Message-Id: <1511821819-5496-2-git-send-email-me@tobin.cc> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1511821819-5496-1-git-send-email-me@tobin.cc> References: <1511821819-5496-1-git-send-email-me@tobin.cc> Subject: [kernel-hardening] [RFC 1/3] kallsyms: don't leak address when symbol not found X-Virus-Scanned: ClamAV using ClamSMTP 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 --- kernel/kallsyms.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c index 531ffa984bc2..4bfa4ee3ce93 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);