Skip to contentSkip to conversation

crypto: ccp: Fix incorrect payload size calculation in psp_poulate_hsti()

PATCH In review Yunseong Kim 3 participants 3 messages Sep 3, 2025 – Sep 13, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: ccp: Fix incorrect payload size calculation in psp_poulate_hsti()

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.

---
 drivers/crypto/ccp/hsti.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/ccp/hsti.c +1 -1
index 1b39a4fb55c0..0e6b73b55dbf 100644
@@ -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)
Signature · 1 line
2.51.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · 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.

Quoted 16 lines
  drivers/crypto/ccp/hsti.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/ccp/hsti.c +1 -1
index 1b39a4fb55c0..0e6b73b55dbf 100644
@@ -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)
maintainer
#2 lore raw
In reply to Yunseong Kim
Quoted 7 lines · 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.

Quoted 7 lines

Fix this by using sizeof(*req) to correctly calculate the size of the struct hsti_request.

---
 drivers/crypto/ccp/hsti.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch applied. Thanks.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt