Skip to content

Commit 9d6cc16

Browse files
committed
crypto: ccp - Avoid page allocation failure warning for SEV_GET_ID2
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2130715 Upstream Status: merged into herbert/cryptodev-2.6.git commit 91dfd98 Author: David Rientjes <rientjes@google.com> Date: Fri Dec 30 14:18:46 2022 -0800 crypto: ccp - Avoid page allocation failure warning for SEV_GET_ID2 For SEV_GET_ID2, the user provided length does not have a specified limitation because the length of the ID may change in the future. The kernel memory allocation, however, is implicitly limited to 4MB on x86 by the page allocator, otherwise the kzalloc() will fail. When this happens, it is best not to spam the kernel log with the warning. Simply fail the allocation and return ENOMEM to the user. Fixes: d6112ea ("crypto: ccp - introduce SEV_GET_ID2 command") Reported-by: Andy Nguyen <theflow@google.com> Reported-by: Peter Gonda <pgonda@google.com> Suggested-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: David Rientjes <rientjes@google.com> Acked-by: Tom Lendacky <thomas.lendacky@amd.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Vladis Dronov <vdronov@redhat.com>
1 parent eaf69b0 commit 9d6cc16

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

drivers/crypto/ccp/sev-dev.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,14 @@ static int sev_ioctl_do_get_id2(struct sev_issue_cmd *argp)
881881
input_address = (void __user *)input.address;
882882

883883
if (input.address && input.length) {
884-
id_blob = kzalloc(input.length, GFP_KERNEL);
884+
/*
885+
* The length of the ID shouldn't be assumed by software since
886+
* it may change in the future. The allocation size is limited
887+
* to 1 << (PAGE_SHIFT + MAX_ORDER - 1) by the page allocator.
888+
* If the allocation fails, simply return ENOMEM rather than
889+
* warning in the kernel log.
890+
*/
891+
id_blob = kzalloc(input.length, GFP_KERNEL | __GFP_NOWARN);
885892
if (!id_blob)
886893
return -ENOMEM;
887894

0 commit comments

Comments
 (0)