Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp926844pxu; Fri, 23 Oct 2020 17:37:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZIOnOLtwFVIwcse5AA5vk0Y5k8/K7QWhIjtf8/Jt1TH4ps6Mi+izC0ME6TQKgCwR3XMn3 X-Received: by 2002:aa7:d7ca:: with SMTP id e10mr4797935eds.269.1603499877370; Fri, 23 Oct 2020 17:37:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603499877; cv=none; d=google.com; s=arc-20160816; b=kLWUtwdp7lIpHis7EdbRbCTrNCOPeBbTYiCfuw1s5bMBGSMYnCTkc9X01KUgMwyuGT IL+jMHcsw+MBLsXh5TJ0+DvxotkqCqnDkMo7sjjSRgKcxW9d7xClBgAcd30V313a2/FP rA9jxdQxupA4NWsW56IOD4/QZZ1M1b2a3rXZxsHLSQsEVVHiXfWi2wVa0tlt4/4X8qsE +q1+FmRm+/YNqdZvfVU6iSfOZHjoGl+pwU0/VXGKtasYXq5Su3eEBtKwvyvFsdQ6OFnB ZwOWMt6eECPydzajJkOsOE092PlFBb8It58SXxwOhkijv8tVUVy01aSrRLGkmdKqWRBz DCvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=NTK7EZhLIyorf0z7qNnZ9n+0hDRgFsssb0HNeO8kMYM=; b=jrnJ3LHshY/Xh0F5CPbRE33Y7i7OYCgxeFHdOW29xGwWrEAyRo27FKFIglC+nOGdoZ OysEa5dle1gqJdmAQe+R+/JmKuUVFOJ/kthtIQGTiq6j50rOfc3wDCggQeDfO769Ar82 uV/9lTG34sPPJ9JsxdPwgu65AFb9QdcKhJHmrEuHu93y/odAXh1nkPmvWkUGU9XrcHeh u2pad00fzwQo/5hORNxEdA6vD1YXiK0UtRpIYtunBD7UQHhCv9Dk0PRUtPPD15ONKRj2 oVytZr3CbV1mJAvjV6/SBOkzP9lTlkunnVvtfYL/c2MKlIHFK2bSJIxjQ2nUO4YeuTAM 7ezQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="nugwVx/z"; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h10si2065753edn.193.2020.10.23.17.37.29; Fri, 23 Oct 2020 17:37:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="nugwVx/z"; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756966AbgJWVxd (ORCPT + 99 others); Fri, 23 Oct 2020 17:53:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:54192 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756964AbgJWVxc (ORCPT ); Fri, 23 Oct 2020 17:53:32 -0400 Received: from gmail.com (unknown [104.132.1.76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id ACE4720857; Fri, 23 Oct 2020 21:53:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603490012; bh=Ij37+nLWdhORElfqYs8jtc6OQd/BGn0J09kWaWaub44=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=nugwVx/zVZIlwfzOET6+GuwwgnQJjNPwjBmYCB7gf+774kJ69BUcUP+RTBwca/lsB qRxXBt0K8ECFwoDH04ZlccuEerj8ssPgYIUvGXt4T2CzH1oeS3WeRcFofla8b2y37r qwaDS8+OekhJASNfUtZR9bhduF5kZ7eg7ifGd4Vw= Date: Fri, 23 Oct 2020 14:53:29 -0700 From: Eric Biggers To: Herbert Xu Cc: Arvind Sankar , "David S. Miller" , "linux-crypto@vger.kernel.org" , David Laight , linux-kernel@vger.kernel.org, Sami Tolvanen Subject: Re: [PATCH v2 1/6] crypto: Use memzero_explicit() for clearing state Message-ID: <20201023215329.GA180517@gmail.com> References: <20201020203957.3512851-1-nivedita@alum.mit.edu> <20201020203957.3512851-2-nivedita@alum.mit.edu> <20201022043633.GD857@sol.localdomain> <20201023153927.GA217686@rani.riverdale.lan> <20201023155604.GA3908702@gmail.com> <20201023204536.GB27708@gondor.apana.org.au> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201023204536.GB27708@gondor.apana.org.au> Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Sat, Oct 24, 2020 at 07:45:36AM +1100, Herbert Xu wrote: > On Fri, Oct 23, 2020 at 08:56:04AM -0700, Eric Biggers wrote: > > > > When clearing memory because "it may be sensitive" rather than "it's needed for > > the code to behave correctly", I think it's best to use memzero_explicit() to > > make the intent clear, even if it seems that memset() is sufficient. Also keep > > in mind that support for compiling the kernel with LTO (link-time optimization) > > is being worked on (and some people already do it), which results in more code > > being optimized out. > > The rule up until now has been that we only use memzero_explicit for > stack variables. At this point please don't convert anything else > as it will cause too much churn. > > If LTO did arrive we should do a global conversion. > LTO is actively being worked on, now up to v6: https://lkml.kernel.org/lkml/20201013003203.4168817-1-samitolvanen@google.com/ And in the real world it's already being used; the Android Compatibility Definition Document strongly recommends enabling CFI, which depends on LTO. It's doubtful that anyone will do a global conversion from memset() to memzero_explicit(), as it's too hard to find all the places that should be converted. They are in lots of different subsystems; the crypto subsystem will have the most, but not all. We just need to fix as many as we can. If you'd like to do something more comprehensive than this patch, that would be great, but I hope we don't wait forever for a global conversion that never happens. FWIW, kfree_sensitive() (formerly kzfree) already got converted by https://git.kernel.org/linus/8982ae527fbef170, and it wasn't really controversial. Some people even wanted Cc stable (which I disagreed with, but it apparently made the final version). - Eric