* [PATCH] crypto: ccp: Fix incorrect payload size calculation in psp_poulate_hsti()
@ 2025-09-03 13:16 Yunseong Kim
2025-09-03 14:54 ` Mario Limonciello
0 siblings, 1 reply; 2+ messages in thread
From: Yunseong Kim @ 2025-09-03 13:16 UTC (permalink / raw)
To: Herbert Xu, Mario Limonciello, Tom Lendacky, John Allen,
David S. Miller
Cc: linux-crypto, linux-kernel, Yunseong Kim
payload_size field of the request header is incorrectly calculated using
sizeof(req). Since 'req' is a pointer (struct hsti_request *), sizeof(req)
returns the size of the pointer itself (e.g., 8 bytes on a 64-bit system),
rather than the size of the structure it points to. This leads to an
incorrect payload size being sent to the Platform Security Processor (PSP),
potentially causing the HSTI query command to fail.
Fix this by using sizeof(*req) to correctly calculate the size of the
struct hsti_request.
Signed-off-by: Yunseong Kim <ysk@kzalloc.com>
---
drivers/crypto/ccp/hsti.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/crypto/ccp/hsti.c b/drivers/crypto/ccp/hsti.c
index 1b39a4fb55c0..0e6b73b55dbf 100644
--- a/drivers/crypto/ccp/hsti.c
+++ b/drivers/crypto/ccp/hsti.c
@@ -88,7 +88,7 @@ static int psp_poulate_hsti(struct psp_device *psp)
if (!req)
return -ENOMEM;
- req->header.payload_size = sizeof(req);
+ req->header.payload_size = sizeof(*req);
ret = psp_send_platform_access_msg(PSP_CMD_HSTI_QUERY, (struct psp_request *)req);
if (ret)
--
2.51.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] crypto: ccp: Fix incorrect payload size calculation in psp_poulate_hsti()
2025-09-03 13:16 [PATCH] crypto: ccp: Fix incorrect payload size calculation in psp_poulate_hsti() Yunseong Kim
@ 2025-09-03 14:54 ` Mario Limonciello
0 siblings, 0 replies; 2+ messages in thread
From: Mario Limonciello @ 2025-09-03 14:54 UTC (permalink / raw)
To: Yunseong Kim, Herbert Xu, Tom Lendacky, John Allen,
David S. Miller
Cc: linux-crypto, linux-kernel
On 9/3/25 8:16 AM, Yunseong Kim wrote:
> payload_size field of the request header is incorrectly calculated using
> sizeof(req). Since 'req' is a pointer (struct hsti_request *), sizeof(req)
> returns the size of the pointer itself (e.g., 8 bytes on a 64-bit system),
> rather than the size of the structure it points to. This leads to an
> incorrect payload size being sent to the Platform Security Processor (PSP),
> potentially causing the HSTI query command to fail.
>
> Fix this by using sizeof(*req) to correctly calculate the size of the
> struct hsti_request.
>
> Signed-off-by: Yunseong Kim <ysk@kzalloc.com>
Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>> ---
> drivers/crypto/ccp/hsti.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/crypto/ccp/hsti.c b/drivers/crypto/ccp/hsti.c
> index 1b39a4fb55c0..0e6b73b55dbf 100644
> --- a/drivers/crypto/ccp/hsti.c
> +++ b/drivers/crypto/ccp/hsti.c
> @@ -88,7 +88,7 @@ static int psp_poulate_hsti(struct psp_device *psp)
> if (!req)
> return -ENOMEM;
>
> - req->header.payload_size = sizeof(req);
> + req->header.payload_size = sizeof(*req);
>
> ret = psp_send_platform_access_msg(PSP_CMD_HSTI_QUERY, (struct psp_request *)req);
> if (ret)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-09-03 14:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-03 13:16 [PATCH] crypto: ccp: Fix incorrect payload size calculation in psp_poulate_hsti() Yunseong Kim
2025-09-03 14:54 ` Mario Limonciello
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).