* [PATCH] Drivers: hv: vmbus: Initialize unload_event statically
@ 2021-04-16 14:39 Andrea Parri (Microsoft)
2021-04-16 15:25 ` Michael Kelley
0 siblings, 1 reply; 3+ messages in thread
From: Andrea Parri (Microsoft) @ 2021-04-16 14:39 UTC (permalink / raw)
To: linux-kernel
Cc: kys, haiyangz, sthemmin, wei.liu, linux-hyperv, mikelley,
Andrea Parri (Microsoft)
If a malicious or compromised Hyper-V sends a spurious message of type
CHANNELMSG_UNLOAD_RESPONSE, the function vmbus_unload_response() will
call complete() on an uninitialized event, and cause an oops.
Reported-by: Michael Kelley <mikelley@microsoft.com>
Signed-off-by: Andrea Parri (Microsoft) <parri.andrea@gmail.com>
---
drivers/hv/channel_mgmt.c | 2 +-
drivers/hv/connection.c | 2 ++
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index f3cf4af01e102..1efb616480a64 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -841,7 +841,7 @@ void vmbus_initiate_unload(bool crash)
if (vmbus_proto_version < VERSION_WIN8_1)
return;
- init_completion(&vmbus_connection.unload_event);
+ reinit_completion(&vmbus_connection.unload_event);
memset(&hdr, 0, sizeof(struct vmbus_channel_message_header));
hdr.msgtype = CHANNELMSG_UNLOAD;
vmbus_post_msg(&hdr, sizeof(struct vmbus_channel_message_header),
diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c
index 350e8c5cafa8c..529dcc47f3e11 100644
--- a/drivers/hv/connection.c
+++ b/drivers/hv/connection.c
@@ -26,6 +26,8 @@
struct vmbus_connection vmbus_connection = {
.conn_state = DISCONNECTED,
+ .unload_event = COMPLETION_INITIALIZER(
+ vmbus_connection.unload_event),
.next_gpadl_handle = ATOMIC_INIT(0xE1E10),
.ready_for_suspend_event = COMPLETION_INITIALIZER(
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* RE: [PATCH] Drivers: hv: vmbus: Initialize unload_event statically
2021-04-16 14:39 [PATCH] Drivers: hv: vmbus: Initialize unload_event statically Andrea Parri (Microsoft)
@ 2021-04-16 15:25 ` Michael Kelley
2021-04-19 6:09 ` Andrea Parri
0 siblings, 1 reply; 3+ messages in thread
From: Michael Kelley @ 2021-04-16 15:25 UTC (permalink / raw)
To: Andrea Parri (Microsoft), linux-kernel
Cc: KY Srinivasan, Haiyang Zhang, Stephen Hemminger, wei.liu, linux-hyperv
From: Andrea Parri (Microsoft) <parri.andrea@gmail.com> Sent: Friday, April 16, 2021 7:40 AM
>
> If a malicious or compromised Hyper-V sends a spurious message of type
> CHANNELMSG_UNLOAD_RESPONSE, the function vmbus_unload_response() will
> call complete() on an uninitialized event, and cause an oops.
Please leave a comment somewhere in the code itself that describes this
scenario so that somebody in the future doesn't decide it's OK to "simplify" the
initialization of unload_event. :-)
Michael
>
> Reported-by: Michael Kelley <mikelley@microsoft.com>
> Signed-off-by: Andrea Parri (Microsoft) <parri.andrea@gmail.com>
> ---
> drivers/hv/channel_mgmt.c | 2 +-
> drivers/hv/connection.c | 2 ++
> 2 files changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
> index f3cf4af01e102..1efb616480a64 100644
> --- a/drivers/hv/channel_mgmt.c
> +++ b/drivers/hv/channel_mgmt.c
> @@ -841,7 +841,7 @@ void vmbus_initiate_unload(bool crash)
> if (vmbus_proto_version < VERSION_WIN8_1)
> return;
>
> - init_completion(&vmbus_connection.unload_event);
> + reinit_completion(&vmbus_connection.unload_event);
> memset(&hdr, 0, sizeof(struct vmbus_channel_message_header));
> hdr.msgtype = CHANNELMSG_UNLOAD;
> vmbus_post_msg(&hdr, sizeof(struct vmbus_channel_message_header),
> diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c
> index 350e8c5cafa8c..529dcc47f3e11 100644
> --- a/drivers/hv/connection.c
> +++ b/drivers/hv/connection.c
> @@ -26,6 +26,8 @@
>
> struct vmbus_connection vmbus_connection = {
> .conn_state = DISCONNECTED,
> + .unload_event = COMPLETION_INITIALIZER(
> + vmbus_connection.unload_event),
> .next_gpadl_handle = ATOMIC_INIT(0xE1E10),
>
> .ready_for_suspend_event = COMPLETION_INITIALIZER(
> --
> 2.25.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Drivers: hv: vmbus: Initialize unload_event statically
2021-04-16 15:25 ` Michael Kelley
@ 2021-04-19 6:09 ` Andrea Parri
0 siblings, 0 replies; 3+ messages in thread
From: Andrea Parri @ 2021-04-19 6:09 UTC (permalink / raw)
To: Michael Kelley
Cc: linux-kernel, KY Srinivasan, Haiyang Zhang, Stephen Hemminger,
wei.liu, linux-hyperv
On Fri, Apr 16, 2021 at 03:25:03PM +0000, Michael Kelley wrote:
> From: Andrea Parri (Microsoft) <parri.andrea@gmail.com> Sent: Friday, April 16, 2021 7:40 AM
> >
> > If a malicious or compromised Hyper-V sends a spurious message of type
> > CHANNELMSG_UNLOAD_RESPONSE, the function vmbus_unload_response() will
> > call complete() on an uninitialized event, and cause an oops.
>
> Please leave a comment somewhere in the code itself that describes this
> scenario so that somebody in the future doesn't decide it's OK to "simplify" the
> initialization of unload_event. :-)
Yes, will do for v2.
Thanks,
Andrea
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-04-19 6:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-16 14:39 [PATCH] Drivers: hv: vmbus: Initialize unload_event statically Andrea Parri (Microsoft)
2021-04-16 15:25 ` Michael Kelley
2021-04-19 6:09 ` Andrea Parri
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).