The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH 1/1] Drivers: hv: vmbus: Close timing hole that can corrupt per-cpu page Extend the disabling of preemption to include the hypercall so that another thread can't get the CPU and corrupt the per-cpu page used for hypercall arguments.
@ 2017-05-17 21:40 mikelley
  2017-05-17 22:00 ` Stephen Hemminger
  0 siblings, 1 reply; 3+ messages in thread
From: mikelley @ 2017-05-17 21:40 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, olaf, apw, vkuznets, jasowang,
	leann.ogasawara, marcelo.cerri, sthemmin, kys
  Cc: Michael Kelley

From: Michael Kelley <mikelley@microsoft.com>

Signed-off-by: Michael Kelley <mikelley@microsoft.com>
---
 drivers/hv/hv.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
index 12e7bae..47ed538 100644
--- a/drivers/hv/hv.c
+++ b/drivers/hv/hv.c
@@ -82,9 +82,14 @@ int hv_post_message(union hv_connection_id connection_id,
 	aligned_msg->message_type = message_type;
 	aligned_msg->payload_size = payload_size;
 	memcpy((void *)aligned_msg->payload, payload, payload_size);
-	put_cpu_ptr(hv_cpu);
 
 	status = hv_do_hypercall(HVCALL_POST_MESSAGE, aligned_msg, NULL);
+
+	/* Preemption must remain disabled until after the hypercall
+	 * so some other thread can't get scheduled onto this cpu and
+	 * corrupt the per-cpu post_msg_page
+	 */
+	put_cpu_ptr(hv_cpu);
 
 	return status & 0xFFFF;
 }
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] Drivers: hv: vmbus: Close timing hole that can corrupt per-cpu page Extend the disabling of preemption to include the hypercall so that another thread can't get the CPU and corrupt the per-cpu page used for hypercall arguments.
  2017-05-17 21:40 [PATCH 1/1] Drivers: hv: vmbus: Close timing hole that can corrupt per-cpu page Extend the disabling of preemption to include the hypercall so that another thread can't get the CPU and corrupt the per-cpu page used for hypercall arguments mikelley
@ 2017-05-17 22:00 ` Stephen Hemminger
  2017-05-17 22:04   ` Joshua R. Poulson
  0 siblings, 1 reply; 3+ messages in thread
From: Stephen Hemminger @ 2017-05-17 22:00 UTC (permalink / raw)
  To: mikelley
  Cc: mikelley, gregkh, linux-kernel, devel, olaf, apw, vkuznets,
	jasowang, leann.ogasawara, marcelo.cerri, sthemmin, kys

On Wed, 17 May 2017 14:40:55 -0700
mikelley@exchange.microsoft.com wrote:

> From: Michael Kelley <mikelley@microsoft.com>
> 
> Signed-off-by: Michael Kelley <mikelley@microsoft.com>
> ---
>  drivers/hv/hv.c |    7 ++++++-
>  1 files changed, 6 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
> index 12e7bae..47ed538 100644
> --- a/drivers/hv/hv.c
> +++ b/drivers/hv/hv.c
> @@ -82,9 +82,14 @@ int hv_post_message(union hv_connection_id connection_id,
>  	aligned_msg->message_type = message_type;
>  	aligned_msg->payload_size = payload_size;
>  	memcpy((void *)aligned_msg->payload, payload, payload_size);
> -	put_cpu_ptr(hv_cpu);
>  
>  	status = hv_do_hypercall(HVCALL_POST_MESSAGE, aligned_msg, NULL);
> +
> +	/* Preemption must remain disabled until after the hypercall
> +	 * so some other thread can't get scheduled onto this cpu and
> +	 * corrupt the per-cpu post_msg_page
> +	 */
> +	put_cpu_ptr(hv_cpu);
>  
>  	return status & 0xFFFF;
>  }

Since Subject line becomes the git log description, it is best practice to keep it short.
On git commit man page:

       Though not required, it’s a good idea to begin the commit message with
       a single short (less than 50 character) line summarizing the change,
       followed by a blank line and then a more thorough description. 

If you need to provide more description put it in the message body.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] Drivers: hv: vmbus: Close timing hole that can corrupt per-cpu page Extend the disabling of preemption to include the hypercall so that another thread can't get the CPU and corrupt the per-cpu page used for hypercall arguments.
  2017-05-17 22:00 ` Stephen Hemminger
@ 2017-05-17 22:04   ` Joshua R. Poulson
  0 siblings, 0 replies; 3+ messages in thread
From: Joshua R. Poulson @ 2017-05-17 22:04 UTC (permalink / raw)
  To: Stephen Hemminger
  Cc: mikelley, mikelley, gregkh, linux-kernel, devel, olaf, apw,
	Vitaly Kuznetsov, jasowang, leann.ogasawara, marcelo.cerri,
	Stephen Hemminger, KY Srinivasan

This looks like a bugfix that should be included in stable.

On Wed, May 17, 2017 at 3:00 PM, Stephen Hemminger
<stephen@networkplumber.org> wrote:
> On Wed, 17 May 2017 14:40:55 -0700
> mikelley@exchange.microsoft.com wrote:
>
>> From: Michael Kelley <mikelley@microsoft.com>
>>
>> Signed-off-by: Michael Kelley <mikelley@microsoft.com>
>> ---
>>  drivers/hv/hv.c |    7 ++++++-
>>  1 files changed, 6 insertions(+), 1 deletions(-)
>>
>> diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
>> index 12e7bae..47ed538 100644
>> --- a/drivers/hv/hv.c
>> +++ b/drivers/hv/hv.c
>> @@ -82,9 +82,14 @@ int hv_post_message(union hv_connection_id connection_id,
>>       aligned_msg->message_type = message_type;
>>       aligned_msg->payload_size = payload_size;
>>       memcpy((void *)aligned_msg->payload, payload, payload_size);
>> -     put_cpu_ptr(hv_cpu);
>>
>>       status = hv_do_hypercall(HVCALL_POST_MESSAGE, aligned_msg, NULL);
>> +
>> +     /* Preemption must remain disabled until after the hypercall
>> +      * so some other thread can't get scheduled onto this cpu and
>> +      * corrupt the per-cpu post_msg_page
>> +      */
>> +     put_cpu_ptr(hv_cpu);
>>
>>       return status & 0xFFFF;
>>  }
>
> Since Subject line becomes the git log description, it is best practice to keep it short.
> On git commit man page:
>
>        Though not required, it’s a good idea to begin the commit message with
>        a single short (less than 50 character) line summarizing the change,
>        followed by a blank line and then a more thorough description.
>
> If you need to provide more description put it in the message body.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-05-17 22:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-17 21:40 [PATCH 1/1] Drivers: hv: vmbus: Close timing hole that can corrupt per-cpu page Extend the disabling of preemption to include the hypercall so that another thread can't get the CPU and corrupt the per-cpu page used for hypercall arguments mikelley
2017-05-17 22:00 ` Stephen Hemminger
2017-05-17 22:04   ` Joshua R. Poulson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox