Skip to contentSkip to conversation

xen: fix sparse warning in page.h

PATCH New Juergen Gross 1 participant 1 message Dec 5, 2014

Subsystems (2)
lore
Share & tools
lore

Juergen Gross

author maintainer
#0 lore raw

PATCH 1/1 xen: fix sparse warning in page.h

The inline function mfn_to_pfn_no_overrides() uses __get_user() to access the machine_to_phys_mapping array to avoid crashes when using out of bounds indices e.g. for I/O addresses.

Avoid sparse warnings by attributing the accessed address with __user.

---
 arch/x86/include/asm/xen/page.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/x86/include/asm/xen/page.h +3 -1
index f5d5de4..6deff84 100644
@@ -113,6 +113,7 @@ static inline unsigned long mfn_to_pfn_no_overrides(unsigned long mfn)
 {
 	unsigned long pfn;
 	int ret;
+	unsigned long __user *addr;
 
 	if (xen_feature(XENFEAT_auto_translated_physmap))
 		return mfn;
@@ -125,7 +126,8 @@ static inline unsigned long mfn_to_pfn_no_overrides(unsigned long mfn)
 	 * In such cases it doesn't matter what we return (we return garbage),
 	 * but we must handle the fault without crashing!
 	 */
-	ret = __get_user(pfn, &machine_to_phys_mapping[mfn]);
+	addr = (unsigned long __user *)(&machine_to_phys_mapping[mfn]);
+	ret = __get_user(pfn, addr);
 	if (ret < 0)
 		return ~0;
 
Signature · 1 line
2.1.2