Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp179319imm; Fri, 3 Aug 2018 01:28:46 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcNXcJI2c8VGj0btSqIWSwMYG6zoO7tTZ6PNoc+zqV1LrsPF2Wpj+pSsJOKm5wLitWvh8ms X-Received: by 2002:a65:6343:: with SMTP id p3-v6mr2783035pgv.48.1533284926397; Fri, 03 Aug 2018 01:28:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533284926; cv=none; d=google.com; s=arc-20160816; b=KsgOHiEByEirPItnrd/Own+tEpmVq2mcBWHTMjDIMm6mlSmGpjNWhrsrJVlGe/Rn+S sxQ/RbgWqvf5nEb1T3BpoDH+ghjvUfdPcytsJGu5H/503NEY1ypgaKXlCkzW41/9+d0j mLsVllHa14bTsCaCr+1Jn4vV8CGCRYfz3KQ3oPcl3Mlyn0wRANxTBVnG7V5OSeDxFPNP Bun0/4EGry9juQvvdNOmUOo287ojGFudw183AlXShclcrZ6argCnaPB2oiD57NuYiiEC QbSH1rNpgUQtHkMkpBVzwToyVqVV/wOS8xgyLND2F3sG9eeeRI0xcFigue2Dnzo07s7Z VPOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=R17FW7vwiWT1PuB2ihqjNHvjZn12D8bYwCPgfhF5jL4=; b=VSM6VwxphwIWpFbjPKiNA6Wwjc98HyLqYgmChWj8P/TAhYURpnlObS8Uht2vxktM4M qQxghAeAIfn1ea4r3U45QsVMk02lgQ55d6zotQRQV01D54lFmdHJ0ny/WytDysmJ/72t IAL4Ctdpiwg23oXpRxkqfmI7Efh6N0H88tu86nJop1Vfwz3iKD4B6mMiqNwv4dlRYYFq pAOAISbr7LeWm2WYVfIWAseofURALkNFPEFiK3JGM0UfrOOr9zeyR95aJUrsad+AgZoy 3ZARFNovw62fjvYlIyODXbGn/ozndVGhncL0HZzPdheFD5NWfkqKauIpf1ujazSjmM/s eGZg== 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 k6-v6si3200219pls.393.2018.08.03.01.28.31; Fri, 03 Aug 2018 01:28:46 -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 S1731119AbeHCKWz (ORCPT + 99 others); Fri, 3 Aug 2018 06:22:55 -0400 Received: from nautica.notk.org ([91.121.71.147]:58203 "EHLO nautica.notk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728129AbeHCKWz (ORCPT ); Fri, 3 Aug 2018 06:22:55 -0400 Received: by nautica.notk.org (Postfix, from userid 1001) id 7EB3AC009; Fri, 3 Aug 2018 10:27:40 +0200 (CEST) Date: Fri, 3 Aug 2018 10:27:25 +0200 From: Dominique Martinet To: jiangyiwen Cc: Eric Van Hensbergen , Ron Minnich , Latchesar Ionkov , Linux Kernel Mailing List , v9fs-developer@lists.sourceforge.net, netdev@vger.kernel.org Subject: Re: [V9fs-developer] [PATCH] net/9p: avoid request size exceed to the virtqueue number in the zero copy Message-ID: <20180803082725.GA8655@nautica> References: <5B63FB4D.1050703@huawei.com> <20180803073240.GA26848@nautica> <5B640FCC.3000704@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <5B640FCC.3000704@huawei.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org jiangyiwen wrote on Fri, Aug 03, 2018: > On 2018/8/3 15:32, Dominique Martinet wrote: > > jiangyiwen wrote on Fri, Aug 03, 2018: > >> Unfortunately, when the address(input and response headers) are not > >> at page boundary, it will need two extra entry in the zero copy, or > >> else it will cause sg array out of bounds. > >> > >> To avoid the problem, we should subtract two pages for maxsize. > > > > Good catch, that must have been painful to figure. > > > > Given we know how big the headers are (something like 11 or 23 bytes > > depending on the op/direction, it's capped by P9_IOHDRSZ at 24), > > couldn't we just cheat and not use the start of the buffer if we detect > > it's overlapping? > > Actually, generally the P9_IOHDRSZ will not cause the problem, because > 24 bytes is too small, but P9_ZC_HDR_SZ(4096 bytes) often cause two pages. > > So I have a question about why we need to use P9_ZC_HDR_SZ, actually we > may use P9_IOHDRSZ instead. The reason is historical (for non-dotl versions of 9P), but the reply if error could be longer than P9_IOHDRSZ in this case - see the code in p9_check_zc_errors that copies the end of the string back from the zc buffer to the 4k buffer I don't see much other reason, though... But I don't understand how that is a problem - we don't actually put the full P9_ZC_HDR_SZ in chan->sg for headers, but these: out = pack_sg_list(chan->sg, 0, VIRTQUEUE_NUM, req->tc.sdata, req->tc.size); in = pack_sg_list(chan->sg, out, VIRTQUEUE_NUM, req->rc.sdata, in_hdr_len); req->tc.size is the size of the header up till that point and in_hdr_len is the size expected from the header. That's why I suggested that if these are on a page boundary, we could just memcpy that data further within the P9_ZC_HDR_SZ-sized buffer and use that for the header (then move it back to the start of the buffer for the reply header) -- Dominique