From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sergey Senozhatsky Subject: Re: [PATCH] vsprintf: Do not break early boot with probing addresses Date: Tue, 14 May 2019 11:07:30 +0900 Message-ID: <20190514020730.GA651@jagdpanzerIV> References: <20190510081635.GA4533@jagdpanzerIV> <20190510084213.22149-1-pmladek@suse.com> <20190510122401.21a598f6@gandalf.local.home> <096d6c9c17b3484484d9d9d3f3aa3a7c@AcuMS.aculab.com> <20190513091320.GK9224@smile.fi.intel.com> <20190513124220.wty2qbnz4wo52h3x@pathway.suse.cz> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <20190513124220.wty2qbnz4wo52h3x@pathway.suse.cz> Sender: linux-kernel-owner@vger.kernel.org To: Petr Mladek Cc: Andy Shevchenko , David Laight , 'christophe leroy' , Steven Rostedt , Linus Torvalds , Rasmus Villemoes , "Tobin C . Harding" , Michal Hocko , Sergey Senozhatsky , Sergey Senozhatsky , "linux-kernel@vger.kernel.org" , Michael Ellerman , "linuxppc-dev@lists.ozlabs.org" , Russell Currey , Stephen Rothwell , Heiko Carstens , "linux-arch@vger.kernel.org" List-Id: linux-arch.vger.kernel.org On (05/13/19 14:42), Petr Mladek wrote: > > The "(null)" is good enough by itself and already an established > > practice.. > > (efault) made more sense with the probe_kernel_read() that > checked wide range of addresses. Well, I still think that > it makes sense to distinguish a pure NULL. And it still > used also for IS_ERR_VALUE(). Wouldn't anything within first PAGE_SIZE bytes be reported as a NULL deref? char *p = (char *)(PAGE_SIZE - 2); *p = 'a'; gives kernel: BUG: kernel NULL pointer dereference, address = 0000000000000ffe kernel: #PF: supervisor-privileged write access from kernel code kernel: #PF: error_code(0x0002) - not-present page And I like Steven's "(fault)" idea. How about this: if ptr < PAGE_SIZE -> "(null)" if IS_ERR_VALUE(ptr) -> "(fault)" -ss From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-f195.google.com ([209.85.214.195]:42941 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726327AbfENCHf (ORCPT ); Mon, 13 May 2019 22:07:35 -0400 Date: Tue, 14 May 2019 11:07:30 +0900 From: Sergey Senozhatsky Subject: Re: [PATCH] vsprintf: Do not break early boot with probing addresses Message-ID: <20190514020730.GA651@jagdpanzerIV> References: <20190510081635.GA4533@jagdpanzerIV> <20190510084213.22149-1-pmladek@suse.com> <20190510122401.21a598f6@gandalf.local.home> <096d6c9c17b3484484d9d9d3f3aa3a7c@AcuMS.aculab.com> <20190513091320.GK9224@smile.fi.intel.com> <20190513124220.wty2qbnz4wo52h3x@pathway.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190513124220.wty2qbnz4wo52h3x@pathway.suse.cz> Sender: linux-arch-owner@vger.kernel.org List-ID: To: Petr Mladek Cc: Andy Shevchenko , David Laight , 'christophe leroy' , Steven Rostedt , Linus Torvalds , Rasmus Villemoes , "Tobin C . Harding" , Michal Hocko , Sergey Senozhatsky , Sergey Senozhatsky , "linux-kernel@vger.kernel.org" , Michael Ellerman , "linuxppc-dev@lists.ozlabs.org" , Russell Currey , Stephen Rothwell , Heiko Carstens , "linux-arch@vger.kernel.org" , "linux-s390@vger.kernel.org" , Martin Schwidefsky Message-ID: <20190514020730.g4cTS2GpqhzzEgKbRibvfxOK38Jika-NdjcqZLJn1As@z> On (05/13/19 14:42), Petr Mladek wrote: > > The "(null)" is good enough by itself and already an established > > practice.. > > (efault) made more sense with the probe_kernel_read() that > checked wide range of addresses. Well, I still think that > it makes sense to distinguish a pure NULL. And it still > used also for IS_ERR_VALUE(). Wouldn't anything within first PAGE_SIZE bytes be reported as a NULL deref? char *p = (char *)(PAGE_SIZE - 2); *p = 'a'; gives kernel: BUG: kernel NULL pointer dereference, address = 0000000000000ffe kernel: #PF: supervisor-privileged write access from kernel code kernel: #PF: error_code(0x0002) - not-present page And I like Steven's "(fault)" idea. How about this: if ptr < PAGE_SIZE -> "(null)" if IS_ERR_VALUE(ptr) -> "(fault)" -ss