Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3454179ybb; Mon, 6 Apr 2020 09:13:12 -0700 (PDT) X-Google-Smtp-Source: APiQypLAAJfClhnwEjgPmPX9EaPJbZC+MkXABJfFQrIJzHlm2/ixJHk+S/DyISiVtNgIg9SF72Xo X-Received: by 2002:aca:80e:: with SMTP id 14mr6810oii.143.1586189592263; Mon, 06 Apr 2020 09:13:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586189592; cv=none; d=google.com; s=arc-20160816; b=W/2VI94P3Icva75IrssI8lQpRLe2U+/xBIE6Bz8HG4fN+jdC594iA0oyLP1s3OFGGy pWPdXOrPQdIhPrVkYp2D/iUH25FV84MtpMlcnzgwdXewTjOouA58SgkkvnhCXjkPbnOT maaI33GmkcpxeVTOyRYqb888WYUdY6cVLGN98eN2tQE7EPcR6tac8muMCliV48KoGO6s MPxxUHYcjVpoAjeWRChbC4rX4prhK8wqsW/WtSL+xh/kGU5ihYLpfiRisTQ5TIvLBEQ/ oFc1DVVB7q+9VMLpHprAACvZpDw8D4/zCZPH6bpYWb4sVAEMa7pYnJIuUz29c2aZ/OQz 0fXw== 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 :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=4klucaOOhD/9CpWvsgQzgHfnPB8AaKvbu8ParrdPZtg=; b=G+0ZfvA6w4Nbd1ARAvuWaPnk2K42NMq6eQWn00ulgLNwXGk4cacnwgAfw/REcFVxfA jU6icFEkV5tNis9CckTK0qJo3woTYTRj2fstcyvOFqR/0uaz3ixO5MjOki7IICLR+vk9 Lf6lTnlArj0tw0jfx30udXrUg1m0qd9R8cmmFbUT8AOhT0MiZmboBPp6Hc/wLI3RXDzS EMaPdcIGRGckY+1+oLiznNE8YIMgWCQChbV0VcZDutLdUTnOrec5b7AKzdv90G3fpkDA gyHEHekXOcWMSvRB2vip+RgUhukPrlNI4NY9yil4SmR7HseIYPYIRzWANX8Hdu4WnoF7 iceQ== ARC-Authentication-Results: i=1; mx.google.com; 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 c20si8162745otn.247.2020.04.06.09.12.58; Mon, 06 Apr 2020 09:13:12 -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; 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 S1729410AbgDFQME (ORCPT + 99 others); Mon, 6 Apr 2020 12:12:04 -0400 Received: from smtprelay0164.hostedemail.com ([216.40.44.164]:42242 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728707AbgDFQMD (ORCPT ); Mon, 6 Apr 2020 12:12:03 -0400 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay01.hostedemail.com (Postfix) with ESMTP id 37DF0100E7B72; Mon, 6 Apr 2020 16:12:02 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,,RULES_HIT:41:355:379:599:800:960:965:966:973:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1542:1593:1594:1711:1730:1747:1777:1792:2196:2199:2393:2559:2562:2828:2892:3138:3139:3140:3141:3142:3354:3622:3865:3866:3867:3868:3870:3871:3872:3874:4321:4362:4385:4390:4395:5007:6119:6691:7903:7904:8660:9163:10004:10400:10848:11232:11658:11914:12050:12296:12297:12740:12760:12895:13148:13161:13229:13230:13439:14096:14097:14181:14659:14721:21080:21433:21627:21795:21939:21990:30029:30054:30075:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:2,LUA_SUMMARY:none X-HE-Tag: rest46_4bb8419fa601a X-Filterd-Recvd-Size: 3233 Received: from XPS-9350.home (unknown [47.151.136.130]) (Authenticated sender: joe@perches.com) by omf10.hostedemail.com (Postfix) with ESMTPA; Mon, 6 Apr 2020 16:12:00 +0000 (UTC) Message-ID: Subject: Re: [PATCH] mm: Add kvfree_sensitive() for freeing sensitive data objects From: Joe Perches To: David Howells Cc: Waiman Long , Andrew Morton , Jarkko Sakkinen , James Morris , "Serge E. Hallyn" , linux-mm@kvack.org, keyrings@vger.kernel.org, linux-kernel@vger.kernel.org, Linus Torvalds Date: Mon, 06 Apr 2020 09:10:02 -0700 In-Reply-To: <319765.1586188840@warthog.procyon.org.uk> References: <20200406023700.1367-1-longman@redhat.com> <319765.1586188840@warthog.procyon.org.uk> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.34.1-2 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 Mon, 2020-04-06 at 17:00 +0100, David Howells wrote: > Joe Perches wrote: > > > > This patch introduces a new kvfree_sensitive() for freeing those > > > sensitive data objects allocated by kvmalloc(). The relevnat places > > > where kvfree_sensitive() can be used are modified to use it. > > > > Why isn't this called kvzfree like the existing kzfree? > > To quote Linus: > > We have a function for clearing sensitive information: it's called > "memclear_explicit()", and it's about forced (explicit) clearing even > if the data might look dead afterwards. > > The other problem with that function is the name: "__kvzfree()" is not > a useful name for this function. We use the "__" format for internal > low-level helpers, and it generally means that it does *less* than the > full function. This does more, not less, and "__" is not following any > sane naming model. > > So the name should probably be something like "kvfree_sensitive()" or > similar. Or maybe it could go even further, and talk about _why_ it's > sensitive, and call it "kvfree_cleartext()" or something like that. > > Because the clearing is really not what even matters. It might choose > other patterns to overwrite things with, but it might do other things > too, like putting special barriers for data leakage (or flags to tell > return-to-user-mode to do so). > > And yes, kzfree() isn't a good name either, and had that same > memset(), but at least it doesn't do the dual-underscore mistake. > > Including some kzfree()/crypto people explicitly - I hope we can get > away from this incorrect and actively wrong pattern of thinking that > "sensitive data should be memset(), and then we should add a random > 'z' in the name somewhere to 'document' that". Thanks. While I agree with Linus about the __ prefix, the z is pretty common and symmetric to all the zalloc uses. And if _sensitive is actually used, it'd be good to do a s/kzfree/kfree_sensitive/ one day sooner than later.