Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp403356pxk; Fri, 11 Sep 2020 09:58:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwtCubqrUNnTaPT0ekxkDHny7Mw5MRBjj7YmnCXNYr3JoM53oCy/fME5X7FHXOwkdOgCSY0 X-Received: by 2002:a17:906:edca:: with SMTP id sb10mr2881402ejb.60.1599843537660; Fri, 11 Sep 2020 09:58:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599843537; cv=none; d=google.com; s=arc-20160816; b=m2w0YlOUvb3qSKLdSwfa/rbyZPTAko+kMSBpn9TESs7Uf6dwVcDUVp7TlSdLeUhMrK uPANyrvcb6GLq4EhEnQg0TJUmbF6CDFGpqwkTDQWAyxV2ZftNf2N2yd5syy5g8azF8k5 hroX8OQWuY8Z3W3yV07X9Q/o2gmBCBjVtNfdIFqvBc5Yy/chLKj2TBvMET3H8chwIoQ1 DtL8pycaFdMoGSHwQrDRq+84PBVqdiVJQR1+qBCoU6LNnlAhds3Zns4aCHZKmVtYBn/d MAa7pBZHPPsACX1frEX4FA/+8SRoi3EXpKU6ISJuvPJukpMIEaqdd8kfTFox4W4BYeD+ QBjg== 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 :references:in-reply-to:date:cc:to:from:subject:message-id :dkim-signature:dkim-signature; bh=T4k1FJ56PmfLI8BCCUqNGswUnWGEmA54rWWBRN9mBi0=; b=eTgAtLVLVjEnidpda/Mece6ku4+ocRLDwu59AORxEOJoOO5z6qpeAfUQwMbqaB+x3N aA5PykuVOagj4W0iGokFBH4c6klfxea5NMtYkftHuY0xbZsGoXymluFqGLd8RloiXWn7 epZ6boOSwwFXfPlUAkdivPJGbQGiEQ+5BprwOX0SCnAx7l+OfP8i6k2xfWeQR7kQr7g9 VjuDAa8rSJWC8iJBcsY5bpMlqohQmNitAUp3aYKha0FKQQO8vIhWxMLpcL1lmXxsaLx+ HyXw2sXGn5i1epwDrQ/rbd0n9mifJVBg8+xkx+NqkBiWF8Z3H/C2wMaULhMJg4VnKYm4 c0XA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@hansenpartnership.com header.s=20151216 header.b=GG9RMhwB; dkim=fail header.i=@hansenpartnership.com header.s=20151216 header.b=GG9RMhwB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=hansenpartnership.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u10si1594179ejx.142.2020.09.11.09.58.35; Fri, 11 Sep 2020 09:58:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@hansenpartnership.com header.s=20151216 header.b=GG9RMhwB; dkim=fail header.i=@hansenpartnership.com header.s=20151216 header.b=GG9RMhwB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=hansenpartnership.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726335AbgIKQ5r (ORCPT + 99 others); Fri, 11 Sep 2020 12:57:47 -0400 Received: from bedivere.hansenpartnership.com ([66.63.167.143]:42218 "EHLO bedivere.hansenpartnership.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726305AbgIKPE3 (ORCPT ); Fri, 11 Sep 2020 11:04:29 -0400 Received: from localhost (localhost [127.0.0.1]) by bedivere.hansenpartnership.com (Postfix) with ESMTP id DA4558EE21C; Fri, 11 Sep 2020 08:04:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=hansenpartnership.com; s=20151216; t=1599836666; bh=yhrDiYi9c8FE4wC2C86eKSK5/tP+mtNUZsOBeMc7Vzc=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=GG9RMhwBXb3CICZQMZm9a4wVWVt6Ol3eFNMBxAfJmWq4hQgPx+g1bhEuf5tVSH43W CpQhW2TTOG3WcIxLq77wP6UHE55ai2mZF2pqByFiubhxsRQLwRsy7j/UAQirc+n/ov Hz0RaVNlD904A1y9gLwulrhpgULCyeDAi5xevVSw= Received: from bedivere.hansenpartnership.com ([127.0.0.1]) by localhost (bedivere.hansenpartnership.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FWbnV69cVc6j; Fri, 11 Sep 2020 08:04:26 -0700 (PDT) Received: from [153.66.254.174] (c-73-35-198-56.hsd1.wa.comcast.net [73.35.198.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bedivere.hansenpartnership.com (Postfix) with ESMTPSA id 0BF3A8EE0F8; Fri, 11 Sep 2020 08:04:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=hansenpartnership.com; s=20151216; t=1599836666; bh=yhrDiYi9c8FE4wC2C86eKSK5/tP+mtNUZsOBeMc7Vzc=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=GG9RMhwBXb3CICZQMZm9a4wVWVt6Ol3eFNMBxAfJmWq4hQgPx+g1bhEuf5tVSH43W CpQhW2TTOG3WcIxLq77wP6UHE55ai2mZF2pqByFiubhxsRQLwRsy7j/UAQirc+n/ov Hz0RaVNlD904A1y9gLwulrhpgULCyeDAi5xevVSw= Message-ID: <1599836664.4041.21.camel@HansenPartnership.com> Subject: Re: [PATCH] security: keys: Use kvfree_sensitive in a few places From: James Bottomley To: Alex Dewar Cc: David Howells , Jarkko Sakkinen , James Morris , "Serge E. Hallyn" , keyrings@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org Date: Fri, 11 Sep 2020 08:04:24 -0700 In-Reply-To: <20200911114400.82207-1-alex.dewar90@gmail.com> References: <20200911114400.82207-1-alex.dewar90@gmail.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.26.6 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 Fri, 2020-09-11 at 12:44 +0100, Alex Dewar wrote: > In big_key.c, there are a few places where memzero_explicit + kvfree > is used. It is better to use kvfree_sensitive instead, which is more > readable and also prevents the compiler from eliding the call to > memzero_explicit. Fix this. That last bit is untrue: the compiler can't elide memzero_explicit ... that's why it has the explicit suffix. The original problem was a lot of people do memset(.., 0, ..); kfree() which the compiler can elide if it understands the memory is going out of scope. Or the even more problematic memset(..., 0, ...) on a stack variable before it goes out of scope. We can argue about readability but there's no secret leak here. James