Skip to contentSkip to conversation

mshv: Add __user attribute to argument passed to access_ok()

PATCH Applied [email protected] 3 participants 3 messages Jan 14 – Jan 15

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mshv: Add __user attribute to argument passed to access_ok()

From: Michael Kelley <[email protected]>

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.

---
 drivers/hv/mshv_root_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hv/mshv_root_main.c +1 -1
index eff1b21461dc..5673af9fe101 100644
@@ -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);
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 23 lines · On 1/14/2026 10:15 AM, [email protected] wrote:

From: Michael Kelley <[email protected]>

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.

---
 drivers/hv/mshv_root_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hv/mshv_root_main.c +0 -0
index eff1b21461dc..5673af9fe101 100644

drivers/hv/mshv_root_main.c mshv_map_user_memory(struct mshv_partition *partition, · line 1286

Quoted 8 lines
drivers/hv/mshv_root_main.c +1 -1
@@ -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);
maintainer Applied
#2 lore raw
Quoted 26 lines · Nuno Das Neves
Quoted 25 lines · On 1/14/2026 10:15 AM, [email protected] wrote:

From: Michael Kelley <[email protected]>

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.

---
 drivers/hv/mshv_root_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hv/mshv_root_main.c +0 -0
index eff1b21461dc..5673af9fe101 100644
@@ -1280,7 +1280,7 @@ mshv_map_user_memory(struct mshv_partition *partition,
 	long ret;
 
Quoted 8 lines

drivers/hv/mshv_root_main.c mshv_map_user_memory(struct mshv_partition *partition, · line 1286

Quoted 6 lines
drivers/hv/mshv_root_main.c +1 -1
 	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);

Applied.