]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
virt: sev-guest: Replace GFP_KERNEL_ACCOUNT with GFP_KERNEL
authorNikunj A Dadhania <nikunj@amd.com>
Mon, 6 Jan 2025 12:46:22 +0000 (18:16 +0530)
committerBorislav Petkov (AMD) <bp@alien8.de>
Tue, 7 Jan 2025 09:26:20 +0000 (10:26 +0100)
Replace GFP_KERNEL_ACCOUNT with GFP_KERNEL in the sev-guest driver code.
GFP_KERNEL_ACCOUNT is typically used for accounting untrusted userspace
allocations. After auditing the sev-guest code, the following changes are
necessary:

  * snp_init_crypto(): Use GFP_KERNEL as this is a trusted device probe
    path.

Retain GFP_KERNEL_ACCOUNT in the following cases for robustness and
specific path requirements:

  * alloc_shared_pages(): Although all allocations are limited, retain
    GFP_KERNEL_ACCOUNT for future robustness.

  * get_report() and get_ext_report(): These functions are on the unlocked
    ioctl path and should continue using GFP_KERNEL_ACCOUNT.

Suggested-by: Borislav Petkov <bp@alien8.de>
Signed-off-by: Nikunj A Dadhania <nikunj@amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/r/20250106124633.1418972-3-nikunj@amd.com
drivers/virt/coco/sev-guest/sev-guest.c

index 62328d0b2cb6af9bd1af87b41fd16d914ac8c024..250ce92d816b23fe9486bfafa85470697ce3eb81 100644 (file)
@@ -141,7 +141,7 @@ static struct aesgcm_ctx *snp_init_crypto(u8 *key, size_t keylen)
 {
        struct aesgcm_ctx *ctx;
 
-       ctx = kzalloc(sizeof(*ctx), GFP_KERNEL_ACCOUNT);
+       ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
        if (!ctx)
                return NULL;