[PATCH v2 0/2] KVM: x86: Fix UBSAN bool warnings in module parameters

Gal Pressman posted 2 patches 1 month, 1 week ago
arch/x86/kvm/mmu/mmu.c  |  5 +++++
arch/x86/kvm/svm/avic.c | 13 ++++++++++++-
2 files changed, 17 insertions(+), 1 deletion(-)
[PATCH v2 0/2] KVM: x86: Fix UBSAN bool warnings in module parameters
Posted by Gal Pressman 1 month, 1 week ago
Several KVM module parameters use int to support a special -1 (auto)
value, but rely on param_get_bool() for the sysfs getter.
When userspace reads these parameters before the auto value is resolved,
param_get_bool() interprets the int as a bool, triggering UBSAN "load of
value 255 is not a valid value for type '_Bool'" warnings.

Fix both instances by implementing getter functions that handle the -1
case before falling through to param_get_bool().

Changelog -
v1->v2: https://lore.kernel.org/all/20260210064621.1902269-1-gal@nvidia.com/
* Show auto avic as 'N' (Naveen)

Gal Pressman (2):
  KVM: SVM: Fix UBSAN warning when reading avic parameter
  KVM: x86/mmu: Fix UBSAN warning when reading nx_huge_pages parameter

 arch/x86/kvm/mmu/mmu.c  |  5 +++++
 arch/x86/kvm/svm/avic.c | 13 ++++++++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)

-- 
2.52.0
Re: [PATCH v2 0/2] KVM: x86: Fix UBSAN bool warnings in module parameters
Posted by Sean Christopherson 1 month ago
On Wed, 25 Feb 2026 16:50:48 +0200, Gal Pressman wrote:
> Several KVM module parameters use int to support a special -1 (auto)
> value, but rely on param_get_bool() for the sysfs getter.
> When userspace reads these parameters before the auto value is resolved,
> param_get_bool() interprets the int as a bool, triggering UBSAN "load of
> value 255 is not a valid value for type '_Bool'" warnings.
> 
> Fix both instances by implementing getter functions that handle the -1
> case before falling through to param_get_bool().
> 
> [...]

Applied patch 1 to kvm-x86 svm, and patch 2 to kvm-x86 mmu.  Thanks!

[1/2] KVM: SVM: Fix UBSAN warning when reading avic parameter
      https://github.com/kvm-x86/linux/commit/2b1a59f7ef96
[2/2] KVM: x86/mmu: Fix UBSAN warning when reading nx_huge_pages parameter
      https://github.com/kvm-x86/linux/commit/1450ab08108c

--
https://github.com/kvm-x86/linux/tree/next