Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4479148ybb; Tue, 14 Apr 2020 08:06:40 -0700 (PDT) X-Google-Smtp-Source: APiQypIsit+35D+4NSQzGkTPkzWWManTf7Ess48d/5iJNPh38Z0ELL2th+UOS2tgwXt0QJmdjQr1 X-Received: by 2002:a17:906:43c6:: with SMTP id j6mr502795ejn.39.1586876800282; Tue, 14 Apr 2020 08:06:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586876800; cv=none; d=google.com; s=arc-20160816; b=SZ2nhJivkO//59/0/SxrTx1+SjPE4hJ2QxOBAOAODpSsGX8upwDlTUwqbi0WOywNrh TZHwBfHUWP3a7vhrrrs6QZKhr87d2iNw5t+3gdqk6xgFv445efcn2yM+QBrX/QFjOLyK tmCZERglWKs7+DhpQsEfHTXNQNQhgpbWqIWi+oFvnnMfXj3IAf7bNBIhRe7jE9i+peY3 x/c9VfiTAK6cTp4Grc1G2fvFRrXzyPMvxo7SI4oFWYubbdtBTO3PCURC8UXsXbAvDJDu 0k8CwPKXWAVBI/oBWkwVFchmoGLAfJjUnXjovnzDjRwUyzT7q1DFNehP/PYfueneemvJ ySoQ== 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 :content-language:in-reply-to:mime-version:date:message-id:from :references:cc:to:subject:dkim-signature; bh=UKQsCwENnNIEAuJXvQ/tW8fkmNjG5WmayzQXfCLs/i4=; b=GnssenxZu1Wgxc42gWiWtx/dicKbYqcClr9jTz3RQBXo3bz9laT/nTz58sHxe0Exv0 jhmaDMdoG7TQ/v7aQ3n09XeaktSpsOugLJJ04XhGTDBLK2Lxcsma3DNeFqOpl6a9iNK9 ahv6zJYkp/DxMHwtKk+oIfGHtFZAKeteOQI4X1vQ7x0SMuOKMY0/+gLeBkfV+MHxFR5g VVicxZ5K/bkrFisADjKeK31Iy0OEiwC4D1Sr41WQAYrBPhPqOlcsAwcaEhQFwCjgBKz5 F0HHuaIlrLFLtyKWUlZ68sZYWUAtMN+mXUIsk5t/Vr08z2maSbbgNRrFfTbDAXuizGEf Z3Ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=mail header.b=sx6IKJIx; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zx2c4.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w11si8452691ejz.146.2020.04.14.08.06.13; Tue, 14 Apr 2020 08:06:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-bluetooth-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=@zx2c4.com header.s=mail header.b=sx6IKJIx; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zx2c4.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2436875AbgDNIcR (ORCPT + 99 others); Tue, 14 Apr 2020 04:32:17 -0400 Received: from mail.zx2c4.com ([192.95.5.64]:52379 "EHLO mail.zx2c4.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2436826AbgDNIcL (ORCPT ); Tue, 14 Apr 2020 04:32:11 -0400 Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTP id 9d220a78; Tue, 14 Apr 2020 08:22:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=zx2c4.com; h=subject:to:cc :references:from:message-id:date:mime-version:in-reply-to :content-type:content-transfer-encoding; s=mail; bh=Bn42dUX94nPZ VI2aresTt2verm4=; b=sx6IKJIxzuEOA3MDWmGK5eH/64R8mpMYlG8WURWdfzRD XFeah0rjLnpfJ/wNxDNPuLqvGkOXg2tTc6/J9yxFJV/B/IyVASTm/xV1AWFh8sOT E+Zkl2VUcl4Y0wf6Mu5iapMmn3g8Ztyi36JLXdlWN66PEuOJynjCGScQFzOu0tep 4+h/FZal3et8UceGQF9vqtL2mbwwUOtzAFh6NniwZkygh5iiMorXd4zwhnYD2AoL UBjxDBvR+PqwgLJDDNN43HRxAe1Ka1ICHvrV5FNQIfjCNS9xZTJzxiJXAqnsHyrN w3BT8jw4OmracAotC1L9+6WCZMUQn8YWdWOjpIB/Jw== Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id e4f42b92 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Tue, 14 Apr 2020 08:22:18 +0000 (UTC) Subject: Re: [PATCH 1/2] mm, treewide: Rename kzfree() to kfree_sensitive() To: Waiman Long , Andrew Morton , David Howells , Jarkko Sakkinen , James Morris , "Serge E. Hallyn" , Linus Torvalds , Joe Perches , Matthew Wilcox , David Rientjes Cc: linux-mm@kvack.org, keyrings@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org, linux-crypto@vger.kernel.org, linux-s390@vger.kernel.org, linux-pm@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org, linux-mediatek@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, intel-wired-lan@lists.osuosl.org, linux-ppp@vger.kernel.org, wireguard@lists.zx2c4.com, linux-wireless@vger.kernel.org, devel@driverdev.osuosl.org, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-fscrypt@vger.kernel.org, ecryptfs@vger.kernel.org, kasan-dev@googlegroups.com, linux-bluetooth@vger.kernel.org, linux-wpan@vger.kernel.org, linux-sctp@vger.kernel.org, linux-nfs@vger.kernel.org, tipc-discussion@lists.sourceforge.net, cocci@systeme.lip6.fr, linux-security-module@vger.kernel.org, linux-integrity@vger.kernel.org References: <20200413211550.8307-1-longman@redhat.com> <20200413211550.8307-2-longman@redhat.com> From: "Jason A. Donenfeld" Message-ID: <4babf834-c531-50ba-53f6-e88410b15ce3@zx2c4.com> Date: Tue, 14 Apr 2020 02:32:03 -0600 MIME-Version: 1.0 In-Reply-To: <20200413211550.8307-2-longman@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org On 4/13/20 3:15 PM, Waiman Long wrote: > As said by Linus: > > A symmetric naming is only helpful if it implies symmetries in use. > Otherwise it's actively misleading. > > In "kzalloc()", the z is meaningful and an important part of what the > caller wants. > > In "kzfree()", the z is actively detrimental, because maybe in the > future we really _might_ want to use that "memfill(0xdeadbeef)" or > something. The "zero" part of the interface isn't even _relevant_. > > The main reason that kzfree() exists is to clear sensitive information > that should not be leaked to other future users of the same memory > objects. > > Rename kzfree() to kfree_sensitive() to follow the example of the > recently added kvfree_sensitive() and make the intention of the API > more explicit. Seems reasonable to me. One bikeshed, that you can safely discard and ignore as a mere bikeshed: kfree_memzero or kfree_scrub or kfree_{someverb} seems like a better function name, as it describes what the function does, rather than "_sensitive" that suggests something about the data maybe but who knows what that entails. If you disagree, not a big deal either way. > In addition, memzero_explicit() is used to clear the > memory to make sure that it won't get optimized away by the compiler. This had occurred to me momentarily a number of years ago, but I was under the impression that the kernel presumes extern function calls to always imply a compiler barrier, making it difficult for the compiler to reason about what happens in/after kfree, in order to be able to optimize out the preceding memset. With LTO, that rule obviously changes. I guess new code should be written with cross-object optimizations in mind now a days? [Meanwhile, it would be sort of interesting to teach gcc about kfree to enable additional scary optimizations...]