From patchwork Thu Oct 26 02:53:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobin Harding X-Patchwork-Id: 10027417 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 501EB602B7 for ; Thu, 26 Oct 2017 02:54:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4307B22701 for ; Thu, 26 Oct 2017 02:54:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 37A4125F3E; Thu, 26 Oct 2017 02:54:34 +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 7933222701 for ; Thu, 26 Oct 2017 02:54:33 +0000 (UTC) Received: (qmail 28305 invoked by uid 550); 26 Oct 2017 02:54:25 -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 28250 invoked from network); 26 Oct 2017 02:54:24 -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=TbUH8zvcx3A2rc8LO aZrpkDVZfY/wvHozPSApiXq7bQ=; b=R5vhFROXy/w+0d/ftxySSX7xDCEr43pPJ o9an5nmNJLjX5d7XUi6LqkPcZ9nq3A0oz7qCwjRd4Joz6OLtahVK74BwwBF+0MEw +05HunDfSPDP0ONMrI/Xjn9qfQNtg4rcXTXT2JoA7VIFw9Xaxx0SotBKSdGMQ4fv b3B+VOsHInCAAHL8feL0csExXLERvbUTvj52Vfq689m4GmPVnDc76fkWBkApsKWH uppHujC/GuY8SRzBDFjP926GNpVKzDg5QhSJYQDbtg439hW+EK3tdbxiNL3RMHGE Ql3h488HlIURf1BIQbvAJ24aDCbUHgRR2JIR+R6+gtsiWxvlaCTMg== 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=TbUH8zvcx3A2rc8LOaZrpkDVZfY/wvHozPSApiXq7bQ=; b=IaCOtvxM s/PFG4C9vqT0nT55miTsB6iSpH1jyKBhxZVM0BMP0UQTPHUHl0oRwdu3i94WtZpd ECIzEWx4mtxhzJcPAw2bjcPAXlJDhr878i0/zebCfzx07plzL23BhXnRFN19rEG+ 2P/dNb0YdhWOAY3cSu8SOpdJcw3MVO1xY/1bCxrmGwemNPMhKLVvK7K7oZAJYsQf FgFEvJ6Vc+qz5MWGjd7yfiLhCDpMn/4QOw9AhAh+x9evFgsN5mPBHptDj1z4+Ig6 rIatWdKvrqLIYYZhRK9ZVAzyyziku1lI6FeK+j3sgqoH4VkirMsqlSjxRp3s9DvS DiD3WVptvdxMkw== 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 , linux-kernel@vger.kernel.org Date: Thu, 26 Oct 2017 13:53:55 +1100 Message-Id: <1508986436-31966-2-git-send-email-me@tobin.cc> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1508986436-31966-1-git-send-email-me@tobin.cc> References: <1508986436-31966-1-git-send-email-me@tobin.cc> Subject: [kernel-hardening] [PATCH V8 1/2] printk: remove tabular output for NULL pointer X-Virus-Scanned: ClamAV using ClamSMTP Currently pointer() checks for a NULL pointer argument and then if so attempts to print "(null)" with _some_ standard width. This width cannot correctly be ascertained here because many of the printk specifiers print pointers of varying widths. Remove the attempt to print NULL pointers with a correct width. Signed-off-by: Tobin C. Harding --- lib/vsprintf.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 86c3385b9eb3..16a587aed40e 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -1710,15 +1710,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr, { const int default_width = 2 * sizeof(void *); - if (!ptr && *fmt != 'K') { - /* - * Print (null) with the same width as a pointer so it makes - * tabular output look nice. - */ - if (spec.field_width == -1) - spec.field_width = default_width; + if (!ptr && *fmt != 'K') return string(buf, end, "(null)", spec); - } switch (*fmt) { case 'F':