Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3918539ybb; Mon, 6 Apr 2020 19:17:48 -0700 (PDT) X-Google-Smtp-Source: APiQypLNIVczOpjvY2iUW51PIA9fCAKQb6jHfy8Fi69G2RyE5MX5BasAs+4R5E+bVX5+UFphfvxP X-Received: by 2002:a05:6830:3150:: with SMTP id c16mr18965786ots.251.1586225867899; Mon, 06 Apr 2020 19:17:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586225867; cv=none; d=google.com; s=arc-20160816; b=mPI4nDNf6x5ypskzkdM9FqlqNz+gD3Rhb36bc7H2Bz6xdCv7zIc4cqRAWaSdu09DFT TxPVEY6q5uAstlvqaTw2D19s5ipcn/irFC4/Gyo3R8mVkjvoVYVtA/17YnBDcf09Si+Z +96tUP8SEflfBoc3buKTkm/rcAUgT0Nz1BRvt5P6Uhb6UoakJQSHj08OiqjtXdFaQfC3 nIJrgNB1p3XXp3oOoW2pDnf5tSnpMZWeW8vKwhEROVzMOXEPjyEUfgNs0XtnYv09yEPs 9UGqii0bL4H3RvLOhS02DFAMNknz1Dgpyqgzba+W4iXoQAgp5SjogVL2XoYsjNr6lEOl y45A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject :dkim-signature; bh=LE82/FZcwe9r070oAqWiHB0/uFWMlEacVo8VBYOQZEM=; b=b4LaFbvALmq1m0g4SHhizcpkP+Z471X8bWG1b1RtcPICI2C3NcAJZDPVwjowIH7oIg rzRA8lph3C7sJHEra5Ot/toOj+xgVGHIYDl3qg0RhxCnaLxnGsLWEb3FpRcB3y9lXWWM exuipmcXx0qBuEr+FQxjPg48kePFHDVmKdJkCD3A4sxYgRCvVBkZGYNiTt3fC1Qva71y xS+9eENQBYWGsOkbZBVBSHs0cbckFPdKYqyaOmG1gFPLZ7O+yuJIzlrbpXx7OejDAFyr D9b12gVRS9puIWQa3v67MHjdIsXLB2rcevlsrtnCnNwJz3LVX1aCLQCMdeaalnsDATOf nHSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YgK2DZga; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o85si599072ooo.19.2020.04.06.19.17.35; Mon, 06 Apr 2020 19:17:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YgK2DZga; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726550AbgDGCQQ (ORCPT + 99 others); Mon, 6 Apr 2020 22:16:16 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:50224 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726287AbgDGCQQ (ORCPT ); Mon, 6 Apr 2020 22:16:16 -0400 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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