From patchwork Fri May 29 06:41:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1300445 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=b4W8TGvB; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49YFPY6dVtz9sPF for ; Fri, 29 May 2020 16:42:57 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6F35D81B69; Fri, 29 May 2020 08:42:41 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="b4W8TGvB"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E303C8196A; Fri, 29 May 2020 08:42:28 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id CAB2181767 for ; Fri, 29 May 2020 08:42:25 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pj1-x1041.google.com with SMTP id nu7so777505pjb.0 for ; Thu, 28 May 2020 23:42:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GSuaZUoDRPO1g3u7jBtBf47jvR8GtkiZM40s4k3FxxY=; b=b4W8TGvBeyuYdhIB9gIKDLiMLrbLRhwEFVFVyujarMlSHE6q4v6+EQhx6HlM7tvrKt JE8uQZ99MH9Q6jdwfY8vuD1syKhq9ojeah/uHWltn2wIe1hDgd3IltNsBM67EgUEkWMF APQKO1qatliZTVCDlKtHspJIP3wxMY86ViA7oueqy3FFrna7UMOTKxYHAxLQb8szRKuZ 9GZLiSOZ68/CPW9yROCCxiGO02Yy16t6QXjg9MUWGe4eDZswaq0jpIDM1iW7Y6g1kLqz jT3sQ9LsL5oKtmpiXnep11iE15jjCbeRlYGbiVk/rw2PFNG/NSQMPCFkxsYKpRo8guFA zwpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GSuaZUoDRPO1g3u7jBtBf47jvR8GtkiZM40s4k3FxxY=; b=NM7gsaj3dxSVvLJHc35rswxOYsS+OiOfJSftGKMSR+avSY61yMa0bPaYysLoZ7dqD9 3ldIGKz1sl6CfHJ2QAdbyce4NXVEhD61mpHv3kZZMR8nlR/0Xbs/pUp28kesu0hBhkVk lv7FIokkfUXWeEq5M16UmQXUFSG/V+hwY4wdHWY3vmaJeU3BxWPteBiKRfRUnP0keBYp PVWBqPfkaVaOEBuyvxz5sxo2lDzBisFdl63/p7trcep4pP78RVGtu/Vg15TpUErgJRqj sL0SZfyoVXvYI7kpIjhyhcfHsznOjMtPHVLtdE00YPaPIy1lPIbVf6KHmZZlAd+rkoNK E1lA== X-Gm-Message-State: AOAM5311vyD52CkOi521qN2Mt+9HjlsAwRHn2jRbWTtvDAd1kSH2r50Y LXDJikk9N02pgdRgRitriQNWBQ== X-Google-Smtp-Source: ABdhPJxT+Ijn+aUT3ZW2PY+3/cMnpedPig7II9nRgIbnEUl5nzSPKNjc2MSzWqL81Q+WzQPbtmpfiA== X-Received: by 2002:a17:902:c40c:: with SMTP id k12mr7266281plk.11.1590734543724; Thu, 28 May 2020 23:42:23 -0700 (PDT) Received: from localhost.localdomain (pdb6272d5.tkyea130.ap.so-net.ne.jp. [219.98.114.213]) by smtp.gmail.com with ESMTPSA id q5sm6483128pfl.199.2020.05.28.23.42.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 May 2020 23:42:23 -0700 (PDT) From: AKASHI Takahiro To: xypron.glpk@gmx.de, agraf@csgraf.de Cc: sughosh.ganu@linaro.org, mail@patrick-wildt.de, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH 04/13] efi_loader: signature: fix a size check against revocation list Date: Fri, 29 May 2020 15:41:21 +0900 Message-Id: <20200529064130.28332-5-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.25.2 In-Reply-To: <20200529064130.28332-1-takahiro.akashi@linaro.org> References: <20200529064130.28332-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de X-Virus-Status: Clean Since the size check against an entry in efi_search_siglist() is incorrect, this function will never find out a to-be-matched certificate and its associated revocation time in signature list. Signed-off-by: AKASHI Takahiro Reviewed-by: Heinrich Schuchardt --- lib/efi_loader/efi_signature.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/efi_loader/efi_signature.c b/lib/efi_loader/efi_signature.c index be6491c6e255..35f678de057e 100644 --- a/lib/efi_loader/efi_signature.c +++ b/lib/efi_loader/efi_signature.c @@ -432,10 +432,11 @@ static bool efi_search_siglist(struct x509_certificate *cert, * time64_t revocation_time; * }; */ - if ((sig_data->size == SHA256_SUM_LEN) && - !memcmp(sig_data->data, hash, SHA256_SUM_LEN)) { + if ((sig_data->size >= SHA256_SUM_LEN + sizeof(time64_t)) && + !memcmp(sig_data->data, msg, SHA256_SUM_LEN)) { memcpy(revoc_time, sig_data->data + SHA256_SUM_LEN, sizeof(*revoc_time)); + debug("revocation time: 0x%llx\n", *revoc_time); found = true; goto out; }