2019-05-07 07:48:11

by Dexuan Cui

[permalink] [raw]
Subject: [PATCH] Drivers: hv: vmbus: Fix virt_to_hvpfn() for X86_PAE

In the case of X86_PAE, unsigned long is u32, but the physical address type
should be u64. Due to the bug here, the netvsc driver can not load
successfully, and sometimes the VM can panic due to memory corruption (the
hypervisor writes data to the wrong location).

Fixes: 6ba34171bcbd ("Drivers: hv: vmbus: Remove use of slow_virt_to_phys()")
Cc: [email protected]
Cc: Michael Kelley <[email protected]>
Reported-and-tested-by: Juliana Rodrigueiro <[email protected]>
Signed-off-by: Dexuan Cui <[email protected]>
---
drivers/hv/channel.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
index 23381c41d087..aaaee5f93193 100644
--- a/drivers/hv/channel.c
+++ b/drivers/hv/channel.c
@@ -38,7 +38,7 @@

static unsigned long virt_to_hvpfn(void *addr)
{
- unsigned long paddr;
+ phys_addr_t paddr;

if (is_vmalloc_addr(addr))
paddr = page_to_phys(vmalloc_to_page(addr)) +
--
2.17.1


2019-05-07 12:54:32

by Michael Kelley (LINUX)

[permalink] [raw]
Subject: RE: [PATCH] Drivers: hv: vmbus: Fix virt_to_hvpfn() for X86_PAE

From: Dexuan Cui <[email protected]> Sent: Tuesday, May 7, 2019 12:47 AM
>
> In the case of X86_PAE, unsigned long is u32, but the physical address type
> should be u64. Due to the bug here, the netvsc driver can not load
> successfully, and sometimes the VM can panic due to memory corruption (the
> hypervisor writes data to the wrong location).
>
> Fixes: 6ba34171bcbd ("Drivers: hv: vmbus: Remove use of slow_virt_to_phys()")
> Cc: [email protected]
> Cc: Michael Kelley <[email protected]>
> Reported-and-tested-by: Juliana Rodrigueiro <[email protected]>
> Signed-off-by: Dexuan Cui <[email protected]>

Reviewed-by: Michael Kelley <[email protected]>

2019-05-09 01:07:12

by Sasha Levin

[permalink] [raw]
Subject: Re: [PATCH] Drivers: hv: vmbus: Fix virt_to_hvpfn() for X86_PAE

On Tue, May 07, 2019 at 12:51:51PM +0000, Michael Kelley wrote:
>From: Dexuan Cui <[email protected]> Sent: Tuesday, May 7, 2019 12:47 AM
>>
>> In the case of X86_PAE, unsigned long is u32, but the physical address type
>> should be u64. Due to the bug here, the netvsc driver can not load
>> successfully, and sometimes the VM can panic due to memory corruption (the
>> hypervisor writes data to the wrong location).
>>
>> Fixes: 6ba34171bcbd ("Drivers: hv: vmbus: Remove use of slow_virt_to_phys()")
>> Cc: [email protected]
>> Cc: Michael Kelley <[email protected]>
>> Reported-and-tested-by: Juliana Rodrigueiro <[email protected]>
>> Signed-off-by: Dexuan Cui <[email protected]>
>
>Reviewed-by: Michael Kelley <[email protected]>

Queued for hyperv-fixes, thanks!

--
Thanks,
Sasha