From patchwork Mon Mar 29 21:42:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 410867 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp3949494jai; Mon, 29 Mar 2021 14:42:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZVSy6aEkOOrW5tgexpdH9fG4gJqdC8UNZ8V+UBh47pGntZEc4Oc0oRaEoaPZwQTjfAlQd X-Received: by 2002:a17:907:2809:: with SMTP id eb9mr29648390ejc.204.1617054165110; Mon, 29 Mar 2021 14:42:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617054165; cv=none; d=google.com; s=arc-20160816; b=bAzW4m113/vbBRKkSCcW1mtyWESNUSRRk81LqtexhHFLByHZKHMBP2jnzt6fzZviqK AkrNkN9A3PUKOs3IMNJn40oYVH9yi9TwbMMB/NqjVUY7CzmO3QfNTbyTKsx5m+I/6xTb ylpEKF6d8LnGloBli8B0b6FhWb7yy0pY+ruEYyQh/1YE9aeFMGFpUpqb7rcsbXGQKPh9 l63M884eUh7k0qe0DdiAE+gusp5QQn8eowUscDfnyVKUwTEMo1maBQLK5YTO2tjwMNwy B/X9X76m/9s8xw3iUm34kf61xoR9wny0tnZW+TXk+GnfZPD3TDAbeUh4AQ/fKkHqOcdS yDyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=MJe7ub/df+1zV1QW05BIYA7ZKBCIUjjMNZwyc3QEORo=; b=beiPDRk2KMokIUgFd/HXJi51pre501usytZkbJs423OuzJVEUnaIF4UER6ceKiOCMb +Gk7N99wwoXrfWuhtrmRcVxjhE5vhTmK5KIsGOqZiRpKql1w4RSsMJ8rIDPOTXbraiQf cMSwxFg3s+2aNSJ5F+D9cWCX80VHNv9j4iSBEPwvbjuZFAvBZuTsNCnCFYCARx3pR2sN 87e3IEBTiaUsNurnQySp1chxocCf+Ijcl5CRCWyKdmCw/M1iBVceXNmHEcwAECr9LEF/ TGnGTk/HgmeMLufTHUcrAZ5d/1BeWCWMgxeKYDuz+srGcr5qgn9nFbtix1LC0snIWuMs R9PQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Iw2+Gx7a; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id kg8si14163256ejc.642.2021.03.29.14.42.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Mar 2021 14:42:45 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Iw2+Gx7a; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 04EA682898; Mon, 29 Mar 2021 23:42:43 +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="Iw2+Gx7a"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 73EA5828B3; Mon, 29 Mar 2021 23:42:42 +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 autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) (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 ADEE782759 for ; Mon, 29 Mar 2021 23:42:39 +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=ilias.apalodimas@linaro.org Received: by mail-wm1-x333.google.com with SMTP id r10-20020a05600c35cab029010c946c95easo7327739wmq.4 for ; Mon, 29 Mar 2021 14:42:39 -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:mime-version :content-transfer-encoding; bh=MJe7ub/df+1zV1QW05BIYA7ZKBCIUjjMNZwyc3QEORo=; b=Iw2+Gx7aoI+kDIUxUoblEdkm6HN9u8LGPSEgvfnKaFw6nx8XR9wcs5hz3QflJDKzPw U97KfEdrVq5jEDJLC1io4qCptiyuQgqipRjC+ITqM5biWUpsIxIYNC9AdKatN4iQcbHs +EvUAV3GsrsuCcv+mDnFoENemAQbl5r6uw/eSc8dvyvsz3fofdYe3HlxjkUA5ZMVPLbK QkuFi9+bPqAI1Q4pT1ayad+pWrbMjONv3vO8oLgguy8/V5QeeXO5nBWunnqkueRDmL3D rGcoqzVvSkpAnWXw6ZLbgmf/ph87LD/7Dy7sXdi6JmmVCSzvohmtIFaIGW/kcTpxmFP2 GRGg== 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:mime-version :content-transfer-encoding; bh=MJe7ub/df+1zV1QW05BIYA7ZKBCIUjjMNZwyc3QEORo=; b=fw8VFwUjxeJ63zSk1diXSO5Mo/g3V/Y2zcTBi8kTtKt7xtctU3kVAnTA48lXNYZ2iu Gcz2JeuKANWEZRJU6af/0Fkln+g7g25uRTHI4dlghrJ5SjdYEgaBtDHzHqxPd62CeO56 O+r9lhzX6OZbA86y5z25wakrWMhpU4QMtRT6flftvUwPmIJxhiOi3D375gll/EZzD8L1 WZWwIz8/qOhsGNSv/su877NHOTXotIXSyptNKyLINFFkO6tMfzbkHN8DYgHRDYgHPJIz 2kz2sVdcVqCMJiKcPXXad6BqDSt0GYpHF3WuzieRS2iWY7hziLIwjNmxYURErCcVJMVy TeNQ== X-Gm-Message-State: AOAM531hGSE77bKb1r2Wr7WJ+K2670JLEG0p05b9FNBXxylFe/Fgbl1X EOG/y8oZudzLDyLLN3Lwco5f7g== X-Received: by 2002:a1c:498b:: with SMTP id w133mr918076wma.134.1617054159133; Mon, 29 Mar 2021 14:42:39 -0700 (PDT) Received: from apalos.home ([2a02:587:464a:c916:2e56:dcff:fe9a:8f06]) by smtp.gmail.com with ESMTPSA id u8sm31645641wrr.42.2021.03.29.14.42.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Mar 2021 14:42:38 -0700 (PDT) From: Ilias Apalodimas To: xypron.glpk@gmx.de, mr.nuke.me@gmail.com Cc: Ilias Apalodimas , Alexander Graf , u-boot@lists.denx.de Subject: [PATCH v2] efi_loader: Change ptr arithmetics tcg eventlog buffer Date: Tue, 30 Mar 2021 00:42:36 +0300 Message-Id: <20210329214236.51769-1-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.31.0 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.4 at phobos.denx.de X-Virus-Status: Clean Although ptr arithmetics are allowed with extensions in gcc, they are not allowed by the C spec. So switch to (void *)(uintptr_t) instead Signed-off-by: Ilias Apalodimas --- changes since v1: Switch over to uintptr as Alex suggested lib/efi_loader/efi_tcg2.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) -- 2.31.0 Reviewed-by: Alexandru Gagniuc diff --git a/lib/efi_loader/efi_tcg2.c b/lib/efi_loader/efi_tcg2.c index 09046844c723..ed86a220fbd6 100644 --- a/lib/efi_loader/efi_tcg2.c +++ b/lib/efi_loader/efi_tcg2.c @@ -176,13 +176,14 @@ static efi_status_t tcg2_agile_log_append(u32 pcr_index, u32 event_type, struct tpml_digest_values *digest_list, u32 size, u8 event[]) { - void *log = event_log.buffer + event_log.pos; + void *log = (void *)((uintptr_t)event_log.buffer + event_log.pos); size_t pos; int i; u32 event_size; if (event_log.get_event_called) - log = event_log.final_buffer + event_log.final_pos; + log = (void *)((uintptr_t)event_log.final_buffer + + event_log.final_pos); /* * size refers to the length of event[] only, we need to check against @@ -197,24 +198,24 @@ static efi_status_t tcg2_agile_log_append(u32 pcr_index, u32 event_type, put_unaligned_le32(pcr_index, log); pos = offsetof(struct tcg_pcr_event2, event_type); - put_unaligned_le32(event_type, log + pos); + put_unaligned_le32(event_type, (void *)((uintptr_t)log + pos)); pos = offsetof(struct tcg_pcr_event2, digests); /* count */ - put_unaligned_le32(digest_list->count, log + pos); + put_unaligned_le32(digest_list->count, (void *)((uintptr_t)log + pos)); pos += offsetof(struct tpml_digest_values, digests); for (i = 0; i < digest_list->count; i++) { u16 hash_alg = digest_list->digests[i].hash_alg; u8 *digest = (u8 *)&digest_list->digests[i].digest; - put_unaligned_le16(hash_alg, log + pos); + put_unaligned_le16(hash_alg, (void *)((uintptr_t)log + pos)); pos += offsetof(struct tpmt_ha, digest); - memcpy(log + pos, digest, alg_to_len(hash_alg)); + memcpy((void *)((uintptr_t)log + pos), digest, alg_to_len(hash_alg)); pos += alg_to_len(hash_alg); } - put_unaligned_le32(size, log + pos); + put_unaligned_le32(size, (void *)((uintptr_t)log + pos)); pos += sizeof(u32); /* tcg_pcr_event2 event_size*/ - memcpy(log + pos, event, size); + memcpy((void *)((uintptr_t)log + pos), event, size); pos += size; /* make sure the calculated buffer is what we checked against */ @@ -1046,7 +1047,7 @@ static efi_status_t efi_init_event_log(void) put_unaligned_le32(0, &event_header->pcr_index); put_unaligned_le32(EV_NO_ACTION, &event_header->event_type); memset(&event_header->digest, 0, sizeof(event_header->digest)); - ret = create_specid_event(dev, event_log.buffer + sizeof(*event_header), + ret = create_specid_event(dev, (void *)((uintptr_t)event_log.buffer + sizeof(*event_header)), &spec_event_size); if (ret != EFI_SUCCESS) goto out;