All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] crypto: ccp - Limit memory allocation in SEV_GET_ID2 ioctl
@ 2022-12-14 20:20 Peter Gonda
  2022-12-15 10:05 ` Herbert Xu
  0 siblings, 1 reply; 12+ messages in thread
From: Peter Gonda @ 2022-12-14 20:20 UTC (permalink / raw)
  To: herbert
  Cc: Peter Gonda, Andy Nguyen, David Rientjes, stable, linux-kernel,
	linux-crypto, John Allen, Thomas . Lendacky

Currently userspace can ask for any uint32 size allocation for the
SEV_GET_ID2. Limit this allocation size to the max physically
contiguously allocation: MAX_ORDER.

Reported-by: Andy Nguyen <theflow@google.com>
Suggested-by: David Rientjes <rientjes@google.com>
Signed-off-by: Peter Gonda <pgonda@google.com>
Cc: stable@vger.kernel.org
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: linux-kernel@vger.kernel.org
Cc: linux-crypto@vger.kernel.org
Cc: John Allen <john.allen@amd.com>
Cc: Thomas.Lendacky <thomas.lendacky@amd.com>

---
 drivers/crypto/ccp/sev-dev.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c
index 06fc7156c04f..5c16c4406764 100644
--- a/drivers/crypto/ccp/sev-dev.c
+++ b/drivers/crypto/ccp/sev-dev.c
@@ -878,6 +878,10 @@ static int sev_ioctl_do_get_id2(struct sev_issue_cmd *argp)
 	if (copy_from_user(&input, (void __user *)argp->data, sizeof(input)))
 		return -EFAULT;
 
+	/* Max length that can be allocated physically contiguously */
+	if (get_order(input.length) >= MAX_ORDER)
+		return -ENOMEM;
+
 	input_address = (void __user *)input.address;
 
 	if (input.address && input.length) {
-- 
2.39.0.rc1.256.g54fd8350bd-goog


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2023-01-06 15:20 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-14 20:20 [PATCH] crypto: ccp - Limit memory allocation in SEV_GET_ID2 ioctl Peter Gonda
2022-12-15 10:05 ` Herbert Xu
2022-12-28  1:42   ` David Rientjes
2022-12-28  8:49     ` Herbert Xu
2022-12-30 22:01       ` David Rientjes
2022-12-30 22:18         ` [patch] crypto: ccp - Avoid page allocation failure warning for SEV_GET_ID2 David Rientjes
2023-01-03 14:39           ` Tom Lendacky
2023-01-03 23:18             ` David Rientjes
2023-01-04 14:40               ` Tom Lendacky
2023-01-05  1:49                 ` David Rientjes
2023-01-05 15:37                   ` Tom Lendacky
2023-01-06 15:18           ` Herbert Xu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.