From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753750AbdEQVyY (ORCPT ); Wed, 17 May 2017 17:54:24 -0400 Received: from a2nlsmtp01-02.prod.iad2.secureserver.net ([198.71.225.36]:45480 "EHLO a2nlsmtp01-02.prod.iad2.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752156AbdEQVyW (ORCPT ); Wed, 17 May 2017 17:54:22 -0400 X-Greylist: delayed 675 seconds by postgrey-1.27 at vger.kernel.org; Wed, 17 May 2017 17:54:22 EDT x-originating-ip: 107.180.71.197 From: mikelley@exchange.microsoft.com To: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, devel@linuxdriverproject.org, olaf@aepfle.de, apw@canonical.com, vkuznets@redhat.com, jasowang@redhat.com, leann.ogasawara@canonical.com, marcelo.cerri@canonical.com, sthemmin@microsoft.com, kys@microsoft.com Cc: Michael Kelley Subject: [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. Date: Wed, 17 May 2017 14:40:55 -0700 Message-Id: <1495057255-10660-1-git-send-email-mikelley@exchange.microsoft.com> X-Mailer: git-send-email 1.7.1 Reply-To: mikelley@microsoft.com X-CMAE-Envelope: MS4wfA7OwhfotxKfgMOVsxRpVVD08ZQDhWsZ0ql9idvhPb03g3CA6rbMORaQ5Tr78AOcvl5bFpOCJmVpdpzm1UfitRpEAnt5X23gGiKkJ7OPvadtl9GDqlso 1j+xiWoINrWlhkNpHcmy1F416iWdElB3CusqViJWgKF8lEs2ObNfUsR8A5fbIzMREyo/QnLi5NMo9SqoUbnifPLbK1C7fnr6PVANc2iMQmGz/MM5IHntn6a2 n66xVN0a6H3j+3ruXp9BfC4vmAr5zJb/ldrlPznUPxzBvIydoiDE1SmFQzL6IZh4xsq81FTRx7+SjH+IJYwq4RqHiCArMkCZhXi7laGSvjuZqrLBbZFGOS9E cIlgCUQyz+lTXdM/XuOYqCexivzXqJ7h5I2IpgDyfrQkoE1NLSgLUumhZ24PIk1lmerR16WAwFLoPLyYRCCCKkspospZRNcj3sldGX4fE1CA0qyPvha2XzJ0 vEBCg9uBjwpuLT8//YVAPWRsz5N7ooRdJ5V/xNzmUDqsu8YijrnzIGnAYcbYeAH+vLPR4UExmNyV6nIMEivkQ4Y/7HIUB88wSExDtA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Michael Kelley Signed-off-by: Michael Kelley --- 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