Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1721095pxk; Fri, 4 Sep 2020 18:02:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy01r7Azz+sL65c5lUyVDGxngGkW6k8eibixanLPChCLdZCEXFvIaJoEogP/ehfN4/dSTnA X-Received: by 2002:a17:906:17c5:: with SMTP id u5mr9963691eje.453.1599267766871; Fri, 04 Sep 2020 18:02:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599267766; cv=none; d=google.com; s=arc-20160816; b=ONOgiOrKzby4y/JHTpGltv4Fa9XV4QX6S+71oZOhzj4fqa5YJi3Wfdyiqz7+Ca7ewf r6nrdbfJLIXBq92Ip+89xrDbqvaF2EQhLYEsAGFFx0GUdqhBpEZGAD0ytUFcPC8dQt2f OKSWVm2rImMhd6oizkLuGuzU/+1hBFRf7flhciksbXBR8vt3bjb0aSkKmiaNpwQyf05p HNY+/Je9V8jhy0K6HyoZVhnSqpkl7JJ+hObv5r4zxOsWX0/TAQDe/NnaG6Nya8fxZ1po nKFnB0MfZ68r+xKT7yxo2jllTLXvtw1J/+eXrInmBm7uME4CJH2gZ2I3t0bWkSGiKwvs 8LIg== 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:from:references:cc:to:subject:dkim-signature; bh=kNBOhuEZgb11jNzVin4vW86ugipWCO8mBgoUlZPaXM0=; b=rNu/H7n1c8+FZ4ofzueIzUpfmSz3xHvygjnCd8NJpp8oBRYnB28C0WZCth4OQcOPjh RJsWUCd3R7A8ybiSmYqA1pGdwhjsflsC0Z8ZcBJYWRm5gY1fCD72KB32LYZE5jkQE49w sEwnZapFwOeSs0ebqGhuBcDozV0mjYPxcEPdedQ6rtnI4xEqCI+XFfHJTDMdHnPwRIuh j6KuL/qLcIU6Y/cde04aKHVuX+cMvKNP1WxqAL/EoKRmEv9ck7ZCrqqjhlHretR3tcrM fj+XvzHhD6RYqvviQnKk4Y3PA2dKXuv+5U9pEjdAT10UOmMPdsvdGrUHdp0k0rKeDFYs RGaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IkxsdXwT; 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 b18si4958533edu.100.2020.09.04.18.02.09; Fri, 04 Sep 2020 18:02:46 -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=IkxsdXwT; 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 S1726948AbgIEA6H (ORCPT + 99 others); Fri, 4 Sep 2020 20:58:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:24826 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726456AbgIEA6H (ORCPT ); Fri, 4 Sep 2020 20:58:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599267485; 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=kNBOhuEZgb11jNzVin4vW86ugipWCO8mBgoUlZPaXM0=; b=IkxsdXwT0E8dXDxp6LpfRFDVF2z1iHeySk7ZleXv8ltsQJWl35SZG6kIpe7lFOJuBpyZXT PliItNj4I2CTzVkQS0ZBjTZEcxU8rsZI0xs/DVieS934oIy/PFvhNVygm/TFU46woVCT0X LEgit3NYteOotnm+mkCn+ZzEab/Ucrg= 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-537-uF9XtEZ6OV2bD6ZgtSTOhQ-1; Fri, 04 Sep 2020 20:58:01 -0400 X-MC-Unique: uF9XtEZ6OV2bD6ZgtSTOhQ-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 EEF211DDEA; Sat, 5 Sep 2020 00:57:59 +0000 (UTC) Received: from [10.10.65.66] (ovpn-65-66.rdu2.redhat.com [10.10.65.66]) by smtp.corp.redhat.com (Postfix) with ESMTP id ADE3460C05; Sat, 5 Sep 2020 00:57:57 +0000 (UTC) Subject: Re: [PATCH 2/3] integrity: Move import of MokListRT certs to a separate routine To: Andy Shevchenko Cc: Linux Kernel Mailing List , linux-efi , Platform Driver , linux-security-module , Ard Biesheuvel , James Morris , "Serge E. Hallyn" , Kees Cook , Mimi Zohar , Borislav Petkov , Peter Jones , David Howells , Prarit Bhargava References: <20200826034455.28707-1-lszubowi@redhat.com> <20200826034455.28707-3-lszubowi@redhat.com> From: Lenny Szubowicz Message-ID: Date: Fri, 4 Sep 2020 20:57:57 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit 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 9/2/20 3:55 AM, Andy Shevchenko wrote: > On Wed, Aug 26, 2020 at 6:45 AM Lenny Szubowicz wrote: >> >> Move the loading of certs from the UEFI MokListRT into a separate >> routine to facilitate additional MokList functionality. >> >> There is no visible functional change as a result of this patch. >> Although the UEFI dbx certs are now loaded before the MokList certs, >> they are loaded onto different key rings. So the order of the keys >> on their respective key rings is the same. > > ... > >> /* >> + * load_moklist_certs() - Load MokList certs >> + * >> + * Returns: Summary error status >> + * >> + * Load the certs contained in the UEFI MokListRT database into the >> + * platform trusted keyring. >> + */ > > Hmm... Is it intentionally kept out of kernel doc format? Yes. Since this is a static local routine, I thought that it shouldn't be included by kerneldoc. But I wanted to generally adhere to the kernel doc conventions for a routine header. To that end, in V2 I move the "Return:" section to come after the short description. > >> +static int __init load_moklist_certs(void) >> +{ >> + efi_guid_t mok_var = EFI_SHIM_LOCK_GUID; >> + void *mok = NULL; >> + unsigned long moksize = 0; >> + efi_status_t status; >> + int rc = 0; > > Redundant assignment (see below). > >> + /* Get MokListRT. It might not exist, so it isn't an error >> + * if we can't get it. >> + */ >> + mok = get_cert_list(L"MokListRT", &mok_var, &moksize, &status); > >> + if (!mok) { > > Why not positive conditional? Sometimes ! is hard to notice. > >> + if (status == EFI_NOT_FOUND) >> + pr_debug("MokListRT variable wasn't found\n"); >> + else >> + pr_info("Couldn't get UEFI MokListRT\n"); >> + } else { >> + rc = parse_efi_signature_list("UEFI:MokListRT", >> + mok, moksize, get_handler_for_db); >> + if (rc) >> + pr_err("Couldn't parse MokListRT signatures: %d\n", rc); >> + kfree(mok); > > kfree(...) > if (rc) > ... > return rc; > > And with positive conditional there will be no need to have redundant > 'else' followed by additional level of indentation. > >> + } > >> + return rc; > > return 0; > >> +} > > P.S. Yes, I see that the above was in the original code, so, consider > my comments as suggestions to improve the code. > I agree that your suggestions improve the code. I've incorporated this into V2. -Lenny.