From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ADDEDC2D0EC for ; Wed, 8 Apr 2020 00:37:26 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 733CF206A1 for ; Wed, 8 Apr 2020 00:37:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 733CF206A1 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=perches.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 09D9A8E0005; Tue, 7 Apr 2020 20:37:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 04CFC8E0001; Tue, 7 Apr 2020 20:37:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EA5428E0005; Tue, 7 Apr 2020 20:37:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0146.hostedemail.com [216.40.44.146]) by kanga.kvack.org (Postfix) with ESMTP id D57958E0001 for ; Tue, 7 Apr 2020 20:37:25 -0400 (EDT) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 8A059A8DA for ; Wed, 8 Apr 2020 00:37:25 +0000 (UTC) X-FDA: 76682824050.30.owner35_23b28a8d7e82e X-HE-Tag: owner35_23b28a8d7e82e X-Filterd-Recvd-Size: 3711 Received: from smtprelay.hostedemail.com (smtprelay0100.hostedemail.com [216.40.44.100]) by imf09.hostedemail.com (Postfix) with ESMTP for ; Wed, 8 Apr 2020 00:37:25 +0000 (UTC) Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay05.hostedemail.com (Postfix) with ESMTP id EC792180240BA; Wed, 8 Apr 2020 00:37:24 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-HE-Tag: cough31_235fb3002fe5a X-Filterd-Recvd-Size: 2519 Received: from XPS-9350.home (unknown [47.151.136.130]) (Authenticated sender: joe@perches.com) by omf09.hostedemail.com (Postfix) with ESMTPA; Wed, 8 Apr 2020 00:37:22 +0000 (UTC) Message-ID: Subject: Re: [PATCH v3] mm: Add kvfree_sensitive() for freeing sensitive data objects From: Joe Perches To: Matthew Wilcox , Waiman Long Cc: 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 Date: Tue, 07 Apr 2020 17:35:24 -0700 In-Reply-To: <20200407221255.GM21484@bombadil.infradead.org> References: <20200407200318.11711-1-longman@redhat.com> <0fe5dcaf078be61ef21c7f18b750c5dc14c69dd7.camel@perches.com> <67c51b03-192c-3006-5071-452f351aee67@redhat.com> <20200407221255.GM21484@bombadil.infradead.org> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.34.1-2 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, 2020-04-07 at 15:12 -0700, Matthew Wilcox wrote: > 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. I would really doubt it as the allocation of sensitive data should generally be separate. Also, a similar argument could apply to kzfree/kfree_sensitive.