Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp785121img; Wed, 20 Mar 2019 10:47:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqznrf0/OiapwDDE7K69/M+5rpisVdTxH9oluYLP3colHR/dTM0UcxtFeIGF/IfBSsCdxMpt X-Received: by 2002:a65:6210:: with SMTP id d16mr8614995pgv.189.1553104056277; Wed, 20 Mar 2019 10:47:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553104056; cv=none; d=google.com; s=arc-20160816; b=RQN636qCU2VEXrfj6yLD5wqemMAnagj9fBLFXY3qWYP2u+qle4q+UvMhYTg5G2g8uW aevxU5kh5wMA4D3Vi7MdewyKikDCHP3JpecFR7qSv4Npdom7S2dtXPvOP8i7s7tDnK8n irp1rT98Fu60FKH5rGyOf6uUiKBYnRd8wYadtuOdAfXxooQtjaKjHuGo5WiT2gemDab2 OQFR/c5jGyFJ/2fTrRLgEF5U148VBqvi7qWDKdV9FPK69QPpr1DTS79E19JJC11Rf6/c oLkVMuwQo6eU5axvJ/jD+Cb0Rg069B1ma8oM0HA6PCGulBzIG7HkejCC1KbyUwi5KuL7 1oKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :dkim-signature; bh=D/oXc+713++ecBotR94dhoqyhOY4U6rININ+Cpib0mw=; b=v6i4QhaaD+aszbOdprE8r02UIFwADu+v/uSpr9v/ok7aI9ufznRX8wS9UxZR4JfiRt hcCT5I2HaSxWQJccJFRn/qyliSd+o/Cz99JCXUFaPuYXgB8ReO469wB9H8qCNiWQu0bA +i0ZyXAfdDYXSpHjSxInEF/c+xbOgzmmT4szACJEfzPmcFaPxokSeF6HTTurbB6TIVF0 rqaKb74RzHt1XWKS1GKALnkBfV9r8NN3gfq9gxhd3Z1jn9CVxkB9pMSrORXMzAP5w1Ys VNUiP/41JZNXJWeuooSgkxjdTIEuPAY8JKx/yArPrNiWSwmCxM8RVkatfDcaHRKCVzLM eymg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kroah.com header.s=fm3 header.b=mEu4IlVr; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=WrmZFG30; 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 k11si2282119pls.244.2019.03.20.10.47.21; Wed, 20 Mar 2019 10:47:36 -0700 (PDT) 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; dkim=pass header.i=@kroah.com header.s=fm3 header.b=mEu4IlVr; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=WrmZFG30; 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 S1727227AbfCTRqg (ORCPT + 99 others); Wed, 20 Mar 2019 13:46:36 -0400 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:56859 "EHLO out5-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726832AbfCTRqf (ORCPT ); Wed, 20 Mar 2019 13:46:35 -0400 X-Greylist: delayed 401 seconds by postgrey-1.27 at vger.kernel.org; Wed, 20 Mar 2019 13:46:35 EDT Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 4EBC8231E7; Wed, 20 Mar 2019 13:39:54 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Wed, 20 Mar 2019 13:39:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kroah.com; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:content-transfer-encoding:in-reply-to; s=fm3; bh=D /oXc+713++ecBotR94dhoqyhOY4U6rININ+Cpib0mw=; b=mEu4IlVr+CIFcmcRm wD2qDqbp0o3XXxfsJHHlWAtf4Us+CF6fadvAVMb3ommz7jmVMcyHMsqVQbvgUoIx 9phbm6yXkLL0ZVpNFP6rwbD0onRCyhA22A15GuFQe6sh70ZL++b5Nrhv/b9YKxon btlsIuxk8ULf9wCiLBd7s0ClyZnz/U38cawy78kYXPZnEComY+k9IEzIsDL/8cIT Et8icpr3nBJtEL1CzlvZ6Yp6ucbUx3gaWGigmZO2XFYXu0G3XWmyJbzelIteGmIn YhQL3bQ/wOATZaepM2sQoAJCQcK2AtJlg6CMLL/tpXl1OZSIPBJWKzv6Re23t1/u I4ojQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=D/oXc+713++ecBotR94dhoqyhOY4U6rININ+Cpib0 mw=; b=WrmZFG30VSr24+qCfvL88T7H5q/H+9a2aPbU5Snrpw6bCRk8au8hpou1H htoyhXX21z0qRPCrp+4ovNBdioN9vgfNT7s9+COjAMkGp0kTfxWKnpeAf884KSpS Jha0f5bdq7o1rDRHPO8/f6xLyUkh2KIRcROPHHzoAHKXzfnfuC8HbgtJdy35FAu1 q1KUyC+TXHcAZwbyI7dXGpgXP7SXmtUvzBhiZTHOOm7EvWBM6BYSVAgq0jUJ0XJT cx5cc1AKo4uD+flvILllN9Crunytm8itWMpAliowosL6pjeYdfVfPCDy1PyTxD0r Ca/05ep6eDgEbZ9bae8RUUHnjKYcg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedutddrieeigddutdefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfhfgggtugfgjggfsehtkeertddtredunecuhfhrohhmpefirhgv ghcumffjuceoghhrvghgsehkrhhorghhrdgtohhmqeenucfkphepkeefrdekiedrkeelrd dutdejnecurfgrrhgrmhepmhgrihhlfhhrohhmpehgrhgvgheskhhrohgrhhdrtghomhen ucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Received: from localhost (5356596b.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) by mail.messagingengine.com (Postfix) with ESMTPA id EC8D81031A; Wed, 20 Mar 2019 13:39:52 -0400 (EDT) Date: Wed, 20 Mar 2019 18:39:51 +0100 From: Greg KH To: James Smart Cc: Kees Cook , Willy Tarreau , Silvio Cesare , LKML , Dick Kennedy , Dan Carpenter , Will Deacon Subject: Re: [PATCH 5/8] scsi: lpfc: change snprintf to scnprintf for possible overflow Message-ID: <20190320173951.GA27003@kroah.com> References: <20190112152844.26550-1-w@1wt.eu> <20190112152844.26550-5-w@1wt.eu> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.11.4 (2019-03-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 15, 2019 at 02:41:17PM -0800, James Smart wrote: > > On 1/14/2019 5:15 PM, Kees Cook wrote: > > On Sat, Jan 12, 2019 at 7:29 AM Willy Tarreau wrote: > > > From: Silvio Cesare > > > > > > Change snprintf to scnprintf. There are generally two cases where using > > > snprintf causes problems. > > > > > > 1) Uses of size += snprintf(buf, SIZE - size, fmt, ...) > > > In this case, if snprintf would have written more characters than what the > > > buffer size (SIZE) is, then size will end up larger than SIZE. In later > > > uses of snprintf, SIZE - size will result in a negative number, leading > > > to problems. Note that size might already be too large by using > > > size = snprintf before the code reaches a case of size += snprintf. > > > > > > 2) If size is ultimately used as a length parameter for a copy back to user > > > space, then it will potentially allow for a buffer overflow and information > > > disclosure when size is greater than SIZE. When the size is used to index > > > the buffer directly, we can have memory corruption. This also means when > > > size = snprintf... is used, it may also cause problems since size may become > > > large. Copying to userspace is mitigated by the HARDENED_USERCOPY kernel > > > configuration. > > > > > > The solution to these issues is to use scnprintf which returns the number of > > > characters actually written to the buffer, so the size variable will never > > > exceed SIZE. > > > > > > Signed-off-by: Silvio Cesare > > > Cc: James Smart > > > Cc: Dick Kennedy > > > Cc: Dan Carpenter > > > Cc: Kees Cook > > > Cc: Will Deacon > > > Cc: Greg KH > > > Signed-off-by: Willy Tarreau > > I think this needs Cc: stable. > > > > Reviewed-by: Kees Cook > > > > -Kees > > > > > Reviewed-by:? James Smart What ever happened to this patch? Did it get dropped somehow? thanks, greg k-h