Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4623919pxj; Wed, 12 May 2021 09:28:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxmY+nx3NenA4fzVVfrDQiupKbv480flm4NdxnzovMH/yq6WFZN5B/mh7A10LBc6t1COeC0 X-Received: by 2002:a17:906:5210:: with SMTP id g16mr11415491ejm.116.1620836903646; Wed, 12 May 2021 09:28:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620836903; cv=none; d=google.com; s=arc-20160816; b=lOrWm+KhPldHjskLJAdaxrNFIz+6CVbA/odK65NbDYpPPro0h0UQ+xphGDultkh4pt OSjP2A0VDEhWjbS2o/szHofyMxzCdOicd20EjF3suBBJN3y9/abzBhTxAknxkftZlJwZ uN4Fbi0A+wYoP0EJZwZv/YWsSo6PqYvIKXJxHB1D4sgomWEyxdyQO9pc4i+2TWLWB4WI Aw2Hpllwh6thp1oPtaZp7zOJWEf3HUDFe6+ruvbx5gRQRLTYZuKhRqwXMDpmk4W0wmkd lrzEK+IvX+iVJVfBDO5wtc1+L67U42Oml2StdXjzBEJ6LtESOUf2UEtpy4sGLTL6Yl9Q YRuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/IhiZy4BMrJGoW5/XPWKh1SEYdS27FpsiQzT16GpYgs=; b=JZnt3d9BEC+AP/zoCU+6Zjdc4XaP9OK2slPaR4de9ZjCkMPiStArXcOQm3Iy/oIqqk vyqOYQ3LXpncWheySl2avnhJNuBy7euyKEJ1ndAh9irzI309h65sRBy/NUKzOCai/nfc xQjDIxBCXMi5Ebsov7kNGsIJOeHrgIR84ixzS8WnqTM4+rni8ZyimtPsDprUG5ehm9wt 9HnqY6YoA+Tqb26A3wKpQ+lu567hq3SMCQwXX0eRD+Y+zcT8cdtokvyuPaGsfjqkf1yJ uLj/WQ6ukjprSHlJVTFxOa8xSchYOPpY6u15/e3DULIzYI0e2MdQ1rO6qDRne/dGns/0 cYIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=SCt6EpST; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h20si79017edv.406.2021.05.12.09.28.00; Wed, 12 May 2021 09:28:23 -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=@linuxfoundation.org header.s=korg header.b=SCt6EpST; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240824AbhELQZn (ORCPT + 99 others); Wed, 12 May 2021 12:25:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:56710 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236335AbhELPho (ORCPT ); Wed, 12 May 2021 11:37:44 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1B91B61418; Wed, 12 May 2021 15:19:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620832756; bh=dsNNgavrktCZFFwGDrO2hZ2DwjhGRSmOigrFpMRTxPI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SCt6EpST3UXWH1M0Othjpgv1mNIJYfnCNKykqm5eh55oIfTFGSyuNclwk50VivO/D 6EcR+tYqQjRqn8GHiGzQE8y0TpjVVJWk+HkrGjWqbBUh2jbqNKHhoZuvFcoM3aikRS ATcvX8NI9d+zVuK0fGgqbAcd8C84plQfTTYglJrs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Li Huafei , Roberto Sassu , Mimi Zohar , Sasha Levin Subject: [PATCH 5.10 366/530] ima: Fix the error code for restoring the PCR value Date: Wed, 12 May 2021 16:47:56 +0200 Message-Id: <20210512144831.814041840@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144819.664462530@linuxfoundation.org> References: <20210512144819.664462530@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Li Huafei [ Upstream commit 7990ccafaa37dc6d8bb095d4d7cd997e8903fd10 ] 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 Reviewed-by: Roberto Sassu Signed-off-by: Mimi Zohar Signed-off-by: Sasha Levin --- 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 1e89e2d3851f..f83255a39e65 100644 --- a/security/integrity/ima/ima_template.c +++ b/security/integrity/ima/ima_template.c @@ -468,8 +468,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.30.2