]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
mshv: Add __user attribute to argument passed to access_ok()
authorMichael Kelley <mhklinux@outlook.com>
Wed, 14 Jan 2026 18:15:08 +0000 (10:15 -0800)
committerWei Liu <wei.liu@kernel.org>
Thu, 15 Jan 2026 07:12:04 +0000 (07:12 +0000)
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>
Reviewed-by: Nuno Das Neves <nunodasneves@linux.microsoft.com>
Signed-off-by: Wei Liu <wei.liu@kernel.org>
drivers/hv/mshv_root_main.c

index 1134a82c7881341c10272f682ed695f1e85a2a42..99fdbc3988aae7754a9cf7946794d2c82a696704 100644 (file)
@@ -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);