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=-2.5 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 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 536DCC2BA1E for ; Mon, 6 Apr 2020 17:59:06 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1D9B620678 for ; Mon, 6 Apr 2020 17:59:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ipA2jILl" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1D9B620678 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C41D18E0010; Mon, 6 Apr 2020 13:59:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BF10D8E000D; Mon, 6 Apr 2020 13:59:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AE0278E0010; Mon, 6 Apr 2020 13:59:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0170.hostedemail.com [216.40.44.170]) by kanga.kvack.org (Postfix) with ESMTP id 91C748E000D for ; Mon, 6 Apr 2020 13:59:05 -0400 (EDT) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 5759818C9 for ; Mon, 6 Apr 2020 17:59:05 +0000 (UTC) X-FDA: 76678191450.16.flag33_89877eaae4c28 X-HE-Tag: flag33_89877eaae4c28 X-Filterd-Recvd-Size: 5041 Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by imf21.hostedemail.com (Postfix) with ESMTP for ; Mon, 6 Apr 2020 17:59:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1586195944; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kMP/HJwuG1cl3KldZk1VTYBaQUCRZ/n/2fyeOu3dz1k=; b=ipA2jILlNOHNOVYwI/KJTYu3RTBVZdvO2DEtAkheEcNMoM1CWp+mgUMRFPr6bHPE+Gyg2m LEaDAJgtRXaNmC8BsGirp+QdPXhshlFUVo5GJRSTV7Zi8Tnd7EKkRYsaQvCDrBTiT/ZSSi RKREGBxkfujJYg+9VzEqLpLKEoVDOlw= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-317-IIrjofGuObiNKxRVYGeJNw-1; Mon, 06 Apr 2020 13:58:58 -0400 X-MC-Unique: IIrjofGuObiNKxRVYGeJNw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D93AD8024E6; Mon, 6 Apr 2020 17:58:56 +0000 (UTC) Received: from llong.remote.csb (ovpn-115-20.rdu2.redhat.com [10.10.115.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id C763019C4F; Mon, 6 Apr 2020 17:58:54 +0000 (UTC) Subject: Re: [PATCH] mm: Add kvfree_sensitive() for freeing sensitive data objects To: Joe Perches , David Howells Cc: Andrew Morton , Jarkko Sakkinen , James Morris , "Serge E. Hallyn" , linux-mm@kvack.org, keyrings@vger.kernel.org, linux-kernel@vger.kernel.org, Linus Torvalds References: <20200406023700.1367-1-longman@redhat.com> <319765.1586188840@warthog.procyon.org.uk> From: Waiman Long Organization: Red Hat Message-ID: <19cbf3b1-2c3f-dd0f-a5c6-69ca3f77dd68@redhat.com> Date: Mon, 6 Apr 2020 13:58:54 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Content-Language: en-US X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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 4/6/20 12:10 PM, Joe Perches wrote: > On Mon, 2020-04-06 at 17:00 +0100, David Howells wrote: >> Joe Perches wrote: >> >>>> This patch introduces a new kvfree_sensitive() for freeing those >>>> sensitive data objects allocated by kvmalloc(). The relevnat places >>>> where kvfree_sensitive() can be used are modified to use it. >>> Why isn't this called kvzfree like the existing kzfree? >> To quote Linus: >> >> We have a function for clearing sensitive information: it's called >> "memclear_explicit()", and it's about forced (explicit) clearing even >> if the data might look dead afterwards. >> >> The other problem with that function is the name: "__kvzfree()" is not >> a useful name for this function. We use the "__" format for internal >> low-level helpers, and it generally means that it does *less* than the >> full function. This does more, not less, and "__" is not following any >> sane naming model. >> >> So the name should probably be something like "kvfree_sensitive()" or >> similar. Or maybe it could go even further, and talk about _why_ it's >> sensitive, and call it "kvfree_cleartext()" or something like that. >> >> Because the clearing is really not what even matters. It might choose >> other patterns to overwrite things with, but it might do other things >> too, like putting special barriers for data leakage (or flags to tell >> return-to-user-mode to do so). >> >> And yes, kzfree() isn't a good name either, and had that same >> memset(), but at least it doesn't do the dual-underscore mistake. >> >> Including some kzfree()/crypto people explicitly - I hope we can get >> away from this incorrect and actively wrong pattern of thinking that >> "sensitive data should be memset(), and then we should add a random >> 'z' in the name somewhere to 'document' that". > Thanks. > > While I agree with Linus about the __ prefix, > the z is pretty common and symmetric to all > the zalloc uses. > > And if _sensitive is actually used, it'd be > good to do a s/kzfree/kfree_sensitive/ one day > sooner than later. > > I have actually been thinking about that. I saw a couple of cases in the crypto code where a memzero_explicit() is followed by kfree(). Those can be replaced by kfree_sensitive. Cheers, Longman