From: sashiko-bot@kernel.org
To: "Gregory Price" <gourry@gourry.net>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH 3/5] KVM: guest_memfd: bind backing memory to a NUMA node at creation
Date: Wed, 02 Sep 2026 20:00:41 +0000 [thread overview]
Message-ID: <20260902200041.8E0DA1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260902194657.79075-4-gourry@gourry.net>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Critical] Validation of flag-gated syscall parameters outside their flag gate breaks ABI compatibility for existing userspace applications.
--
commit 431a72230c55ac38f268a69346922d329c315246
Author: Gregory Price <gourry@gourry.net>
KVM: guest_memfd: bind backing memory to a NUMA node at creation
This commit introduces the bind node flag to kvm_gmem_create, allowing a
guest_memfd to be bound to a specific NUMA node at creation time. It
replaces a portion of the reserved fields in struct kvm_create_guest_memfd
with node and pad fields. The node policy is then applied to the
underlying inode.
> diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h
> index ac2d77d149635..8d3ae7e2ead8e 100644
> --- a/include/uapi/linux/kvm.h
> +++ b/include/uapi/linux/kvm.h
[ ... ]
> @@ -1658,11 +1658,14 @@ struct kvm_memory_attributes {
> #define KVM_CREATE_GUEST_MEMFD _IOWR(KVMIO, 0xd4, struct kvm_create_guest_memfd)
> #define GUEST_MEMFD_FLAG_MMAP (1ULL << 0)
> #define GUEST_MEMFD_FLAG_INIT_SHARED (1ULL << 1)
> +#define GUEST_MEMFD_FLAG_BIND_NODE (1ULL << 2)
>
> struct kvm_create_guest_memfd {
> __u64 size;
> __u64 flags;
> - __u64 reserved[6];
> + __u32 node;
> + __u32 pad;
> + __u64 reserved[5];
> };
>
> #define KVM_PRE_FAULT_MEMORY _IOWR(KVMIO, 0xd5, struct kvm_pre_fault_memory)
[ ... ]
> diff --git a/virt/kvm/guest_memfd.c b/virt/kvm/guest_memfd.c
> index 625e62e1a0318..dc9f071dd969b 100644
> --- a/virt/kvm/guest_memfd.c
> +++ b/virt/kvm/guest_memfd.c
[ ... ]
> @@ -593,6 +624,7 @@ int kvm_gmem_create(struct kvm *kvm, struct kvm_create_guest_memfd *args)
> {
> loff_t size = args->size;
> u64 flags = args->flags;
> + int node = NUMA_NO_NODE;
>
> if (flags & ~kvm_gmem_get_supported_flags(kvm))
> return -EINVAL;
> @@ -600,7 +632,15 @@ int kvm_gmem_create(struct kvm *kvm, struct kvm_create_guest_memfd *args)
> if (size <= 0 || !PAGE_ALIGNED(size))
> return -EINVAL;
>
> - return __kvm_gmem_create(kvm, size, flags);
> + if (flags & GUEST_MEMFD_FLAG_BIND_NODE) {
> + if (args->pad || args->node >= MAX_NUMNODES)
> + return -EINVAL;
> + node = args->node;
> + } else if (args->node || args->pad) {
> + return -EINVAL;
> + }
[Severity: Critical]
Could this strict check in kvm_gmem_create() on args->node and args->pad
cause a regression for existing userspace applications?
Since these fields were previously part of the ignored reserved array,
legacy binaries invoking the ioctl without the new bind node flag might
leave these stack or register slots uninitialized. Enforcing them to be
zero outside of the flag gate could cause these legacy calls to
unexpectedly fail with an invalid argument error.
> +
> + return __kvm_gmem_create(kvm, size, flags, node);
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260902194657.79075-1-gourry@gourry.net?part=3
next prev parent reply other threads:[~2026-09-02 20:00 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-02 19:46 [PATCH 0/5] KVM: guest_memfd: bind backing memory to a NUMA node Gregory Price
2026-09-02 19:46 ` [PATCH 1/5] mm/mempolicy: add mempolicy_create() Gregory Price
2026-09-02 19:46 ` [PATCH 2/5] mm/mempolicy: add mpol_set_shared_policy_range() Gregory Price
2026-09-02 19:46 ` [PATCH 3/5] KVM: guest_memfd: bind backing memory to a NUMA node at creation Gregory Price
2026-09-02 20:00 ` sashiko-bot [this message]
2026-09-02 19:46 ` [PATCH 4/5] selftests: KVM: guest_memfd: let the gmem_test() harness bind a node Gregory Price
2026-09-02 19:59 ` sashiko-bot
2026-09-02 19:46 ` [PATCH 5/5] selftests: KVM: guest_memfd: test GUEST_MEMFD_FLAG_BIND_NODE Gregory Price
2026-09-02 20:04 ` sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260902200041.8E0DA1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=gourry@gourry.net \
--cc=kvm@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox