Received: by 10.223.185.116 with SMTP id b49csp2704842wrg; Mon, 5 Mar 2018 07:26:30 -0800 (PST) X-Google-Smtp-Source: AG47ELs2GdRpjx6kEkQSuS1YRCjfwOaw1HjiR+aL+lVNVWcrJN86oK4oArPSzfSxRoof1OQnpW7H X-Received: by 10.167.128.80 with SMTP id y16mr15554332pfm.91.1520263590335; Mon, 05 Mar 2018 07:26:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520263590; cv=none; d=google.com; s=arc-20160816; b=ShdVnFXa0SWFdNhHJMxXNsugMkrqEEo+AP5RAN6z56477oV35BjYVk5QgwNGKAG3IG 7lp/EDAo/YJ+RbOnn77ukCNbrybWdtyP9yv9TeJtvjaYMju2P1KeLIGaFMpFOAzUHbTq hihP+7n7DG0AfE6dTns6hYOStFhnKJN/k3rWhG0WDNnjnLOKJnq0X8g5tBhuEZCrN0PS hcgWftY3so0aWs+WFbij+ddxZZahZT+Nu7w+xeruH4Ae49Ly9JI1yerkEyVFxeQ4CHCO UXRlRDFN9Ar56x5dOdm4vf5KsiVEyCeElTafApXxn8ilhIVUTY48D74Odigph7cAgOsL xSlg== 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=K3i9Iy2NSERrM4aBsI9H03nGEahyFfvwR+fvbuCm7s8=; b=W/gFJPdHVid/hQf0Ye1GFhv1dgBnB3/lX6BRQbTYDFQdE5ufEnHkGCOrliGEHlLJYh SBiS6m45EM/E4zCkiaBnC71fHp2MGApKS+j6Qmn9Le+qzqPOd/4iMRm6r3CvNM+MsqHz u0yKKBHCVtefraOhFNeOHurSsprhyI+MJhzQ0GjgjdO3dnDjZdA2KvYRfjtjRLJ8o1C+ GJoyzGj3q+NdtNAmKZ3M6o0pVOmXXELgDAuN8BsbOX6593K2JPq/03tz+uPn9Onfv2hK RLa2QtcYtTAJDdHZb+2EilyOrvqrwdfSuE2FSDEgDxoorkrI23akQ+/8ZJrioVZOPMrA R9JQ== 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 q2si8479001pgr.693.2018.03.05.07.26.15; Mon, 05 Mar 2018 07:26:30 -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 S1752454AbeCEPZP (ORCPT + 99 others); Mon, 5 Mar 2018 10:25:15 -0500 Received: from mga17.intel.com ([192.55.52.151]:33971 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751881AbeCEPZI (ORCPT ); Mon, 5 Mar 2018 10:25:08 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Mar 2018 07:25:07 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,427,1515484800"; d="scan'208";a="34745963" Received: from smile.fi.intel.com (HELO smile) ([10.237.72.86]) by fmsmga004.fm.intel.com with ESMTP; 05 Mar 2018 07:25:05 -0800 Message-ID: <1520263504.10722.399.camel@linux.intel.com> Subject: Re: [PATCH] vsprintf: Make "null" pointer dereference more robust From: Andy Shevchenko To: Rasmus Villemoes , Petr Mladek Cc: "Tobin C . Harding" , Joe Perches , linux-kernel@vger.kernel.org, Andrew Morton , Michal Hocko Date: Mon, 05 Mar 2018 17:25:04 +0200 In-Reply-To: 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> 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 Mon, 2018-03-05 at 16:16 +0100, 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? We (will) have such check in two places, perhaps a helper static bool is_pointer_valid(void *ptr) { return !IS_ERR(ptr) && (unsigned long)ptr >= PAGE_SIZE; } ? -- Andy Shevchenko Intel Finland Oy