Re: [PATCH] KVM: selftests: Check guest memfd validity with flags
From: Ackerley Tng
Date: Wed May 13 2026 - 13:15:32 EST
Sean Christopherson <seanjc@xxxxxxxxxx> writes:
>
> [...snip...]
>
> But, Ackerley and Fuad want give kvm_vm_release() the same treatment[*], at which
> point there's no good reason not to be paranoid. I want to do that in a dedicated
> patch though, and harden "everything" in one shot. I'll send something like the
> below.
>
Thanks!
> [*] https://lore.kernel.org/all/20260511113759.610924-3-tabba@xxxxxxxxxx
>
> diff --git tools/testing/selftests/kvm/lib/kvm_util.c tools/testing/selftests/kvm/lib/kvm_util.c
> index 2a76eca7029d..2476167252a1 100644
> --- tools/testing/selftests/kvm/lib/kvm_util.c
> +++ tools/testing/selftests/kvm/lib/kvm_util.c
> @@ -737,6 +737,12 @@ userspace_mem_region_find(struct kvm_vm *vm, u64 start, u64 end)
> return NULL;
> }
>
> +static void kvm_free_fd(int *fd)
Not where the line is drawn between "free" vs "release" in the
selftests, just wanted to draw your attention to the two terms we can
pick the correct term.
> +{
> + kvm_close(*fd);
> + *fd = -1;
> +}
> +
>
> [...snip...]
>