Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3116488imu; Fri, 18 Jan 2019 05:10:57 -0800 (PST) X-Google-Smtp-Source: ALg8bN6fYsFKskjZLBID00DtxmoflrEerKL0Rhr/G3eiaQbKg6N4GnfN7PmnvBBhK446CxUt5Ngm X-Received: by 2002:a65:6215:: with SMTP id d21mr17626648pgv.289.1547817057895; Fri, 18 Jan 2019 05:10:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547817057; cv=none; d=google.com; s=arc-20160816; b=vOj9J7FMT/SAgMYbh2tx8uBZ1JSGQHR9AnbvKPaIpVXDB22Vt4BIxQC9MzYCzeRsez eur6A28yIhIFwJBgWRMaMjGPGHwmlO4RySm/InZGccTUklt7iBy/a0a5osloI5ocRvvM RXQLyiPy+oTvacqYb4gQoHKXy/BL9yQOPrzBOj5OkOCZs5VxX6skYcXSzbPIMAhywTGQ hHzjNizKd/FdNUC+4mODeQl2ljkolD1/KSj1sWu1bhgU6yABYBeHWG5OvBUdJ9NwJ0AF FCC2wcdTh2eCmx9o0OHyT+v6J1lt95a2uB+LLc6K/ngL8HaSoHEFKsXo425ug3AtE5vl BdfA== 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-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:dkim-signature; bh=7zPrEcHCUbuM7hhUe7azWpqIsHgd1XucZkVE/odsv18=; b=ReaR1PZTfFCGbL6tjnJm5elZhvVinlYyL0mdNI5/EZnWF2EzKeNLgQeQDAHKZ0f4v8 8AyDJtS3Ret2Tya3PwnjfgSvsXa/2usGarHLO+7EXNjx0Hg+66rSszTivC1hpLg6tXh2 MaM5xN0R+JBhNkgUU0YEds3ulrKzkukXT3ltlLz3ndr2gH8yPOFhDcLA2nLvWtTWO+Vy NByedDhh+mymUyBe6zhZYt4JGFQjRY4XQ3BQbSH0GPHZRs9aPOzD7T4uqWgDOItkvv66 jZf6n/TX18+Hka64P21SQqLRwCN3f6VwWaGKqUSwImp01vIl90kVKXvckmB17A3ZTDBP +6iA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kroah.com header.s=fm2 header.b=MmGZ6yBu; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=pfW1Pq3L; 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 w22si4215380plp.301.2019.01.18.05.10.36; Fri, 18 Jan 2019 05:10:57 -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; dkim=pass header.i=@kroah.com header.s=fm2 header.b=MmGZ6yBu; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=pfW1Pq3L; 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 S1727810AbfARNGx (ORCPT + 99 others); Fri, 18 Jan 2019 08:06:53 -0500 Received: from new2-smtp.messagingengine.com ([66.111.4.224]:50571 "EHLO new2-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726952AbfARNGx (ORCPT ); Fri, 18 Jan 2019 08:06:53 -0500 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailnew.nyi.internal (Postfix) with ESMTP id 846AD28F4B; Fri, 18 Jan 2019 08:06:51 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Fri, 18 Jan 2019 08:06:51 -0500 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:in-reply-to; s=fm2; bh=7zPrEcHCUbuM7hhUe7azWpqIsHg d1XucZkVE/odsv18=; b=MmGZ6yBu0DwLneSivnkH5TKMjVXM3d8TEgz6XoYKeaI S5Ky7r3uJXVr9CXcbFis7Fw5tK2VgfHsMhzSrOFZSeZ19PN8q+h9CedQyBOGupLI lXS1OZZJ9z8AEj3oYs5YxGDsBewYx2hmhUq8zpZtsvGluNKcP41J+VypAvis93/l 4f7Y8x9544EPIvvvnviUGjAz2DRLLvnKl2YPJoGbXX1uH+wnw2K/9FJzp/BpSO6Q hmhHKE0CojC7T0izkNNvsysQnRDN5dH1phRFsh5zlOKBOnRBoFmOBOWWgFf3qoRw zdZygjBn4YMuFbkfdK7U6TriNuQDP7IMxIePVtBkKUA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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=fm1; bh=7zPrEc HCUbuM7hhUe7azWpqIsHgd1XucZkVE/odsv18=; b=pfW1Pq3L+byH/joLyW3o4I txrzVOEOIZge+W1I/uOYut+M59WSFKWQxYhorKIKOqDJtYuxas6Xe35RbDI+/jZD ApfebSO49fFq7oLhctkzma8d5eyMwV6REkZf6O5TNdCaYCbHB9qYvN5vFJM83es+ DB8tCWf1R5wRSPttSva8EypmnKqTiiQ9J7t0L9iRBFj5xgy0vCGgzVFKFnYF8k3H jh3Gxh3G5KIWUiU5CovVk7iCeEDLfE5E03ugL3Z7lG9t2H/9eOWskK0c3n+fkOoS NfsGxSwjYOY1UDmJa7RP8fo2sIooxlW5LO71I0RQXUbza73CuDzlEHTkVPnKEZdQ == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtledrhedtgdehtdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecufedt tdenucesvcftvggtihhpihgvnhhtshculddquddttddmnegoufhprghmkfhpucdlfedttd dmnecujfgurhepfffhvffukfhfgggtuggjfgesthdtredttdervdenucfhrhhomhepifhr vghgucfmjfcuoehgrhgvgheskhhrohgrhhdrtghomheqnecukfhppeekfedrkeeirdekle druddtjeenucfrrghrrghmpehmrghilhhfrhhomhepghhrvghgsehkrhhorghhrdgtohhm necuvehluhhsthgvrhfuihiivgeptd 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 3535D1027C; Fri, 18 Jan 2019 08:06:50 -0500 (EST) Date: Fri, 18 Jan 2019 14:06:48 +0100 From: Greg KH To: Kees Cook Cc: Silvio Cesare , LKML , Dan Carpenter , Will Deacon , Willy Tarreau Subject: Re: [PATCH 1/8] lkdtm: change snprintf to scnprintf for possible overflow Message-ID: <20190118130648.GA27209@kroah.com> References: <20190112152844.26550-1-w@1wt.eu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.2 (2019-01-07) 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 12:47:34PM -0800, Kees Cook wrote: > On Sat, Jan 12, 2019 at 7:28 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: Dan Carpenter > > Cc: Kees Cook > > Cc: Will Deacon > > Cc: Greg KH > > Signed-off-by: Willy Tarreau > > It looks like these are going via individual trees. Greg, can you > please take this into your drivers-misc tree for lkdtm? > > Acked-by: Kees Cook Will do, thanks. greg k-h