Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2933432imm; Mon, 16 Jul 2018 17:36:21 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcKhxXUzAA1FelftnKBck/IQYrFFuyQXThTUH6J4cq6TM+GA2CTzl+y2ZNi7A2eEcXfpBUb X-Received: by 2002:a17:902:bcc5:: with SMTP id o5-v6mr3523529pls.336.1531787781573; Mon, 16 Jul 2018 17:36:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531787781; cv=none; d=google.com; s=arc-20160816; b=PwXnwgI0b6zZpUskFnV771hNi05ikirWCeRoypARoc1JgZ8rUKeJNYZvvQP4txBdjs qubuAUEN0Cep384fxAUywPEwLp5dVry9sZg8otulOFz0lW24oSd4cRB9Ad2xBKFzDlAE eXLJvzvxARBX39nt2UZeVATVxqjsIrKju7ctUiGEgbsiqG+Qnc6g+KFQ9mC1H5Pd1Vka lfB5fjdwnvYDniKwVRv+GTSGRX3Davfir4uBh794O9ytgYpwgnq8628Y8LjcaeVRiete +r/FMeMvP3f+v+AgdrTNp54l+y4UtKqQfQPSgL5mo2ly2rkfPjU+bYSwk6lsm673ZmM4 iOUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=DpfcA4DL5DGiiXNwkLOURJ+Yp3GG6BMVyLv9uuXYaWU=; b=yNBy1Tx1/E8p/TFRh3DvwXa+sDVvFidU6utxYIgGZKN8cvPSWd6h6PIQ2OkUu7KMuf /w6AKH7098TAKfAgDW2t1Rxw25Hnplikn26cHK/AamYS2HRaQX+Wvjiz4M7ACMNPy06Q Fv0V3bZpeO7qery2cJQrCKwQUmnAcShIgGaN4BHAJWj9mylcNEKnoVIIKaf1G/KTNWn4 L4wntox66DcPdKzGYdHuPvEs+cxuHn1nSdDHiHrcn3Zaa6wvaMTkV1e08wfJbSDGwU37 tp8o2iDayL0pfOMWYfo7aWOl0x4UFfvtQhTdlE24dFr7FZeklVK2UMviy1Y8s6a1xTXF g9rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=FwiiI4j9; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 97-v6si31612379pld.345.2018.07.16.17.36.06; Mon, 16 Jul 2018 17:36:21 -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; dkim=pass header.i=@chromium.org header.s=google header.b=FwiiI4j9; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730310AbeGQBFZ (ORCPT + 99 others); Mon, 16 Jul 2018 21:05:25 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:37240 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729466AbeGQBFZ (ORCPT ); Mon, 16 Jul 2018 21:05:25 -0400 Received: by mail-pg1-f196.google.com with SMTP id n7-v6so1295739pgq.4 for ; Mon, 16 Jul 2018 17:35:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id; bh=DpfcA4DL5DGiiXNwkLOURJ+Yp3GG6BMVyLv9uuXYaWU=; b=FwiiI4j9lzXbwCUGZ35pPm6QqcSJu9MosBo+5cSpVpb9hzMZfwhSyEH5SJlhdsn6gN bOeeCvLIf3RbhNvgPVN1G6xwrlA8x5zPaljJyIwk8gdWOOOQg0Cayn6e5odrPTrQ4MfM Kb/0H4Vn9XG2ahe10c6CTAHn3Q6SXT1VAclo0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=DpfcA4DL5DGiiXNwkLOURJ+Yp3GG6BMVyLv9uuXYaWU=; b=iiQ9WOgKA1K/+kz8cFaNFATrKfNFUVvlhBPc+Par/HNsXsRZhzQd30rv9Y+khEqkJC 29Q43HrZZF88aBiKm0DPaE3bE+MvjFA/PKthprQHFYOqNrwZRWWs3jn6Jp8SRF+Q+5bz XXqV1nw8hhxoHkSbRjdudnljRmEJdL88UFVyPnTkPfFSgrtK8ZmzeqP+FlX+9xSi1Rzz iJ9VkEdndLMKsNLzIIRBR5+BLtv4jurLMvMb6qoWvoYCHvglb/I7T0CWQTKxN/mg6pwC u2B8hSGubrTOUgUtEOPA7VPKTC8SYxeZCzyNQLip7oIjBuNpU2snFFCqcqIymaLA95p9 yE+A== X-Gm-Message-State: AOUpUlFhbyTwedijfE49MSsd8f7sqIbuCc8Ip8lzDnWenrCKcC3JoXnz 7Mn2Qkj/HI3Llg5N8mUQzA6oZM0DsYQ= X-Received: by 2002:a63:fb07:: with SMTP id o7-v6mr2805267pgh.333.1531787734225; Mon, 16 Jul 2018 17:35:34 -0700 (PDT) Received: from belgium.mtv.corp.google.com ([2620:0:1000:1501:d2b0:ee44:7e40:11aa]) by smtp.gmail.com with ESMTPSA id g11-v6sm44864206pfh.63.2018.07.16.17.35.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Jul 2018 17:35:33 -0700 (PDT) From: Chirantan Ekbote To: asmadeus@codewreck.org Cc: groug@kaod.org, linux-kernel@vger.kernel.org, v9fs-developer@lists.sourceforge.net, dgreid@chromium.org, groeck@chromium.org, Chirantan Ekbote Subject: [PATCH v2] Fix zero-copy path in the 9p virtio transport Date: Mon, 16 Jul 2018 17:35:29 -0700 Message-Id: <20180717003529.114368-1-chirantan@chromium.org> X-Mailer: git-send-email 2.18.0.203.gfac676dfb9-goog Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Signed-off-by: Chirantan Ekbote Reviewed-by: Greg Kurz Tested-by: Greg Kurz --- net/9p/trans_virtio.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c index 05006cbb3361..65761381c58f 100644 --- a/net/9p/trans_virtio.c +++ b/net/9p/trans_virtio.c @@ -406,6 +406,7 @@ p9_virtio_zc_request(struct p9_client *client, struct p9_req_t *req, 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) @@ -416,6 +417,12 @@ p9_virtio_zc_request(struct p9_client *client, struct p9_req_t *req, 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); -- 2.18.0.203.gfac676dfb9-goog