From: Balbir Singh Date: Sun, 17 May 2020 00:27:39 +0000 Subject: Re: [PATCH v3] mm: Add kvfree_sensitive() for freeing sensitive data objects Message-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit List-Id: References: <20200407200318.11711-1-longman@redhat.com> <1158ff38-c65d-379f-8ae7-6f507d9fc8dd@gmail.com> <20200514120018.GA16070@bombadil.infradead.org> In-Reply-To: <20200514120018.GA16070@bombadil.infradead.org> To: Matthew Wilcox 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 On 14/5/20 10:00 pm, Matthew Wilcox wrote: > 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. > May be, but the callers of the API have to be explictly aware of the contract. I don't disagree with you on what you've said, but I was referring to the intent of freeing sensitive data vs the turn around time for doing so. Balbir Singh.