From nobody Wed Apr 15 21:53:37 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 E9767C4332F for ; Mon, 21 Nov 2022 23:56:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232086AbiKUX4k (ORCPT ); Mon, 21 Nov 2022 18:56:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232007AbiKUX4f (ORCPT ); Mon, 21 Nov 2022 18:56:35 -0500 X-Greylist: delayed 2262 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Mon, 21 Nov 2022 15:56:19 PST Received: from lizzy.crudebyte.com (lizzy.crudebyte.com [91.194.90.13]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1FF695A5 for ; Mon, 21 Nov 2022 15:56:18 -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=tgnR9mH97CXxQYgNtREObSMAVVccFgQyvaAQftuBqys=; b=E9Yu+ lHkliZDAoyYvYAD6jturTuDXX+OCItfkoQ9Us5KZk7bSgBReREC3t2Bpcr6UkKd9ETiChHrPGOwe7 iQS2thSmpmd9V/g5fuDg7AMtf5Q57oO1hhwBYvemFEoPKAhRJIn2bEHWfa0sAtxCPsDZy86YeWprr QTS3qy4ysHe2yTIoxz1pTXzQSdpnHGyJdR1GF0nszCwYRXlcng+Zf68ouQGuhrtLlxG8sOA9CoMaq a83gUSLgLXcojhlsPYAYwdmbh+yHprDhY0T3KqXq56VMeMuNrz+is5VOehP8KHl5NwGLBJIMkAArk 45P4UsYoQ0jEBTmuMGC3dgI7k94YA==; Message-Id: <5b4019594a93bc77b0e3298457c3d9ec0e08fbb5.1669072186.git.linux_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Tue, 22 Nov 2022 00:03:58 +0100 Subject: [PATCH 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" Signed-off-by: Christian Schoenebeck Tested-by: Stefano Stabellini --- include/net/9p/9p.h | 2 ++ net/9p/client.c | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/include/net/9p/9p.h b/include/net/9p/9p.h index 13abe013af21..b0a6dec20b92 100644 --- a/include/net/9p/9p.h +++ b/include/net/9p/9p.h @@ -530,6 +530,7 @@ struct p9_rstatfs { * @tag: transaction id of the request * @offset: used by marshalling routines to track current position in buff= er * @capacity: used by marshalling routines to track total malloc'd capacity + * @zc: whether zero-copy is used * @sdata: payload * * &p9_fcall represents the structure for all 9P RPC @@ -546,6 +547,7 @@ struct p9_fcall { =20 size_t offset; size_t capacity; + bool zc; =20 struct kmem_cache *cache; u8 *sdata; diff --git a/net/9p/client.c b/net/9p/client.c index aaa37b07e30a..30dd82f49b28 100644 --- a/net/9p/client.c +++ b/net/9p/client.c @@ -680,6 +680,8 @@ 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 req->rc.zc =3D false; + if (signal_pending(current)) { sigpending =3D 1; clear_thread_flag(TIF_SIGPENDING); @@ -778,6 +780,8 @@ 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 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:37 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 2589BC4332F for ; Mon, 21 Nov 2022 23:56:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231826AbiKUX4V (ORCPT ); Mon, 21 Nov 2022 18:56:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231148AbiKUX4N (ORCPT ); Mon, 21 Nov 2022 18:56:13 -0500 X-Greylist: delayed 2254 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Mon, 21 Nov 2022 15:56:10 PST Received: from lizzy.crudebyte.com (lizzy.crudebyte.com [91.194.90.13]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F7A51140 for ; Mon, 21 Nov 2022 15:56:09 -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=O2ndXwHNWzZYBOJ5a+JRMM+u+i9Ll5yf5vhTnt2nMGM=; b=gT6vu VeAinBNNo5tAdvTdyXmXVqultC8L6ZWB61YAijycnbdUll4k4hes2GpTHIE3N0hNDcvGBMfDe9mk2 e2Ohw/x1pTqMthoa8v8E419LXUURYCYeAmVY6G+40DqMF5iylQPVCVPZR/Z/YG7ZI1aNutvNgK4TR RQQNdhfCGtvZ5dsrfP5rVwKC6Tigt+JAiqKEdpPuzAqflbG0wb2/soqw3s4V4jHduGNfB9tfCNZtd ErWcoo1UxodYFLhzMkIVPvQ2j/yEbSL2VNmd4atPIDIgS8nB3NcAB3SNf1+B5x834VmcuVbrNwfDO q5TMmYHeqy+azhGiqnIUSXu7/0ANw==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Tue, 22 Nov 2022 00:04:08 +0100 Subject: [PATCH 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 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 --- net/9p/client.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/net/9p/client.c b/net/9p/client.c index 30dd82f49b28..63f13dd1ecff 100644 --- a/net/9p/client.c +++ b/net/9p/client.c @@ -514,10 +514,10 @@ static int p9_check_errors(struct p9_client *c, struc= t 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 %ld (type=3D%d)\n", + req->rc.size, req->rc.capacity, req->rc.id); return -EIO; } /* dump the response from server --=20 2.30.2