All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] KVM: selftests: Fix three leaked resources
@ 2026-12-01  9:06 Gokul K
  2026-12-01  9:06 ` [PATCH 1/3] KVM: selftests: Close /dev/sev when an SEV VM is released Gokul K
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Gokul K @ 2026-12-01  9:06 UTC (permalink / raw)
  To: Sean Christopherson, Paolo Bonzini, kvm
  Cc: Shuah Khan, linux-kselftest, Peter Gonda, Jing Zhang,
	linux-kernel

Three resource leaks found while auditing the selftests, all on paths
that run normally rather than on error paths.

Patches 1 and 2 are both /dev/sev descriptors. The first is the one that
matters: every SEV VM opens /dev/sev into vm->arch.sev_fd and nothing
ever closes it, because x86 never provided a kvm_arch_vm_release(). arm64 is the only architecture
that overrides that hook today. The second is sev_init2_tests.c opening
the device once per KVM_SEV_INIT2 ioctl and keeping none of them.

Patch 3 is unrelated to SEV: kvm_binary_stats_test.c loses the id string
when the kernel reports no stats descriptors.

Compile-tested and run on an AMD host without SEV, so patches 1 and 2
are compile-tested only - the paths they touch need an SEV-capable
machine. kvm_binary_stats_test passes 4/4 before and after patch 3. Nine
x86 selftests were run with and without patch 1, which touches the
library every x86 test links, and gave identical results:
set_memory_region_test and x86/state_test fail both ways, as this host's
kernel is older than the tree, and x86/kvm_clock_test skips.

Gokul K (3):
  KVM: selftests: Close /dev/sev when an SEV VM is released
  KVM: selftests: Close the SEV fd opened for each KVM_SEV_INIT2 ioctl
  KVM: selftests: Free the stats id string when no stats are defined

 tools/testing/selftests/kvm/kvm_binary_stats_test.c | 1 +
 tools/testing/selftests/kvm/lib/x86/processor.c     | 6 ++++++
 tools/testing/selftests/kvm/x86/sev_init2_tests.c   | 5 ++++-
 3 files changed, 11 insertions(+), 1 deletion(-)

-- 
2.51.0



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

end of thread, other threads:[~2026-12-01  9:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01  9:06 [PATCH 0/3] KVM: selftests: Fix three leaked resources Gokul K
2026-12-01  9:06 ` [PATCH 1/3] KVM: selftests: Close /dev/sev when an SEV VM is released Gokul K
2026-12-01  9:06 ` [PATCH 2/3] KVM: selftests: Close the SEV fd opened for each KVM_SEV_INIT2 ioctl Gokul K
2026-12-01  9:06 ` [PATCH 3/3] KVM: selftests: Free the stats id string when no stats are defined Gokul K
2026-12-01  9:12   ` sashiko-bot

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.