From nobody Wed Apr 15 21:53:36 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E0D21C4332F for ; Tue, 22 Nov 2022 20:08:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234517AbiKVUIh (ORCPT ); Tue, 22 Nov 2022 15:08:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234222AbiKVUId (ORCPT ); Tue, 22 Nov 2022 15:08:33 -0500 X-Greylist: delayed 2102 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Tue, 22 Nov 2022 12:08:32 PST Received: from lizzy.crudebyte.com (lizzy.crudebyte.com [91.194.90.13]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90D78A3400 for ; Tue, 22 Nov 2022 12:08:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=weFqBBEuoYe8WdB7ucJUMCD7rrVXpr62keLdAWyCS78=; b=c/Y03 viW3pfh0CXBuJXFUV546K3MLlDBf5+7XUhj4ROuE0l2qcUJ/JnBG4GE2ZcQ8owjiLrsSiRBZ31Rzq flAl00AViUPcqtsLv7xfi4YgHhblZsPut5DgW7z1+/pIDGV+HPWGI7ve9dLnzocVWY9Uu/vFi2qgs MwXFy2RgWFApTkOzb03wORpqHFmlRLgKyfUNKfuryT9xA5O3olsNxQtO2l/rLzKCeD5DqTGd1F3iB eF9a2y9XdqVfimrDVR3XI3tOJK6PIQiQ2AX6E4jJP0qsVOplVBBBfpBaLGLMXUeiW7R3LZvgojpuz nQGnvZgL/mJ2ffyIyMUa5THslAimA==; Message-Id: <8f2a5c12a446c3b544da64e0b1550e1fb2d6f972.1669144861.git.linux_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Tue, 22 Nov 2022 20:20:22 +0100 Subject: [PATCH v2 1/2] net/9p: distinguish zero-copy requests To: Dominique Martinet , Stefano Stabellini Cc: v9fs-developer@lists.sourceforge.net, linux-kernel@vger.kernel.org, GUO Zihua Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add boolean `zc` member to struct p9_fcall to distinguish zero-copy messages (not using the linear `sdata` buffer for message payload) from regular messages (which do copy message payload to `sdata` before being further processed). This new member is appended to end of structure to avoid inserting huge padding in generated layout. Signed-off-by: Christian Schoenebeck Tested-by: Stefano Stabellini --- include/net/9p/9p.h | 2 ++ net/9p/client.c | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/include/net/9p/9p.h b/include/net/9p/9p.h index 13abe013af21..429adf6be29c 100644 --- a/include/net/9p/9p.h +++ b/include/net/9p/9p.h @@ -531,6 +531,7 @@ struct p9_rstatfs { * @offset: used by marshalling routines to track current position in buff= er * @capacity: used by marshalling routines to track total malloc'd capacity * @sdata: payload + * @zc: whether zero-copy is used * * &p9_fcall represents the structure for all 9P RPC * transactions. Requests are packaged into fcalls, and reponses @@ -549,6 +550,7 @@ struct p9_fcall { =20 struct kmem_cache *cache; u8 *sdata; + bool zc; }; =20 int p9_errstr2errno(char *errstr, int len); diff --git a/net/9p/client.c b/net/9p/client.c index aaa37b07e30a..c7935e392812 100644 --- a/net/9p/client.c +++ b/net/9p/client.c @@ -680,6 +680,9 @@ p9_client_rpc(struct p9_client *c, int8_t type, const c= har *fmt, ...) if (IS_ERR(req)) return req; =20 + req->tc.zc =3D false; + req->rc.zc =3D false; + if (signal_pending(current)) { sigpending =3D 1; clear_thread_flag(TIF_SIGPENDING); @@ -778,6 +781,9 @@ static struct p9_req_t *p9_client_zc_rpc(struct p9_clie= nt *c, int8_t type, if (IS_ERR(req)) return req; =20 + req->tc.zc =3D true; + req->rc.zc =3D true; + if (signal_pending(current)) { sigpending =3D 1; clear_thread_flag(TIF_SIGPENDING); --=20 2.30.2 From nobody Wed Apr 15 21:53:36 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C1707C4332F for ; Tue, 22 Nov 2022 20:08:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234302AbiKVUId (ORCPT ); Tue, 22 Nov 2022 15:08:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232544AbiKVUIb (ORCPT ); Tue, 22 Nov 2022 15:08:31 -0500 X-Greylist: delayed 2102 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Tue, 22 Nov 2022 12:08:29 PST Received: from lizzy.crudebyte.com (lizzy.crudebyte.com [91.194.90.13]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 315E060689 for ; Tue, 22 Nov 2022 12:08:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=RO9sw++pfIwBQdkuVrGjUBNV/KCLhBvtU55dRc8P7k8=; b=SEDZw uJPp3QAdKV2/6R69RAmA2HRkixKOkz0+jR19ECNUXvqsSL6i2E3aamX7XldA0sdG46uR2X5/ehEdV eZoeBcw145ak0lHUN9vdkr0oB5QkX4p8D7oRju6wZUzxBN6IBxbJ6CQ6gZ48uHwEBPCIz8djTg/eT ELv1xOnFQ3GYraTqq9xrSu0gh/R9NSCK6kSbP/rDdQMKQ3gVg96O9EKv98wD2ZMflzzkTOwMBBCpB kx7pPsWvXKnTgNTXMzwM3paxurtqMkJdEtLQ5Z7368M2rpuxNyCCKT2qkj2R4DTy2rc2POpetL+O+ 8S1+NAtLQ45UHlmK2taD/jO2NWV3Q==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Tue, 22 Nov 2022 20:20:29 +0100 Subject: [PATCH v2 2/2] net/9p: fix response size check in p9_check_errors() To: Dominique Martinet , Stefano Stabellini Cc: v9fs-developer@lists.sourceforge.net, linux-kernel@vger.kernel.org, GUO Zihua Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Since commit 60ece0833b6c ("net/9p: allocate appropriate reduced message buffers") it is no longer appropriate to check server's response size against msize. Check against the previously allocated buffer capacity instead. - Omit this size check entirely for zero-copy messages, as those always allocate 4k (P9_ZC_HDR_SZ) linear buffers which are not used for actual payload and can be much bigger than 4k. - Replace p9_debug() by pr_err() to make sure this message is always printed in case this error is triggered. - Add 9p message type to error message to ease investigation. Signed-off-by: Christian Schoenebeck Tested-by: Stefano Stabellini Reported-by: kernel test robot --- net/9p/client.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/net/9p/client.c b/net/9p/client.c index c7935e392812..0ff25c2157ab 100644 --- a/net/9p/client.c +++ b/net/9p/client.c @@ -514,10 +514,9 @@ static int p9_check_errors(struct p9_client *c, struct= p9_req_t *req) int ecode; =20 err =3D p9_parse_header(&req->rc, NULL, &type, NULL, 0); - if (req->rc.size >=3D c->msize) { - p9_debug(P9_DEBUG_ERROR, - "requested packet size too big: %d\n", - req->rc.size); + if (req->rc.size > req->rc.capacity && !req->rc.zc) { + pr_err("requested packet size too big: %d does not fit %zu (type=3D%d)\n= ", + req->rc.size, req->rc.capacity, req->rc.id); return -EIO; } /* dump the response from server --=20 2.30.2