Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753054AbbELHXK (ORCPT ); Tue, 12 May 2015 03:23:10 -0400 Received: from a.ns.miles-group.at ([95.130.255.143]:65275 "EHLO radon.swed.at" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752643AbbELHXH (ORCPT ); Tue, 12 May 2015 03:23:07 -0400 Message-ID: <5551AA57.5060908@nod.at> Date: Tue, 12 May 2015 09:23:03 +0200 From: Richard Weinberger User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Andrew Morton CC: linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] Fix printk() on ERR_PTR() References: <1431286936-4333-1-git-send-email-richard@nod.at> <1431286936-4333-2-git-send-email-richard@nod.at> <20150511162039.05a035367d1895738ca85155@linux-foundation.org> In-Reply-To: <20150511162039.05a035367d1895738ca85155@linux-foundation.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1373 Lines: 44 Am 12.05.2015 um 01:20 schrieb Andrew Morton: > On Sun, 10 May 2015 21:42:15 +0200 Richard Weinberger wrote: > >> vbin_printf() checks whether the provided pointer is larger >> than -PAGE_SIZE such that it does not explode on ERR_PTR() pointers. >> printk() does not. >> >> Let's add this check also to the printk() code such that >> trace_printk() and printk() are consistent again. >> >> .. >> >> --- a/lib/vsprintf.c >> +++ b/lib/vsprintf.c >> @@ -511,7 +511,8 @@ char *string(char *buf, char *end, const char *s, struct printf_spec spec) >> { >> int len, i; >> >> - if ((unsigned long)s < PAGE_SIZE) >> + if ((unsigned long)s > (unsigned long)-PAGE_SIZE || > > hm, PAGE_SIZE has type ulong, so is the cast needed? But we add a negative sign to it. AFAIK the cast is needed to prevent gcc from promoting this to a signed long. >> + (unsigned long)s < PAGE_SIZE) > > This would be a place for > > if (!within(PAGE_SIZE, (unsigned long)s, -PAGE_SIZE)) > s = "(null)"; > > I'm counting at least five implementations of within(), not all the same. Challenge accepted. :D Thanks, //richard -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/