Received: by 10.223.185.116 with SMTP id b49csp3613567wrg; Tue, 6 Mar 2018 01:57:38 -0800 (PST) X-Google-Smtp-Source: AG47ELtDj3nJYNodlp8YCJIQBU43P1pMzxWBnVuJTgILWWCHtg7jF413MHzgKScK29MwDE6bK2jR X-Received: by 10.101.73.77 with SMTP id q13mr14489861pgs.336.1520330257921; Tue, 06 Mar 2018 01:57:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520330257; cv=none; d=google.com; s=arc-20160816; b=LfOqKErVwQkhDwkxAT4ZEiCAA+E7DsbmyzfUT92LPcJT0LyKCqkG4x933MLiOgp8cZ RxLzAitd6uUFBS9ovF1k0QOhnDXQ8wonFelyFKRw7pYCmXyfwGhVKfjHP05SZkyTg9g/ hn0tBcALwy1YycKY+YTIenZ5tUF8tzqMS0WNuKXyqZFKvIFJT/S3tfcNa3dNYRwgjmqw QvF64ebvXAsL1C+zuJF7uuHk0BvRrQXOBvikj823/t2cfRmwlpl3b1MHhBAxf7HbeYu3 o3w89cYL/T/GXbAkxVadPlfm6b+1cuhm7r2NXdfSaz4bJTh1uqL848Vx7Vn3UtbZylqK uA5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:date:cc:to:from:subject :message-id:arc-authentication-results; bh=39JiKk1oamys0waPTN29j9bvG/PFoIT/hh+Zy8we6zA=; b=mP4EzA7cnCgBDXq36UMfehyG7bch4VxjFRD7sahL3EBRZScpAoTaDVSSP80yUi8YFe XsZVqm0IKOXSzM/H4udv0bQ+YsujUF7Js923kPfXlsBs7YvwB5yiK/sxT/2lc3l1bQwy GaF9suWhJlXNv+425mIo4ZjYo/QkTnJtW74BtdVObe58vQimNfbih9KYFtPcOFRjrFHj m/vjdEHTfP7ZoutLZXVfcUoBCPLEXi0tImhUYMN9ddX58H7WmmXiKaGAjF2OWjh6nsDT 03cTxAWqu6YHP3q6z4Agr4E3Jx+XeFWl0cAWmyRDHcdRmwkKAAKCyaQgsFEW7RGSBZ/A Mj6g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m68si5818464pfm.171.2018.03.06.01.57.23; Tue, 06 Mar 2018 01:57:37 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753154AbeCFJ4a (ORCPT + 99 others); Tue, 6 Mar 2018 04:56:30 -0500 Received: from mga17.intel.com ([192.55.52.151]:30654 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750838AbeCFJ42 (ORCPT ); Tue, 6 Mar 2018 04:56:28 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Mar 2018 01:56:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,431,1515484800"; d="scan'208";a="25583983" Received: from smile.fi.intel.com (HELO smile) ([10.237.72.86]) by fmsmga002.fm.intel.com with ESMTP; 06 Mar 2018 01:56:26 -0800 Message-ID: <1520330185.10722.401.camel@linux.intel.com> Subject: Re: [PATCH] vsprintf: Make "null" pointer dereference more robust From: Andy Shevchenko To: Petr Mladek , Rasmus Villemoes Cc: "Tobin C . Harding" , Joe Perches , linux-kernel@vger.kernel.org, Andrew Morton , Michal Hocko Date: Tue, 06 Mar 2018 11:56:25 +0200 In-Reply-To: <20180306092513.ibodfsnv4xrxdlub@pathway.suse.cz> References: <20180216210711.79901-1-andriy.shevchenko@linux.intel.com> <20180216210711.79901-8-andriy.shevchenko@linux.intel.com> <20180227155047.o74ohmoyj56up6pa@pathway.suse.cz> <1519752950.10722.231.camel@linux.intel.com> <20180228100437.o4juwxbzomkqjvjx@pathway.suse.cz> <1519814544.10722.266.camel@linux.intel.com> <20180302125118.bjd3tbuu72vgfczo@pathway.suse.cz> <20180302125359.szbin2kznxvoq7sc@pathway.suse.cz> <20180306092513.ibodfsnv4xrxdlub@pathway.suse.cz> Organization: Intel Finland Oy Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.26.5-1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2018-03-06 at 10:25 +0100, Petr Mladek wrote: > On Mon 2018-03-05 16:16:37, Rasmus Villemoes wrote: > > On 2 March 2018 at 13:53, Petr Mladek wrote: > > > - if (!ptr && *fmt != 'K' && *fmt != 'x') { > > > + if ((unsigned long)ptr < PAGE_SIZE && *fmt != 'K' && *fmt > > > != 'x') { > > > > ISTM that accidentally passing an ERR_PTR would be just as likely as > > passing a NULL pointer (or some small offset from one), so if we do > > this, shouldn't the test also cover IS_ERR values? > > It would make perfect sense to catch IS_ERR_PTR(). Derefenrecing > such pointer cause crash. But it might be pretty confusing to print > "(null)" in this case. > > I would handle this in separate patch and print "(err)" or so. > Any volunteer to prepare the patch? As I pointed out, we have already such check for %s in binary printf(). And it goes for "(null)". I'm not sure if changing that might break something. -- Andy Shevchenko Intel Finland Oy