Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5069201rwb; Mon, 21 Nov 2022 16:17:39 -0800 (PST) X-Google-Smtp-Source: AA0mqf7xNOuVZzKF47tNOi1tpMfuL3NMO9X9fCOtfw53Fth9wQik9ZXQ/VWmAvvbjiFLDv1SAm7i X-Received: by 2002:a17:902:ef81:b0:186:ceff:f818 with SMTP id iz1-20020a170902ef8100b00186cefff818mr5444546plb.11.1669076259578; Mon, 21 Nov 2022 16:17:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669076259; cv=none; d=google.com; s=arc-20160816; b=Lvo/n4iIR6wTeol3XnyWdkeacpiWw7ne1mXsExnK514Hf9cDqOHdBRO9a12e1k2Hyj PcgbdcPszqu855wMmTQThPN+lusBBz7GB0ZzgAfw+5j3vq4c2E72SBxml/WfbIVH/pdC Y14RuxjQ6Dg9+EGCXw4186jYaCDJo9qtoT8L0n2K/oDDejE2MGhDKFBW7zthNyDEItEx IqwpwGW4WrluDFl37QkLzkE22aUVeMUiCvG1s8r2n24UTlHrRWQjaEpRuzNcFkkoCLRS slpaVPKps9X98Ou8+mePGFnO3gmf60xoze8Ab9TrUMPZs/ebMnWk5f+tomqFyxRXfreT KcZg== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 23-20020a631557000000b00473d2c2c081si8303383pgv.689.2022.11.21.16.17.27; Mon, 21 Nov 2022 16:17:39 -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 + 92 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 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 -- 2.30.2