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: <c8c37018-8681-458f-96b7-82bae88ebcd3@xen.org>
Date: Thu, 22 Feb 2024 10:14:38 +0000
From: Paul Durrant <xadimgnik@...il.com>
To: Arnd Bergmann <arnd@...nel.org>, David Woodhouse <dwmw2@...radead.org>,
 Sean Christopherson <seanjc@...gle.com>, Paolo Bonzini <pbonzini@...hat.com>
Cc: Arnd Bergmann <arnd@...db.de>, Thomas Gleixner <tglx@...utronix.de>,
 Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
 Dave Hansen <dave.hansen@...ux.intel.com>, x86@...nel.org,
 "H. Peter Anvin" <hpa@...or.com>, Jens Axboe <axboe@...nel.dk>,
 Jan Kara <jack@...e.cz>, Christian Brauner <brauner@...nel.org>,
 kvm@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] KVM: x86/xen: fix 32-bit pointer cast

On 22/02/2024 10:03, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@...db.de>
> 
> shared_info.hva is a 64-bit variable, so casting to a pointer causes
> a warning in 32-bit builds:
> 
> arch/x86/kvm/xen.c: In function 'kvm_xen_hvm_set_attr':
> arch/x86/kvm/xen.c:660:45: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
>    660 |                         void __user * hva = (void *)data->u.shared_info.hva;
> 
> Replace the cast with a u64_to_user_ptr() call that does the right thing.

Thanks Arnd. I'd just got a ping from kernel test robot for lack of 
__user qualifier in the cast 
(https://lore.kernel.org/oe-kbuild-all/202402221721.mhF8MNVh-lkp@intel.com/), 
which this should also fix.

> 
> Fixes: 01a871852b11 ("KVM: x86/xen: allow shared_info to be mapped by fixed HVA")
> Signed-off-by: Arnd Bergmann <arnd@...db.de>
> ---
>   arch/x86/kvm/xen.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 

Reviewed-by: Paul Durrant <paul@....org>

> diff --git a/arch/x86/kvm/xen.c b/arch/x86/kvm/xen.c
> index 01c0fd138d2f..8a04e0ae9245 100644
> --- a/arch/x86/kvm/xen.c
> +++ b/arch/x86/kvm/xen.c
> @@ -657,7 +657,7 @@ int kvm_xen_hvm_set_attr(struct kvm *kvm, struct kvm_xen_hvm_attr *data)
>   						     gfn_to_gpa(gfn), PAGE_SIZE);
>   			}
>   		} else {
> -			void __user * hva = (void *)data->u.shared_info.hva;
> +			void __user * hva = u64_to_user_ptr(data->u.shared_info.hva);
>   
>   			if (!PAGE_ALIGNED(hva) || !access_ok(hva, PAGE_SIZE)) {
>   				r = -EINVAL;


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ