crypto: ccp - Avoid page allocation failure warning for SEV_GET_ID2
authorDavid Rientjes <rientjes@google.com>
Fri, 30 Dec 2022 22:18:46 +0000 (14:18 -0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 6 Jan 2023 09:15:47 +0000 (17:15 +0800)
commit91dfd98216d817ec5f1c55890bacb7b4fe9b068a
tree6aae08904de5593e79a05c909a865432cb25b592
parent8e613cec25196b51601dfac50c5bf229acd72bc6
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: d6112ea0cb34 ("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>
drivers/crypto/ccp/sev-dev.c