public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/2] platform/x86/amd/pmf: Do not use readl() for policy buffer access
@ 2024-02-27 14:54 Armin Wolf
  2024-02-27 14:55 ` [PATCH v2 2/2] platform/x86/amd/pmf: Fix possible out-of-bound memory accesses Armin Wolf
  0 siblings, 1 reply; 6+ messages in thread
From: Armin Wolf @ 2024-02-27 14:54 UTC (permalink / raw)
  To: Shyam-sundar.S-k
  Cc: hdegoede, ilpo.jarvinen, platform-driver-x86, linux-kernel

The policy buffer is allocated using normal memory allocation
functions, so readl() should not be used on it.

Compile-tested only.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
---
Changes since v1:
- get the full dword instead of only 8 bits
---
 drivers/platform/x86/amd/pmf/tee-if.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/x86/amd/pmf/tee-if.c b/drivers/platform/x86/amd/pmf/tee-if.c
index 16973bebf55f..b3491268b6a0 100644
--- a/drivers/platform/x86/amd/pmf/tee-if.c
+++ b/drivers/platform/x86/amd/pmf/tee-if.c
@@ -249,8 +249,8 @@ static int amd_pmf_start_policy_engine(struct amd_pmf_dev *dev)
 	u32 cookie, length;
 	int res;

-	cookie = readl(dev->policy_buf + POLICY_COOKIE_OFFSET);
-	length = readl(dev->policy_buf + POLICY_COOKIE_LEN);
+	cookie = *(u32 *)(dev->policy_buf + POLICY_COOKIE_OFFSET);
+	length = *(u32 *)(dev->policy_buf + POLICY_COOKIE_LEN);

 	if (cookie != POLICY_SIGN_COOKIE || !length)
 		return -EINVAL;
--
2.39.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-02-29 12:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-27 14:54 [PATCH v2 1/2] platform/x86/amd/pmf: Do not use readl() for policy buffer access Armin Wolf
2024-02-27 14:55 ` [PATCH v2 2/2] platform/x86/amd/pmf: Fix possible out-of-bound memory accesses Armin Wolf
2024-02-27 15:45   ` Ilpo Järvinen
2024-02-28 11:16     ` Shyam Sundar S K
2024-02-28 20:48       ` Armin Wolf
2024-02-29 12:05         ` Ilpo Järvinen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox