Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2325876imm; Fri, 7 Sep 2018 14:42:33 -0700 (PDT) X-Google-Smtp-Source: ANB0VdY9yNdpvZC6Uue8X5+habsBExc5nAX2LQEeqdWJ0Oc/0QrWDvC0cdKhJ+C/W8J+1iAK1KUp X-Received: by 2002:a62:b0e:: with SMTP id t14-v6mr10086936pfi.36.1536356553677; Fri, 07 Sep 2018 14:42:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536356553; cv=none; d=google.com; s=arc-20160816; b=TjC4y3O9c+QMgiHrKGB0tqq8kAeI9oSktNpPyBoLbIrula2PekqMsxtKLxxvWv/TXK LxrTaFHOySTtciX5F5bTcUawOVliTwChopKmzDnr5QPzKgOo7EW1Ee5q3OSiKllZuePJ sWPDmigDY/lcnctAhdBW45vvZvpimhZHCcCGdZD4KEFcttCoT7K7/yJReF0gK5o+P7f2 DGsajYdy3xQEKjptrjsEtRv/7ZrgsXGtbeFMOuOKzPFPo8oKYyzVyA9Wk+JaYGnFi7hH wH8HDRJU1Nq3sdIiILqgVoWSJeLd0CNmVtm3akotBFwKTcp84qh8UEqBBHSgbQUtW0id 4KlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from; bh=BLlO5F6tfHPUItvAOzFxHFBbt843Dfc+o9PaTpZUnsI=; b=Tom8sFY5AfgW+OMlc9xf9A9xjiShgo7Zq+4VRXmP9nCw2WoppiAssoTOlxdCXDgr4I XcWyFV24/0rkGuPE8ZoshklOuwz59kWtC5dQx/vs8G10vfWx89R77FBtRMXdUaSXvtRt Xm8wGkZE2zeSWzvvnWoJKzytLB2qVpT03MAfyosDHI4raZRN/gDXkd7GnMascx4n+aYy pW1eeNL3fMoj73Is2rKaaBave03jeMKIWDr1oHmPY1eUypOAYNP9IOTOoxqP/AaPW9mr wolvsTJYlkhoWuZfxznxPARuu28xZuZ6wI09a6Lr61PFN2U0BF8uuz8yRD1K+Dufsw4p CjrA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c10-v6si9595749pgg.315.2018.09.07.14.42.18; Fri, 07 Sep 2018 14:42:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730167AbeIHCXr (ORCPT + 99 others); Fri, 7 Sep 2018 22:23:47 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:54708 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728473AbeIHCXq (ORCPT ); Fri, 7 Sep 2018 22:23:46 -0400 Received: from localhost (ip-213-127-74-90.ip.prioritytelecom.net [213.127.74.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 24FDFFF6; Fri, 7 Sep 2018 21:40:50 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chirantan Ekbote , Greg Kurz , Dylan Reid , Guenter Roeck , Dominique Martinet Subject: [PATCH 4.4 03/47] 9p/net: Fix zero-copy path in the 9p virtio transport Date: Fri, 7 Sep 2018 23:09:59 +0200 Message-Id: <20180907210904.834444985@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180907210904.607934824@linuxfoundation.org> References: <20180907210904.607934824@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Chirantan Ekbote commit d28c756caee6e414d9ba367d0b92da24145af2a8 upstream. The zero-copy optimization when reading or writing large chunks of data is quite useful. However, the 9p messages created through the zero-copy write path have an incorrect message size: it should be the size of the header + size of the data being written but instead it's just the size of the header. This only works if the server ignores the size field of the message and otherwise breaks the framing of the protocol. Fix this by re-writing the message size field with the correct value. Tested by running `dd if=/dev/zero of=out bs=4k count=1` inside a virtio-9p mount. Link: http://lkml.kernel.org/r/20180717003529.114368-1-chirantan@chromium.org Signed-off-by: Chirantan Ekbote Reviewed-by: Greg Kurz Tested-by: Greg Kurz Cc: Dylan Reid Cc: Guenter Roeck Cc: stable@vger.kernel.org Signed-off-by: Dominique Martinet Signed-off-by: Greg Kroah-Hartman --- net/9p/trans_virtio.c | 7 +++++++ 1 file changed, 7 insertions(+) --- a/net/9p/trans_virtio.c +++ b/net/9p/trans_virtio.c @@ -409,6 +409,7 @@ p9_virtio_zc_request(struct p9_client *c p9_debug(P9_DEBUG_TRANS, "virtio request\n"); if (uodata) { + __le32 sz; int n = p9_get_mapped_pages(chan, &out_pages, uodata, outlen, &offs, &need_drop); if (n < 0) @@ -419,6 +420,12 @@ p9_virtio_zc_request(struct p9_client *c memcpy(&req->tc->sdata[req->tc->size - 4], &v, 4); outlen = n; } + /* The size field of the message must include the length of the + * header and the length of the data. We didn't actually know + * the length of the data until this point so add it in now. + */ + sz = cpu_to_le32(req->tc->size + outlen); + memcpy(&req->tc->sdata[0], &sz, sizeof(sz)); } else if (uidata) { int n = p9_get_mapped_pages(chan, &in_pages, uidata, inlen, &offs, &need_drop);