]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
crypto: ccp - Fix incorrect payload size calculation in psp_poulate_hsti()
authorYunseong Kim <ysk@kzalloc.com>
Wed, 3 Sep 2025 13:16:43 +0000 (22:16 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 13 Nov 2025 20:37:21 +0000 (15:37 -0500)
[ Upstream commit 2b0dc40ac6ca16ee0c489927f4856cf9cd3874c7 ]

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>> ---
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/crypto/ccp/hsti.c

index 1b39a4fb55c061bf6fa7030bb47b8da4f324ad3a..0e6b73b55dbf7e2376f220ecfa282d05967806b3 100644 (file)
@@ -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)