Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp6051171rwl; Mon, 9 Jan 2023 03:39:53 -0800 (PST) X-Google-Smtp-Source: AMrXdXvKZ59Jj/JEBLSXAbYAXc6PPj3fXVMLxz7G1JoQuQwSadx8zm7vDZeNdzAoFZECFBgwfK2o X-Received: by 2002:a05:6a21:1518:b0:ac:f68:33c9 with SMTP id nq24-20020a056a21151800b000ac0f6833c9mr78707087pzb.33.1673264393683; Mon, 09 Jan 2023 03:39:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673264393; cv=none; d=google.com; s=arc-20160816; b=LKCKSNCFR8j1B1z25TftBz8P7x1+QtO9B8AMD/6dImWN7kcgSpo8JKSUOcocLTkFDX n0JOsko83ykGPe5YPt/o5Yt8NDvFKkWxenf7DgTvntG6ZS13pHfFgXpNSLEzphI9h0Os j3aJqcWKbgtKKeu+FjjEwkWM/+Bk/7thKn2u7panMWbsS40v7qPR7dtV22F4ArFaul4T RhwsQjhpbtX8oUakSTcBgVXtKBX6QSlQPZXFTmH5PZVnKyT3Kp9buOIrGTr1VdLbJviJ PVHOvAnRUYNDbrGtYkYSR3Pc04ev+snf8UhniIG4aiKvq+708CpM9ZYeTgf8XJLCdmiZ lG3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=bM0iVHUEbfqCYXfdRByIUCokxN2eQlAuZFyCFVdy4go=; b=VBbR2VEFpGRPeGzYxBEY1oSZSjuswSkmISGeUqIKtEtFVPVNfYWsr7azuf53c8IuzH jBAQKOTfDyw3nZ9g81LB35bMsGXSOIJ2+7SB1U3E29bjFonMKm8fM055BHqDTtqbar7j PrU8Kpg5XbvJ8cHVu5Mq86bzYvxcoad5HlfJvzdm3bvVtBvaM9CmZEMEF+oySGSOua91 AGZg1PIw6eoDn6rjcmNUXUSEZ7rACjFnoW4kSUQ8SMkqLGN7pY6ne/7O7nwtnQ1sVN7w dFjRtkUT8lCE64po9zky3TTFYx/0EbPZkds/EHTdi5VLKscEkUzuZYHMiTAUj6+hEIjR IA7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=gB4Oq549; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m14-20020a63fd4e000000b0046f583c8c4asi9226151pgj.315.2023.01.09.03.39.47; Mon, 09 Jan 2023 03:39:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=gB4Oq549; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234159AbjAIL0N (ORCPT + 53 others); Mon, 9 Jan 2023 06:26:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236912AbjAIL0J (ORCPT ); Mon, 9 Jan 2023 06:26:09 -0500 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17EBC167CE for ; Mon, 9 Jan 2023 03:26:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673263569; x=1704799569; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=3qWXvBiMwic5hXKXKXJ43zm4Wa3xTBKTNHaKUocqVo4=; b=gB4Oq549qGczHE/YStje1ezFyv0ATpIk4NVvwJiYZC8KYx8Bf2oKfj12 LEErneJ6zZAiqzJ1jAMpY87Pt2f6Uv4N/c+5fkJUNFAKS1+YqVZx6D2GV zmSdttqyJt/5dDdNiXaz/FyhlxzhMNO7F9USvNGYywCwfkYNnYuJATzXM RndNM18kOoQmcjB23RWJ0kXBkUInycTEITUIap0Li+mxuwD1dDHozLFn3 PNHV0+jOZGOtZ0jhwZupn3393Ps9Ycye0QjHo7PFBhDlekv1zwEpb8vlw MTpS2EU4n2uNpjYyUjm3xMA1Gf46d6QTc17C4MgXLd1qYqFoiMktxvi6H Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10584"; a="350063960" X-IronPort-AV: E=Sophos;i="5.96,311,1665471600"; d="scan'208";a="350063960" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jan 2023 03:26:08 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10584"; a="719907230" X-IronPort-AV: E=Sophos;i="5.96,311,1665471600"; d="scan'208";a="719907230" Received: from smile.fi.intel.com ([10.237.72.54]) by fmsmga008.fm.intel.com with ESMTP; 09 Jan 2023 03:26:06 -0800 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1pEqI1-006Mdc-0n; Mon, 09 Jan 2023 13:26:05 +0200 Date: Mon, 9 Jan 2023 13:26:04 +0200 From: Andy Shevchenko To: Sergey Shtylyov Cc: Petr Mladek , Steven Rostedt , Sergey Senozhatsky , Rasmus Villemoes , linux-kernel@vger.kernel.org Subject: Re: [PATCH] vsprintf: fix possible NULL pointer deref in vsnprintf() Message-ID: References: <1f4d159e-5382-3c75-bd5e-42337ecd8c28@omp.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 09, 2023 at 01:23:40PM +0200, Andy Shevchenko wrote: > On Fri, Jan 06, 2023 at 12:16:31AM +0300, Sergey Shtylyov wrote: ... > > + /* > > + * C99 allows @buf to be NULL when @size is 0. We treat such NULL as if > > + * @buf pointed to 0-sized buffer, so we can both avoid a NULL pointer > > + * dereference and still return # of characters that would be written > > + * if @buf pointed to a valid buffer... > > + */ > > + if (!buf) > > + size = 0; > > Do we have test cases for that? This still stays... > And what's wrong to print "(null)" ? Have you checked if your patch makes any > regressions to those cases? ...but this paragraph is not for the case (I mixed it with the arguments to be NULL). -- With Best Regards, Andy Shevchenko