Re: [PATCH] KVM: Remove the kvm debugfs directory if kvm_init() fails

From: Sean Christopherson

Date: Fri Aug 07 2026 - 19:06:29 EST


On Fri, Aug 07, 2026, Kai Huang wrote:
> > >
> > > The stale /sys/kernel/debug/kvm directory isn't just cosmetic: a
> > > subsequent attempt to load KVM makes debugfs_create_dir() fail with
> > > -EEXIST, after which kvm_debugfs_dir holds an ERR_PTR and all stat
> > > files are silently never created again. Worse, the leaked stat files
> > > reference file_operations and stat data that live in the KVM module; if
> > > the module is unloaded after the failed initialization, reading the
> > > stale files is a use-after-free.
> > >
> > >
>
> [...]
>
> >
> > Already posted (twice) and applied:
> >
> > https://lore.kernel.org/all/20260706095910.39798-1-leixiang@xxxxxxxxxx
>
> Do we need to "Cc: stable"? The one in your tree (commit db3a46e200df2) doesn't
> have that.

I was thinking "no", as I don't think it's likely to be problematic outside of
fuzzers and error injection, but I also wouldn't object if someone feels strongly
that it should be sent to LTS kernels.