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.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, 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 DA3BFC433E0 for ; Thu, 14 May 2020 12:00:30 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 99BE22065D for ; Thu, 14 May 2020 12:00:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="Ax2F6PvX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 99BE22065D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 1C2B2900144; Thu, 14 May 2020 08:00:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 14D068E0005; Thu, 14 May 2020 08:00:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F2F9A900144; Thu, 14 May 2020 08:00:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0063.hostedemail.com [216.40.44.63]) by kanga.kvack.org (Postfix) with ESMTP id D555A8E0005 for ; Thu, 14 May 2020 08:00:29 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 925BA5820 for ; Thu, 14 May 2020 12:00:29 +0000 (UTC) X-FDA: 76815182178.17.line06_5b8f4efd8bc4f X-HE-Tag: line06_5b8f4efd8bc4f X-Filterd-Recvd-Size: 2653 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf28.hostedemail.com (Postfix) with ESMTP for ; Thu, 14 May 2020 12:00:29 +0000 (UTC) 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=u6SWIOebjVUpIUlonH0OT1Sl21gs5ZK4m5BqWSJAe5U=; b=Ax2F6PvXgGBPCuj7csPD+sdscA aT3H6Piu24dzxMBTtpPx27gh9WwUx1cBSSDpkSwK+qVEMCOUH2anRxlOKeNh8vCXLmTuq7A5bYDXq br7S+5LFfOHIrt680JQQlgWvPF3+mbEIYRonaRApi5+QRHejilrf0WtGXr2dhbi5zok4UpG2zNSjl 9KyTrvxi3CB2SCJCfveGShY6gLo1KxIPvuXraP1bsDX9S05TAYUQmp42uYKRRJD961kyPETUOwvDf yB+EwYikwVanafb9mq8MwUlZR9kp50No99RiVKQ95DaduGhVhtfAAgN6chUrk53MpVgV2LaxRm2W0 GZYorDvA==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jZCXC-0005jW-5u; Thu, 14 May 2020 12:00:18 +0000 Date: Thu, 14 May 2020 05:00:18 -0700 From: Matthew Wilcox To: Balbir Singh Cc: Waiman Long , 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 , Joe Perches , David Rientjes Subject: Re: [PATCH v3] mm: Add kvfree_sensitive() for freeing sensitive data objects Message-ID: <20200514120018.GA16070@bombadil.infradead.org> References: <20200407200318.11711-1-longman@redhat.com> <1158ff38-c65d-379f-8ae7-6f507d9fc8dd@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1158ff38-c65d-379f-8ae7-6f507d9fc8dd@gmail.com> 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 Thu, May 14, 2020 at 09:00:40PM +1000, Balbir Singh wrote: > I wonder if the right thing to do is also to disable pre-emption, just so that the thread does not linger on with sensitive data. > > void kvfree_sensitive(const void *addr, size_t len) > { > preempt_disable(); > if (likely(!ZERO_OR_NULL_PTR(addr))) { > memzero_explicit((void *)addr, len); > kvfree(addr); > } > preempt_enable(); > } > EXPORT_SYMBOL(kvfree_sensitive); If it's _that_ sensitive then the caller should have disabled preemption. Because preemption could otherwise have occurred immediately before kvfree_sensitive() was called.