Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3203767ybz; Sun, 3 May 2020 20:26:52 -0700 (PDT) X-Google-Smtp-Source: APiQypJp8hzHfl7dfOzSCPfv2hoPZ6U46QjF6k/mF2T/2H0z0cFr4kdvMJceTR+s1dSISJ6rIhjT X-Received: by 2002:a17:906:a2d3:: with SMTP id by19mr13431300ejb.370.1588562812055; Sun, 03 May 2020 20:26:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588562812; cv=none; d=google.com; s=arc-20160816; b=fZdzWE6hTIcLynkjf3sWcLt4Ydk2M18anzZO+IJDefzBK+UlIxbwAanv/rLz+teI4F 3eYELAnLO+M5mCDTCEQzm2wy9wRxoLW50n8Sj82j7nKsLkRuMCVZEosY3+y82GFBrdRt yqJqeIidFUOpvYT4Me7Tj1aA907Lcyp5mn3UlxYGm9Lv1pvlH4ZlcF01LpR08mphL9uC /71X1kGRuTEGJ+U6xOnnDa8LBRsvFzZztOtPyz4cB80/aVp77BfDQN3enE8Vz29L+aOG qUZ0UZ/fyOFzx7+2Q+JwvCAWprdQOcTOMatAtaiKSeAXmw8mpAePGbW//UIAj+xFr7mQ UCaw== 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=gF7rcvELgQd39eUzjQBEmRMoEPlsByjPKGkWb8q9nQI=; b=gIVsijlRzF+Wx77r3nIagrrDfmChTP1R5NVLLZNGB6YRbbEEwn4yxP8vvR+2K2HLIZ V5AXJStTVq5HSepm6L01R0XvsdzBkxI+dPhzU4mxlHkiap4Y+2qD2yKVQhMK267N7Gl9 DdRgXk4fRP9N3T8OkP3hTXrpZbWTgam8SfB9BiI9itcYW4GtBY2xcbKz68JzMUuiqjQK y8fvzU2l2c+QT3UXUvh6d2QGJk4ll8iR+dwG5kdnyaqJArvaFhlPvtKOH6SAlMoLwJj5 wGSN3KhrZcwjVYHuStxYnHNSyKncFQ4F+8TUyqm/KC7yaythpGg7dy+gCGBFDPNQquHn fyxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=R4djuxqb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id f9si5942475edq.572.2020.05.03.20.26.27; Sun, 03 May 2020 20:26:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=R4djuxqb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1726625AbgEDC5d (ORCPT + 99 others); Sun, 3 May 2020 22:57:33 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:44505 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726404AbgEDC5d (ORCPT ); Sun, 3 May 2020 22:57:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588561052; 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=gF7rcvELgQd39eUzjQBEmRMoEPlsByjPKGkWb8q9nQI=; b=R4djuxqbl4X70PFFn7aCBoT4Mv2HXBAhF/csEQl+eaXkoKcSyeGfJo0fhGqQ/k7C8PMXZF 70Ptay5Zko7xuGsQj5QSHIjRmjPM+dpuAACABwU4xvLWLc8lv3HyC8oukbvWs0XDNOmMoh xg4RQa3M7rL4TxcSp2+AmVm3R2JCrnQ= 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-124-aDfPBMSwPrKk4IKjU-8VMQ-1; Sun, 03 May 2020 22:57:28 -0400 X-MC-Unique: aDfPBMSwPrKk4IKjU-8VMQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5EC57107ACCA; Mon, 4 May 2020 02:57:26 +0000 (UTC) Received: from llong.remote.csb (ovpn-112-227.rdu2.redhat.com [10.10.112.227]) by smtp.corp.redhat.com (Postfix) with ESMTP id EA5B860BF3; Mon, 4 May 2020 02:57:23 +0000 (UTC) Subject: Re: [PATCH v3] mm: Add kvfree_sensitive() for freeing sensitive data objects To: Andrew Morton Cc: Eric Biggers , 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 , Matthew Wilcox , David Rientjes References: <20200407200318.11711-1-longman@redhat.com> <20200501232224.GC915@sol.localdomain> From: Waiman Long Organization: Red Hat Message-ID: <82fbc32f-3f9e-b876-b998-7714e8597988@redhat.com> Date: Sun, 3 May 2020 22:57:23 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <20200501232224.GC915@sol.localdomain> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/1/20 7:22 PM, Eric Biggers wrote: > On Tue, Apr 07, 2020 at 04:03:18PM -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. >> >> 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. >> >> Fixes: 4f0882491a14 ("KEYS: Avoid false positive ENOMEM error on key read") >> Suggested-by: Linus Torvalds >> Signed-off-by: Waiman Long > Looks good, feel free to add: > > Reviewed-by: Eric Biggers > > (I don't really buy the argument that the compiler could compile away memset() > before kvfree(). But I agree with using memzero_explicit() anyway to make the > intent explicit.) > > I don't see this patch in linux-next yet. Who is planning to take this patch? > Presumably David through the keyrings tree, or Andrew through mm? > > - Eric > Andrew, would you mind taking this patch into the mm-tree? Thanks, Longman