Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4813212ybb; Tue, 7 Apr 2020 15:14:33 -0700 (PDT) X-Google-Smtp-Source: APiQypKozob/5SWl1fol2imKvD/pgPQfPaM3T1hNDOrdjqp4RqpMLUqWpy2v4ZJB9C+ryoXxYBGK X-Received: by 2002:a4a:b241:: with SMTP id i1mr1406687ooo.64.1586297673531; Tue, 07 Apr 2020 15:14:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586297673; cv=none; d=google.com; s=arc-20160816; b=kyX0O4MIP2BZvmxoudlWf9N6KHl3MOBrAZoQdE2U0yjHaL2etOmPFrhcVLjh5eZclW 1hrLqkJ4+Y/YeQS43GAwNIfNBWSWjsd/ysJd+biIcPNUBxuDrLLxHxopDKGQ9bquSBhK D+ehKfxv3gbCP2/Beq6jahxqxTVdJqdSRf5DNfdE0DbP3/XU71NuXq6PvID7poSlkJ6w QhzF4ZvvKo2plE4HEWsSfzlcWhxjwKdoFEF1ur+lcPulKAUOWKjFhgswHjiMDMrtI7MR cIB27kMvAkH6Z66Oi+5CjA004pnl6XN0wGvAIIUhbTsESeiv01+kwnSrinvhSP0IV62Z 0UCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=FXLhUp57gFBupyAqKDM1j0MtUkdYHWcwHronu354gjo=; b=SGU4yzKVPw/uHgt3DB4Tdv5h8qo5jGDuQxOEex3LcNm4Qrnm6/s2GysOCdkVrjZNw+ voVR6mg0cNSRGUZr8Zk3KyjPne7Z786R8xDUMo9CGBzekqEnoALeeD6Nuz6zVzMXzYDS hHrzqE6sBrK6G0THHlmpb0Bq8DL382mQy8Z4fdNse+ecV1apOavKaTTCeh6PczXuLrsU yPSjkBTPvgNbSRMb5+zz9MAVKHkikHy+LqV18w2sE8vJ3fCEHxvbSHk+/qXqtOwxF5Ff krPgYOQAhgJCZS+yXRBkh3UmUzAzPuv09wSQU8HbI/VDyoHH1jPdyw8dA5HFtyWlOM0q yBiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b="NX6E/shB"; 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 q206si1230472oig.71.2020.04.07.15.14.19; Tue, 07 Apr 2020 15:14:33 -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; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b="NX6E/shB"; 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 S1726545AbgDGWNJ (ORCPT + 99 others); Tue, 7 Apr 2020 18:13:09 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:52022 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726380AbgDGWNJ (ORCPT ); Tue, 7 Apr 2020 18:13:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=FXLhUp57gFBupyAqKDM1j0MtUkdYHWcwHronu354gjo=; b=NX6E/shBFjhTZtqoWnsQggljWV EyLgZ5kRMQApEWr518G4omxxKtjX1mcRuhtfdBXlhdfAoVdCjqsjGRdVXjbBHd58EvScCldFtbo2F hOA4FH2cuE/ghnQHveMeKwsRvzJSceJ3IbKxeE4Cs17bXDmbtKfsQTj9OljtwybWtCghbqN2ZCTG6 6yO26v9Tf70S8HIBje/GJxVf8BXrhRRNtA0zto7fW6Xg29BSrXtEtdaSDXdp9wQtnL448t1XfMOGb 27kv5jOh/xg54mKdmaIaR1N1tBzPa0ksGgQeqbilqU4O//Mhy9LRuhkF27lqjReRnOvBXme8yGguq Fl0fC2Xg==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jLwSl-0004xw-AZ; Tue, 07 Apr 2020 22:12:55 +0000 Date: Tue, 7 Apr 2020 15:12:55 -0700 From: Matthew Wilcox To: Waiman Long Cc: Joe Perches , Andrew Morton , David Howells , Jarkko Sakkinen , James Morris , "Serge E. Hallyn" , linux-mm@kvack.org, keyrings@vger.kernel.org, linux-kernel@vger.kernel.org, Linus Torvalds , David Rientjes Subject: Re: [PATCH v3] mm: Add kvfree_sensitive() for freeing sensitive data objects Message-ID: <20200407221255.GM21484@bombadil.infradead.org> References: <20200407200318.11711-1-longman@redhat.com> <0fe5dcaf078be61ef21c7f18b750c5dc14c69dd7.camel@perches.com> <67c51b03-192c-3006-5071-452f351aee67@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <67c51b03-192c-3006-5071-452f351aee67@redhat.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 07, 2020 at 04:45:45PM -0400, Waiman Long wrote: > On 4/7/20 4:31 PM, Joe Perches wrote: > > On Tue, 2020-04-07 at 16:03 -0400, Waiman Long wrote: > >> +extern void kvfree_sensitive(const void *addr, size_t len); > > Why should size_t len be required? > > > > Why not do what kzfree does and memset > > the entire allocation? (area->size) > > If the memory is really virtually mapped, the only way to find out the > size of the object is to use find_vm_area() which can be relatively high > cost and no simple helper function is available. On the other hand, the > length is readily available in the callers. So passing the length > directly to the kvfree_sensitive is simpler. Also it lets us zero only the first N bytes of the allocation. That might be good for performance, if only the first N bytes of an M byte allocation are actually sensitive. I don't know if we have any such cases, but they could exist.