Fix a bug where freeing a VM attempts to close an invalid guest_memfd instance
due to checking if a u32 value is non-negative. Then harden closing of fds in
kvm_util by invalidating fds after they are closed, e.g. so that freeing an fd
multiple times will fail instead of silently closing the wrong file.
Sean Christopherson (2):
KVM: selftests: Cast guest_memfd fd to a signed int when checking for
>= 0
KVM: selftests: Add and use kvm_free_fd() to harden against fd goofs
.../selftests/kvm/include/kvm_syscalls.h | 6 +++++
tools/testing/selftests/kvm/lib/kvm_util.c | 25 +++++++++----------
2 files changed, 18 insertions(+), 13 deletions(-)
base-commit: 66939c1603bd5579e63278f9dc72cba5b79da9b5
--
2.54.0.794.g4f17f83d09-goog