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.4 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 864C0C47254 for ; Wed, 6 May 2020 01:30:08 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1EF9E20735 for ; Wed, 6 May 2020 01:30:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Zi/yPZiA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1EF9E20735 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 6D5478E0005; Tue, 5 May 2020 21:30:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 685B08E0003; Tue, 5 May 2020 21:30:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 572C28E0005; Tue, 5 May 2020 21:30:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0166.hostedemail.com [216.40.44.166]) by kanga.kvack.org (Postfix) with ESMTP id 3C02D8E0003 for ; Tue, 5 May 2020 21:30:07 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id E303F824CA22 for ; Wed, 6 May 2020 01:30:06 +0000 (UTC) X-FDA: 76784563212.13.bee71_5840b2227a707 X-HE-Tag: bee71_5840b2227a707 X-Filterd-Recvd-Size: 4698 Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by imf16.hostedemail.com (Postfix) with ESMTP for ; Wed, 6 May 2020 01:30:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588728605; 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=Zi/yPZiAk5fn0dhOyjKcuLgyd5a1LhKTxiLcDTahcCoBd/XTxo0sB8l3HPtCvIriTwrq3w E3jIJKGID9WhOv/gCfswL+jd5Imh6Q3v+c9IbyhT8A6/azi3SvjtyQQ1AOdrwrdQIBPVQw VKIRec+/IuCbBAdvvGHDvwDr29l17Uo= 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 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 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