Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755780AbdHYM17 (ORCPT ); Fri, 25 Aug 2017 08:27:59 -0400 Received: from mo4-p00-ob.smtp.rzone.de ([81.169.146.220]:13838 "EHLO mo4-p00-ob.smtp.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754850AbdHYM16 (ORCPT ); Fri, 25 Aug 2017 08:27:58 -0400 X-RZG-AUTH: :P2EQZWCpfu+qG7CngxMFH1J+yackYocTD1iAi8x+OWi/zfN1cLnAYQz4mzReZKAqPT2tb6Nx5EL7HQvAw3tBGHnS2eB9 X-RZG-CLASS-ID: mo00 From: Olaf Hering To: "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , devel@linuxdriverproject.org (open list:Hyper-V CORE AND DRIVERS), linux-kernel@vger.kernel.org (open list) Cc: Olaf Hering Subject: [PATCH] Drivers: hv: fcopy: restore correct transfer length Date: Fri, 25 Aug 2017 14:27:51 +0200 Message-Id: <20170825122751.29485-1-olaf@aepfle.de> X-Mailer: git-send-email 2.14.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1744 Lines: 43 Prior commit c7e490fc23eb the expected length of bytes read by the daemon did depend on the context. It was either hv_start_fcopy or hv_do_fcopy. The daemon had a buffer size of two pages, which was much larger than needed. Since commit c7e490fc23eb the expected length of bytes read by the daemon changed slightly. For START_FILE_COPY it is still the size of hv_start_fcopy. But for WRITE_TO_FILE and the other operations it is as large as the buffer that arrived via vmbus. In case of WRITE_TO_FILE that is slightly larger than a struct hv_do_fcopy. Since the buffer in the daemon was still larger everything was fine. After commit 3f2baa8a7d2e the daemon reads only what is actually needed. The new buffer layout is as large as a struct hv_do_fcopy, for the WRITE_TO_FILE operation. Since the kernel expects a slightly larger size, hvt_op_read will return -EINVAL because the daemon will read slightly less than expected. Fix this by restoring the expected buffer size in case of WRITE_TO_FILE. Fixes: c7e490fc23eb ("Drivers: hv: fcopy: convert to hv_utils_transport") Fixes: 3f2baa8a7d2e ("Tools: hv: update buffer handling in hv_fcopy_daemon") Signed-off-by: Olaf Hering --- drivers/hv/hv_fcopy.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/hv/hv_fcopy.c b/drivers/hv/hv_fcopy.c index daa75bd41f86..2364281d8593 100644 --- a/drivers/hv/hv_fcopy.c +++ b/drivers/hv/hv_fcopy.c @@ -170,6 +170,10 @@ static void fcopy_send_data(struct work_struct *dummy) out_src = smsg_out; break; + case WRITE_TO_FILE: + out_src = fcopy_transaction.fcopy_msg; + out_len = sizeof(struct hv_do_fcopy); + break; default: out_src = fcopy_transaction.fcopy_msg; out_len = fcopy_transaction.recv_len;