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,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 BD78DC2BA1A for ; Tue, 7 Apr 2020 02:16:17 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8011A20768 for ; Tue, 7 Apr 2020 02:16:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="YgK2DZga" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8011A20768 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 1C90A8E0006; Mon, 6 Apr 2020 22:16:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 179C28E0001; Mon, 6 Apr 2020 22:16:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 069348E0006; Mon, 6 Apr 2020 22:16:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0168.hostedemail.com [216.40.44.168]) by kanga.kvack.org (Postfix) with ESMTP id DCD228E0001 for ; Mon, 6 Apr 2020 22:16:16 -0400 (EDT) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 9D619180AD806 for ; Tue, 7 Apr 2020 02:16:16 +0000 (UTC) X-FDA: 76679444352.12.plot18_70fb02d45bd12 X-HE-Tag: plot18_70fb02d45bd12 X-Filterd-Recvd-Size: 3541 Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by imf08.hostedemail.com (Postfix) with ESMTP for ; Tue, 7 Apr 2020 02:16:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1586225775; 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=LE82/FZcwe9r070oAqWiHB0/uFWMlEacVo8VBYOQZEM=; b=YgK2DZga/8V5rvUeFXtawT1mng6liKEhvDDO/YZCs7efblmgpaiPCfj0S/4BjphEd1ojLA uQKe4PHEjT/Q6UlTmAJdz1Om0AZNGWR3RErQdQFGarHYWM4CR8ktUxgRjBO+TrT86Riu/I jvISe8WxCWiyCISbfXzqEbaBqOSKqXQ= 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-336-isqSLhojMVqpZAgjGf2_FA-1; Mon, 06 Apr 2020 22:16:11 -0400 X-MC-Unique: isqSLhojMVqpZAgjGf2_FA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8249F1005514; Tue, 7 Apr 2020 02:16:09 +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 90BE6118F52; Tue, 7 Apr 2020 02:16:04 +0000 (UTC) Subject: Re: [PATCH v2] mm: Add kvfree_sensitive() for freeing sensitive data objects To: Joe Perches , Andrew Morton , David Howells , Jarkko Sakkinen , James Morris , "Serge E. Hallyn" Cc: linux-mm@kvack.org, keyrings@vger.kernel.org, linux-kernel@vger.kernel.org, Linus Torvalds , Matthew Wilcox , David Rientjes References: <20200406185827.22249-1-longman@redhat.com> From: Waiman Long Organization: Red Hat Message-ID: <1e4a6174-04be-6c05-fd6e-b43fefd317fc@redhat.com> Date: Mon, 6 Apr 2020 22:16:04 -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.79 on 10.5.11.11 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 3:38 PM, Joe Perches wrote: > On Mon, 2020-04-06 at 14:58 -0400, Waiman Long wrote: >> For kvmalloc'ed data object that contains sensitive information like >> cryptographic key, we need to make sure that the buffer is always >> cleared before freeing it. Using memset() alone for buffer clearing may >> not provide certainty as the compiler may compile it away. To be sure, >> the special memzero_explicit() has to be used. > [] >> extern void kvfree(const void *addr); >> +extern void kvfree_sensitive(const void *addr, size_t len); > Question: why should this be const? > > 2.1.44 changed kfree(void *) to kfree(const void *) but > I didn't find a particular reason why. I am just following the function prototype used by kvfree(). Even kzfree(const void *) use const. I can remove "const" if others agree. Cheers, Longman