lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <86frxx6gtt.wl-maz@kernel.org>
Date: Mon, 12 Feb 2024 11:51:42 +0000
From: Marc Zyngier <maz@...nel.org>
To: Arnd Bergmann <arnd@...nel.org>
Cc: Paolo Bonzini <pbonzini@...hat.com>,
	David Matlack <dmatlack@...gle.com>,
	Arnd Bergmann <arnd@...db.de>,
	Sean Christopherson <seanjc@...gle.com>,
	Fuad Tabba <tabba@...gle.com>,
	Shaoqin Huang <shahuang@...hat.com>,
	Chao Peng <chao.p.peng@...ux.intel.com>,
	kvm@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] KVM: fix kvm_mmu_memory_cache allocation warning

On Mon, 12 Feb 2024 11:24:10 +0000,
Arnd Bergmann <arnd@...nel.org> wrote:
> 
> From: Arnd Bergmann <arnd@...db.de>
> 
> gcc-14 notices that the arguments to kvmalloc_array() are mixed up:
> 
> arch/x86/kvm/../../../virt/kvm/kvm_main.c: In function '__kvm_mmu_topup_memory_cache':
> arch/x86/kvm/../../../virt/kvm/kvm_main.c:424:53: error: 'kvmalloc_array' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Werror=calloc-transposed-args]
>   424 |                 mc->objects = kvmalloc_array(sizeof(void *), capacity, gfp);
>       |                                                     ^~~~
> arch/x86/kvm/../../../virt/kvm/kvm_main.c:424:53: note: earlier argument should specify number of elements, later size of each element
> 
> The code still works correctly, but the incorrect order prevents the compiler
> from properly tracking the object sizes.
> 
> Fixes: 837f66c71207 ("KVM: Allow for different capacities in kvm_mmu_memory_cache structs")
> Signed-off-by: Arnd Bergmann <arnd@...db.de>
> ---
>  virt/kvm/kvm_main.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index 8f03b56dafbd..4c48f61cae35 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -421,7 +421,7 @@ int __kvm_mmu_topup_memory_cache(struct kvm_mmu_memory_cache *mc, int capacity,
>  		if (WARN_ON_ONCE(!capacity))
>  			return -EIO;
>  
> -		mc->objects = kvmalloc_array(sizeof(void *), capacity, gfp);
> +		mc->objects = kvmalloc_array(capacity, sizeof(void *), gfp);
>  		if (!mc->objects)
>  			return -ENOMEM;
>  

Huh, well spotted GCC. And thanks Arnd for the fix.

Reviewed-by: Marc Zyngier <maz@...nel.org>

	M.

-- 
Without deviation from the norm, progress is not possible.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ