Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1496071pxb; Thu, 4 Mar 2021 12:54:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJwlySujnYeofYoTASRND6VZQUHrSbkEgvDvwWj6wZS94U0+j3OWZJTGc6ezrJwOGmmDqw2y X-Received: by 2002:a17:906:3b47:: with SMTP id h7mr6288013ejf.377.1614891277933; Thu, 04 Mar 2021 12:54:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614891277; cv=none; d=google.com; s=arc-20160816; b=PWXnxAFli2vhRVGWQ/zd3kuVez6sCM8jmEbvVRdu0IFvp3w29aPhYj7GZUysWF+ft1 AjV83j1lwekafknddkunM72vxJiKavI/k0nqOxgGj4XtlyTTznx1x7oZknJvDMiUy1OV D79gL3ezdDOAB0Lt7Dwh2fqn5RF8PubJPnbIT+Xf+We9042VL59hA/QjWiqh7iB/xpOw qfBEqzaA2yM4C6vlotY5AbYSuEJaqJrJ+c5G9OwCjX3+CE4O3CncwxwpV+FGY+edI5pV Yd0y9uqHytfEekeHWBTSuV+zvTDqZX8Ni5SEMGpeYZfwTGdY4JVc/oyPIM5t0M6qx0CV flWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=avwtux/GvrbGx0lLNSqm1+XjOqoBlTY/BhWpushvcQQ=; b=vQUNtzXyfymbK9fvfMwmKEI8F2u6f53LjWPuPZm+dVWqqbxNDx1xSmn0U6JM3vU3LY 7RmlJCtyw4iyFp6Ol4nkgBL8kzOJ+IU/JoinEwEAD7WzITzHnBrlGbKR5GHq2fo0EkMb E07DFlOimjWNUvu1xZQqBTT0URUrZ1W8BKTg8I/h1ujUKtkVQPmgv13wQOBj8Wy/LrF/ rGxqrvo5kbDtS5HMTS5VP/gXFkDAnX3jNe39dX2E9ZeLo7IrHQLqjsl6izCaBwAM8gA8 YzxJ/E/ly+Xm1zTBi/24qPI0khUfk2/NDEotQMEfec9ZiLUcAYb9dsXU/fYXFENf/xpt gH8Q== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d3si387952edq.276.2021.03.04.12.54.15; Thu, 04 Mar 2021 12:54:37 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357992AbhCCLhk (ORCPT + 99 others); Wed, 3 Mar 2021 06:37:40 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:13112 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352239AbhCCDaF (ORCPT ); Tue, 2 Mar 2021 22:30:05 -0500 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4DqzvL66Bdz16F4S; Wed, 3 Mar 2021 11:27:10 +0800 (CST) Received: from ubuntu1804.huawei.com (10.67.174.174) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.498.0; Wed, 3 Mar 2021 11:28:45 +0800 From: Li Huafei To: , , , , CC: , , , , , Subject: [PATCH] ima: Fix the error code for restoring the PCR value Date: Wed, 3 Mar 2021 11:28:24 +0800 Message-ID: <20210303032824.124112-1-lihuafei1@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.174.174] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In ima_restore_measurement_list(), hdr[HDR_PCR].data is pointing to a buffer of type u8, which contains the dumped 32-bit pcr value. Currently, only the least significant byte is used to restore the pcr value. We should convert hdr[HDR_PCR].data to a pointer of type u32 before fetching the value to restore the correct pcr value. Fixes: 47fdee60b47f ("ima: use ima_parse_buf() to parse measurements headers") Signed-off-by: Li Huafei --- security/integrity/ima/ima_template.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/security/integrity/ima/ima_template.c b/security/integrity/ima/ima_template.c index e22e510ae92d..4e081e650047 100644 --- a/security/integrity/ima/ima_template.c +++ b/security/integrity/ima/ima_template.c @@ -494,8 +494,8 @@ int ima_restore_measurement_list(loff_t size, void *buf) } } - entry->pcr = !ima_canonical_fmt ? *(hdr[HDR_PCR].data) : - le32_to_cpu(*(hdr[HDR_PCR].data)); + entry->pcr = !ima_canonical_fmt ? *(u32 *)(hdr[HDR_PCR].data) : + le32_to_cpu(*(u32 *)(hdr[HDR_PCR].data)); ret = ima_restore_measurement_entry(entry); if (ret < 0) break; -- 2.17.1