From patchwork Mon Nov 21 23:03:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 24056 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1908126wrr; Mon, 21 Nov 2022 16:11:02 -0800 (PST) X-Google-Smtp-Source: AA0mqf5Vva6xlNHBJRkCEyTWYhyJY0XbQfPLurVlMGfUX67LUKhHRut1riY7FoWT1wHpERk98/6c X-Received: by 2002:a17:903:291:b0:186:994b:5b55 with SMTP id j17-20020a170903029100b00186994b5b55mr14608680plr.100.1669075862486; Mon, 21 Nov 2022 16:11:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669075862; cv=none; d=google.com; s=arc-20160816; b=FTaVuuswLMIGm9DKOjLzKeyKM+7iWQxjVuukb/1MLofky0ZzBgZzjSml9M6+27pUVJ j1mrKourMTbrb6vjrRylL4bFijISYc0hRLwH+k4XAh56GKzaqR9400UAvUPjV/G91Q81 hhytxIN9/g+DakuzWKVQE7fjVl/MnhtNjf3cPsW8lU+I+JAhEL0WEZo6ViGvPjH0B6VY 5958JjUXCzTBVp2xCsKp7GHcjol1pVAjh7BwZYXhOE3yfNtz3GD25CyTABzmfIOYJULy TmnHLX6VHItc63tZdltKyOHYNFg4ANFHdN8oGgV39/wSQY0mxqUXTOzEhYAzZ5lvr8iR dBxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:date:from:references:in-reply-to :message-id:dkim-signature; bh=tgnR9mH97CXxQYgNtREObSMAVVccFgQyvaAQftuBqys=; b=IcRna1Gtk6Zn+u/XyNLvnOFCepCRDL7WfWGmhn679wjFwhyZCWuEA1jixjTMLCc3a+ W92Wz96axNQTTKssv994iqsODLH00+TVGcwAl6W8yzGLull2UmybZde5lE03Ke+EcEuk XwFbzDMAvEPGwA2FGLoqFV0wDHBUTGj6iDt3WFzVwk4XajHUMqneV1GonyNujx6zjd3L 51WMOlZx/g/BU2oF59zBv8frSJugC76FLXzn3ijck0yqrZ8YjZz5mrEqduyDyNjebTFF sqqPSKQ47wWVTXYoyl/xDl53zFsYHcKANaA9NhgTcFDO0CiA8DmX09B5XJLq3lktc14b JNmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@crudebyte.com header.s=lizzy header.b=E9Yu+lHk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=crudebyte.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b4-20020a656684000000b004700f0c1aa0si12908546pgw.139.2022.11.21.16.10.48; Mon, 21 Nov 2022 16:11:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@crudebyte.com header.s=lizzy header.b=E9Yu+lHk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=crudebyte.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231617AbiKUX4j (ORCPT + 99 others); Mon, 21 Nov 2022 18:56:39 -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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750152891181818182?= X-GMAIL-MSGID: =?utf-8?q?1750152891181818182?= Signed-off-by: Christian Schoenebeck --- 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 buffer * @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 { size_t offset; size_t capacity; + bool zc; 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 char *fmt, ...) if (IS_ERR(req)) return req; + req->tc.zc = req->rc.zc = false; + if (signal_pending(current)) { sigpending = 1; clear_thread_flag(TIF_SIGPENDING); @@ -778,6 +780,8 @@ static struct p9_req_t *p9_client_zc_rpc(struct p9_client *c, int8_t type, if (IS_ERR(req)) return req; + req->tc.zc = req->rc.zc = true; + if (signal_pending(current)) { sigpending = 1; clear_thread_flag(TIF_SIGPENDING); From patchwork Mon Nov 21 23:04:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 24055 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1907883wrr; Mon, 21 Nov 2022 16:10:32 -0800 (PST) X-Google-Smtp-Source: AA0mqf48/RoSVVRp3HIkYaPjDYZp+qomi0wlHsewaECI/FMM0on6T5Nx0iZ3uBlMIQg9F2ly797N X-Received: by 2002:a17:902:848d:b0:185:378d:7c18 with SMTP id c13-20020a170902848d00b00185378d7c18mr13599880plo.21.1669075831928; Mon, 21 Nov 2022 16:10:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669075831; cv=none; d=google.com; s=arc-20160816; b=vSiGXdgE79yQaC+g0nuR4N1jLHUfw2WJHDCXMK90g31joSFemKW+FGZ2/bgynM9dqp IZUJJGTjIf73++Mc0AN8sum+qpS5JRiWXVqdYn7+lKFv+WSJnpEZ9kPdtD8e/sX30tRL kEF+U0DQmY91WJHaPWBXeKHp7E7A/VLG1m5ngRRcoae4LahwF6CW3Ti0BWSU1yQJaq8Q aCz2Cy1q4P2ofrgdyV5rs09P7lzRnYZopG3E1ZZK4miO794q5dH9QRs/UwblrwBPid1f OeFpkJlJigN80h4Ce9bWsWkCTM20MlM0PbscLuGH5d8G4DEzajwsw3pdc9dqxyJmrGsD wdBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:date:from:references:in-reply-to :message-id:dkim-signature; bh=O2ndXwHNWzZYBOJ5a+JRMM+u+i9Ll5yf5vhTnt2nMGM=; b=NEfvUuEHnaONVVlMkVwivPrE98zKBLx3+c0WD2xOSmreW3JDhT2DsadPSRdc/o5rZM MKw5vRyiqR9KxMP51fZ9GDb+LorsKV3JCxPKV8G8yYFPkwS3oxdfp9a60KsLWZfUrti+ XQ69/St0uwutFuc0JkfbWOna9AZ7TaLsKq1Rxs0XKNdNPIRXVwWVQx2nbg3rMIg5L/eO CdUCdIwspH87Mvx99y1CaIVqTtU/DTgM4keStBMwDMOL8q+a2q7HVC4yDLRSu1EO6bmL B5GNHxhEc4XItmX9QNTi2+XLCccyqhATt5dnORStcQ+tfF9ISCTEvAFuvfBGjZ0aRPfa cfHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@crudebyte.com header.s=lizzy header.b=gT6vuVeA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=crudebyte.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u13-20020a056a00158d00b005718306bf3bsi13250515pfk.278.2022.11.21.16.10.18; Mon, 21 Nov 2022 16:10:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@crudebyte.com header.s=lizzy header.b=gT6vuVeA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=crudebyte.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231998AbiKUX4U (ORCPT + 99 others); Mon, 21 Nov 2022 18:56:20 -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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750152859593919665?= X-GMAIL-MSGID: =?utf-8?q?1750152859593919665?= 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 --- 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, struct p9_req_t *req) int ecode; err = p9_parse_header(&req->rc, NULL, &type, NULL, 0); - if (req->rc.size >= 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=%d)\n", + req->rc.size, req->rc.capacity, req->rc.id); return -EIO; } /* dump the response from server