Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp1341398ybj; Tue, 5 May 2020 18:32:22 -0700 (PDT) X-Google-Smtp-Source: APiQypK/3BKLl4nyvUP81w6bcFynKiFLzoPgmCy7YyZEd+YZ20W+LWkj4cC+ZSYSbLNoUNr5XGAe X-Received: by 2002:a17:907:9481:: with SMTP id dm1mr5553726ejc.268.1588728742844; Tue, 05 May 2020 18:32:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588728742; cv=none; d=google.com; s=arc-20160816; b=HOr4G4PgpKNlXIgs/NB5snX2/gHpaubIdzSbKEvmGCyRj2hk4nFwn5cBIt62PQpPYe osgvZdSY+dJJyYYxZe+OqkTbcRqKUpFqjxn/y6JBhAVnFBG4Flh9TC92Fuupd6I5H2RZ nAo9C5s6tLxB8LFkPLA/wpuIgelh7eyZDa2GWgiWcuT3JIgyAsosh2yqeNQhsQAubQUQ dbWZTS9JheP+aF64yzbpdYePhzxJRRPpD1Qfj/pSYeulC0hBLPY8BUkmkcSy2zz8bKws hmBr5YE6SVeKs6iGOSOyC0GWAH2a7emIOyXxsOWsHUoCbfnJOmnM74Ef/Bl/qBvIwkHa fyAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject :dkim-signature; bh=Ry4pmb+CcaKZ10VLlnYCO1BgZINspRaHQ7kzZcdb4LU=; b=L0lBdV/GmILtZakjNGTDTd3r0uVseAxrgl3ipX3C4skkGu+h6WsvCCn0gUhi9TURb5 O5JdNfzlVQzroGYV68GZ7qWU1QFQSTubxfeuV4ZHgcwhbN9U8609jIRrl2axBf/rMVoa 0zw1oAUXe1CBcg4EmP5Ele7aayt7/TbLI7jlIF+3wEPolb8PX3WrExzIIVHrvcIvALb0 b6sPaaJHCyDJEOoIx+den/4pXHQ6LLi5XL3j4xu7uRiPHwP8ihfgNgbPU20JjmtC1/oO IEJj+wc40FlBYYVk2hNZnn2PlVanh9nCC7h+/39pfNb9XdTbmV5Z/7wP8oGME03bKo+f O6rA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cJA7Fgi4; 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 bx8si182575edb.25.2020.05.05.18.31.59; Tue, 05 May 2020 18:32:22 -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=cJA7Fgi4; 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 S1729728AbgEFBaK (ORCPT + 99 others); Tue, 5 May 2020 21:30:10 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:30195 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728356AbgEFBaJ (ORCPT ); Tue, 5 May 2020 21:30:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588728607; 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=Ry4pmb+CcaKZ10VLlnYCO1BgZINspRaHQ7kzZcdb4LU=; b=cJA7Fgi47MX0lfIXnTn5keSZZXVYzM4S4wQp68XgIMgWHtv7HczDOQrvMIi4XZSAoIHcvY t3xcVSKzPyYWiO+dx/fCtZwTs+t+TYhwk6A9NsEi+2FayDoAlaEG71JoBK/MwmszuWaZ5I XZdF+kcmrKy6K1gOoviZjDiW3KPZmd0= 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-11-MH1bKyHUMeGmmSWOVXDl2w-1; Tue, 05 May 2020 21:30:03 -0400 X-MC-Unique: MH1bKyHUMeGmmSWOVXDl2w-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E3BB78014D7; Wed, 6 May 2020 01:30:01 +0000 (UTC) Received: from llong.remote.csb (ovpn-113-126.rdu2.redhat.com [10.10.113.126]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6AC8F5C1BD; Wed, 6 May 2020 01:29:59 +0000 (UTC) Subject: Re: [PATCH v3] mm: Add kvfree_sensitive() for freeing sensitive data objects To: Andrew Morton , David Howells Cc: 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: <694135.1586290793@warthog.procyon.org.uk> <20200407200318.11711-1-longman@redhat.com> <694340.1586290917@warthog.procyon.org.uk> <20200505133521.eb8901d0b92e09452191ab49@linux-foundation.org> From: Waiman Long Organization: Red Hat Message-ID: <3be0ef1d-fe7f-6b02-d9c0-c6b750fd94f3@redhat.com> Date: Tue, 5 May 2020 21:29:58 -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: <20200505133521.eb8901d0b92e09452191ab49@linux-foundation.org> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/5/20 4:35 PM, Andrew Morton wrote: > On Tue, 07 Apr 2020 21:21:57 +0100 David Howells = wrote: > >> David Howells wrote: >> >>>> if (unlikely(key_data)) >>>> - __kvzfree(key_data, key_data_len); >>>> + kvfree_sensitive(key_data, key_data_len); >>> I think the if-statement is redundant. >> Ah - I see that you explicitly wanted to keep it. > Why's that? There is a comment above it: =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 /* =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 * The key may change (u= nlikely) in between 2 consecutive =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 * __keyctl_read_key() c= alls. In this case, we reallocate =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 * a larger buffer and r= edo the key read when =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 * key_data_len < ret <=3D= buflen. =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 */ =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 if (ret > key_data_len) { =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 if= (unlikely(key_data)) =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0 __kvzfree(key_data, key_data_len); key_data will be defined only if the unlikely case that the key increase=20 in length between the 2 consecutive __keyctl_read_key() call and we have=20 to enlarge the buffer and read the key again. I want to keep the=20 unlikely() macro to emphasize the fact that this condition should not=20 happen. >> There's a good chance it'll get janitored at some point. > Indeed. Perhaps add a few little comments to explain the reasoning and > to keep the janitorial fingers away? > I can reword the comment to make it more explicit and send a v4 if you=20 think the current comment is not clear enough. Cheers, Longman