* [PATCH 1/1] mshv: Add __user attribute to argument passed to access_ok()
@ 2026-01-14 18:15 mhkelley58
2026-01-14 18:39 ` Nuno Das Neves
0 siblings, 1 reply; 3+ messages in thread
From: mhkelley58 @ 2026-01-14 18:15 UTC (permalink / raw)
To: kys, haiyangz, wei.liu, decui, longli, linux-hyperv; +Cc: linux-kernel
From: Michael Kelley <mhklinux@outlook.com>
access_ok() expects its first argument to have the __user attribute
since it is checking access to user space. Current code passes an
argument that lacks that attribute, resulting in 'sparse' flagging
the incorrect usage. However, the compiler doesn't generate code
based on the attribute, so there's no actual bug.
In the interest of general correctness and to avoid noise from sparse,
add the __user attribute. No functional change.
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202512141339.791TCKnB-lkp@intel.com/
Signed-off-by: Michael Kelley <mhklinux@outlook.com>
---
drivers/hv/mshv_root_main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/hv/mshv_root_main.c b/drivers/hv/mshv_root_main.c
index eff1b21461dc..5673af9fe101 100644
--- a/drivers/hv/mshv_root_main.c
+++ b/drivers/hv/mshv_root_main.c
@@ -1280,7 +1280,7 @@ mshv_map_user_memory(struct mshv_partition *partition,
long ret;
if (mem.flags & BIT(MSHV_SET_MEM_BIT_UNMAP) ||
- !access_ok((const void *)mem.userspace_addr, mem.size))
+ !access_ok((const void __user *)mem.userspace_addr, mem.size))
return -EINVAL;
mmap_read_lock(current->mm);
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] mshv: Add __user attribute to argument passed to access_ok()
2026-01-14 18:15 [PATCH 1/1] mshv: Add __user attribute to argument passed to access_ok() mhkelley58
@ 2026-01-14 18:39 ` Nuno Das Neves
2026-01-15 7:12 ` Wei Liu
0 siblings, 1 reply; 3+ messages in thread
From: Nuno Das Neves @ 2026-01-14 18:39 UTC (permalink / raw)
To: mhklinux, kys, haiyangz, wei.liu, decui, longli, linux-hyperv
Cc: linux-kernel
On 1/14/2026 10:15 AM, mhkelley58@gmail.com wrote:
> From: Michael Kelley <mhklinux@outlook.com>
>
> access_ok() expects its first argument to have the __user attribute
> since it is checking access to user space. Current code passes an
> argument that lacks that attribute, resulting in 'sparse' flagging
> the incorrect usage. However, the compiler doesn't generate code
> based on the attribute, so there's no actual bug.
>
> In the interest of general correctness and to avoid noise from sparse,
> add the __user attribute. No functional change.
>
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202512141339.791TCKnB-lkp@intel.com/
> Signed-off-by: Michael Kelley <mhklinux@outlook.com>
> ---
> drivers/hv/mshv_root_main.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/hv/mshv_root_main.c b/drivers/hv/mshv_root_main.c
> index eff1b21461dc..5673af9fe101 100644
> --- a/drivers/hv/mshv_root_main.c
> +++ b/drivers/hv/mshv_root_main.c
> @@ -1280,7 +1280,7 @@ mshv_map_user_memory(struct mshv_partition *partition,
> long ret;
>
> if (mem.flags & BIT(MSHV_SET_MEM_BIT_UNMAP) ||
> - !access_ok((const void *)mem.userspace_addr, mem.size))
> + !access_ok((const void __user *)mem.userspace_addr, mem.size))
> return -EINVAL;
>
> mmap_read_lock(current->mm);
Reviewed-by: Nuno Das Neves <nunodasneves@linux.microsoft.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] mshv: Add __user attribute to argument passed to access_ok()
2026-01-14 18:39 ` Nuno Das Neves
@ 2026-01-15 7:12 ` Wei Liu
0 siblings, 0 replies; 3+ messages in thread
From: Wei Liu @ 2026-01-15 7:12 UTC (permalink / raw)
To: Nuno Das Neves
Cc: mhklinux, kys, haiyangz, wei.liu, decui, longli, linux-hyperv,
linux-kernel
On Wed, Jan 14, 2026 at 10:39:14AM -0800, Nuno Das Neves wrote:
> On 1/14/2026 10:15 AM, mhkelley58@gmail.com wrote:
> > From: Michael Kelley <mhklinux@outlook.com>
> >
> > access_ok() expects its first argument to have the __user attribute
> > since it is checking access to user space. Current code passes an
> > argument that lacks that attribute, resulting in 'sparse' flagging
> > the incorrect usage. However, the compiler doesn't generate code
> > based on the attribute, so there's no actual bug.
> >
> > In the interest of general correctness and to avoid noise from sparse,
> > add the __user attribute. No functional change.
> >
> > Reported-by: kernel test robot <lkp@intel.com>
> > Closes: https://lore.kernel.org/oe-kbuild-all/202512141339.791TCKnB-lkp@intel.com/
> > Signed-off-by: Michael Kelley <mhklinux@outlook.com>
> > ---
> > drivers/hv/mshv_root_main.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/hv/mshv_root_main.c b/drivers/hv/mshv_root_main.c
> > index eff1b21461dc..5673af9fe101 100644
> > --- a/drivers/hv/mshv_root_main.c
> > +++ b/drivers/hv/mshv_root_main.c
> > @@ -1280,7 +1280,7 @@ mshv_map_user_memory(struct mshv_partition *partition,
> > long ret;
> >
> > if (mem.flags & BIT(MSHV_SET_MEM_BIT_UNMAP) ||
> > - !access_ok((const void *)mem.userspace_addr, mem.size))
> > + !access_ok((const void __user *)mem.userspace_addr, mem.size))
> > return -EINVAL;
> >
> > mmap_read_lock(current->mm);
>
> Reviewed-by: Nuno Das Neves <nunodasneves@linux.microsoft.com>
Applied.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-01-15 7:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-14 18:15 [PATCH 1/1] mshv: Add __user attribute to argument passed to access_ok() mhkelley58
2026-01-14 18:39 ` Nuno Das Neves
2026-01-15 7:12 ` Wei Liu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox