From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754721AbdJJHJj (ORCPT ); Tue, 10 Oct 2017 03:09:39 -0400 Received: from smtprelay0155.hostedemail.com ([216.40.44.155]:60271 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751872AbdJJHJi (ORCPT ); Tue, 10 Oct 2017 03:09:38 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::,RULES_HIT:41:355:379:541:599:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2693:2736:2828:3138:3139:3140:3141:3142:3353:3622:3865:3866:3867:3868:3870:3871:3872:3874:4321:5007:10004:10400:10848:11232:11658:11914:12294:12663:12740:12760:12895:13069:13311:13357:13439:14659:21080:21627:30003:30012:30054:30070:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:1,LUA_SUMMARY:none X-HE-Tag: fang05_36d22ad218848 X-Filterd-Recvd-Size: 2120 Message-ID: <1507619375.3552.28.camel@perches.com> Subject: Re: [PATCH] lib/vsprintf: add default case to 'i' specifier From: Joe Perches To: "Tobin C. Harding" , kernel-hardening@lists.openwall.com Cc: linux-kernel@vger.kernel.org Date: Tue, 10 Oct 2017 00:09:35 -0700 In-Reply-To: <1507517945-27155-1-git-send-email-me@tobin.cc> References: <1507517945-27155-1-git-send-email-me@tobin.cc> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.22.6-1ubuntu1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2017-10-09 at 13:59 +1100, Tobin C. Harding wrote: > %pi leaks kernel addresses if incorrectly specified. Are there any uses that are incorrectly specified? grep doesn't show any. > Currently the printk specifier %pi (%pI) contains a switch statement > without a default clause. The %pi specifier requires a subsequent > character (4, 6, or S) controlling the output. If the specifier is > incomplete the switch statement will fall through and print the variable > argument address in hex instead of the value of the argument (as an IP > address). > > If uncaught this leaks kernel addresses into dmesg. We can return an > error string to make the bug visible and stop addresses leaking. > > Add a default clause returning an error string, stops leaking addresses > and makes the buggy code [] > diff --git a/lib/vsprintf.c b/lib/vsprintf.c [] > @@ -1775,6 +1775,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr, > default: > return string(buf, end, "(invalid address)", spec); > }} > + default: > + return string(buf, end, "(invalid specifier, form: %pi4)", spec); > } > break; > case 'E': I'm not sure this is a big deal and maybe a better way to handle it is to move the %pK, case 'K': block and add a fallthrough or keep the case 'K': block where it is and add a goto.