From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932370AbeCITFU (ORCPT ); Fri, 9 Mar 2018 14:05:20 -0500 Received: from mail-it0-f49.google.com ([209.85.214.49]:53575 "EHLO mail-it0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932069AbeCITFS (ORCPT ); Fri, 9 Mar 2018 14:05:18 -0500 X-Google-Smtp-Source: AG47ELua/jRm9xG809kkoqIICmTkPeZ87ZqmiLsHFAJRzUdE//LTKPzCeUX9joTJ+PBcOEONSvLXunAjcsgVKf6muck= MIME-Version: 1.0 In-Reply-To: <20180309150153.3sxbbpd6jdn2d5yy@pathway.suse.cz> References: <20180302125118.bjd3tbuu72vgfczo@pathway.suse.cz> <20180302125359.szbin2kznxvoq7sc@pathway.suse.cz> <20180306092513.ibodfsnv4xrxdlub@pathway.suse.cz> <1520330185.10722.401.camel@linux.intel.com> <20180307155244.b45c3fb5vcxb4q2l@pathway.suse.cz> <20180308141824.bfk2pr6wmjh4ytdi@pathway.suse.cz> <20180309150153.3sxbbpd6jdn2d5yy@pathway.suse.cz> From: Linus Torvalds Date: Fri, 9 Mar 2018 11:05:17 -0800 X-Google-Sender-Auth: hspr7qBn9GJHEtRDBiw-Hhmqats Message-ID: Subject: Re: [PATCH] vsprintf: Make "null" pointer dereference more robust To: Petr Mladek Cc: Andy Shevchenko , Rasmus Villemoes , "Tobin C . Harding" , Joe Perches , Linux Kernel Mailing List , Andrew Morton , Michal Hocko Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 9, 2018 at 7:01 AM, Petr Mladek wrote: > Also it makes the handling unified. We print: > > + (null) when pure NULL pointer is dereferenced > + (efault) when an invalid address is dereferenced > + pointer address otherwise This is still fundamentally completely wrong. It never prints "pointer address", and if it were to do that, it would be wrong. It should never ever trigger for an address operation, only for the "we will get _data_ from the ponter". The strchr thing is also completely broken, and in a very subtle way. "strchr(string, 0)" is special, and the Open Group states "The terminating null byte is considered to be part of the string" so a NUL character will *always* return success, which is actually completely wrong for this case, because now it does that whole crazy thing for %p that it shouldn't do. Not that I actually verified that our strchr() follows the actual rules anyway - I personally consider "strchr(string, 0)" to not really be "special", but be a bug. Either way, the comment is wrong, but the code is also wrong. Linus