From: Paolo Bonzini <pbonzini@redhat.com>
To: Sean Christopherson <seanjc@google.com>
Cc: Vitaly Kuznetsov <vkuznets@redhat.com>,
Wanpeng Li <wanpengli@tencent.com>,
Jim Mattson <jmattson@google.com>, Joerg Roedel <joro@8bytes.org>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] KVM: x86: Use ERR_PTR_USR() to return -EFAULT as a __user pointer
Date: Fri, 4 Feb 2022 09:44:38 +0100 [thread overview]
Message-ID: <3874109c-d086-f657-6452-0cab7fc0c29e@redhat.com> (raw)
In-Reply-To: <20220202005157.2545816-1-seanjc@google.com>
On 2/2/22 01:51, Sean Christopherson wrote:
> Use ERR_PTR_USR() when returning -EFAULT from kvm_get_attr_addr(), sparse
> complains about implicitly casting the kernel pointer from ERR_PTR() into
> a __user pointer.
>
>>> arch/x86/kvm/x86.c:4342:31: sparse: sparse: incorrect type in return expression
> (different address spaces) @@ expected void [noderef] __user * @@ got void * @@
> arch/x86/kvm/x86.c:4342:31: sparse: expected void [noderef] __user *
> arch/x86/kvm/x86.c:4342:31: sparse: got void *
>>> arch/x86/kvm/x86.c:4342:31: sparse: sparse: incorrect type in return expression
> (different address spaces) @@ expected void [noderef] __user * @@ got void * @@
> arch/x86/kvm/x86.c:4342:31: sparse: expected void [noderef] __user *
> arch/x86/kvm/x86.c:4342:31: sparse: got void *
>
> No functional change intended.
>
> Fixes: 56f289a8d23a ("KVM: x86: Add a helper to retrieve userspace address from kvm_device_attr")
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Sean Christopherson <seanjc@google.com>
> ---
> arch/x86/kvm/x86.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index fec3dd4f0718..b533aab98172 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -90,6 +90,8 @@
> u64 __read_mostly kvm_mce_cap_supported = MCG_CTL_P | MCG_SER_P;
> EXPORT_SYMBOL_GPL(kvm_mce_cap_supported);
>
> +#define ERR_PTR_USR(e) ((void __user *)ERR_PTR(e))
> +
> #define emul_to_vcpu(ctxt) \
> ((struct kvm_vcpu *)(ctxt)->vcpu)
>
> @@ -4340,7 +4342,7 @@ static inline void __user *kvm_get_attr_addr(struct kvm_device_attr *attr)
> void __user *uaddr = (void __user*)(unsigned long)attr->addr;
>
> if ((u64)(unsigned long)uaddr != attr->addr)
> - return ERR_PTR(-EFAULT);
> + return ERR_PTR_USR(-EFAULT);
> return uaddr;
> }
>
> @@ -11684,8 +11686,6 @@ void kvm_arch_sync_events(struct kvm *kvm)
> kvm_free_pit(kvm);
> }
>
> -#define ERR_PTR_USR(e) ((void __user *)ERR_PTR(e))
> -
> /**
> * __x86_set_memory_region: Setup KVM internal memory slot
> *
>
> base-commit: b2d2af7e5df37ee3a9ba6b405bdbb7691a5c2dfc
Queued, thanks.
Paolo
prev parent reply other threads:[~2022-02-04 8:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-02 0:51 Sean Christopherson
2022-02-04 8:44 ` Paolo Bonzini [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3874109c-d086-f657-6452-0cab7fc0c29e@redhat.com \
--to=pbonzini@redhat.com \
--cc=jmattson@google.com \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=seanjc@google.com \
--cc=vkuznets@redhat.com \
--cc=wanpengli@tencent.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®