Message ID | 1675900204-1953-1-git-send-email-mikelley@microsoft.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp9664wrn; Wed, 8 Feb 2023 15:51:39 -0800 (PST) X-Google-Smtp-Source: AK7set++J4/pKpVYE9IAscibKvbZ4DSljTp+RDt5TxZeMdA+U+LSJE5Fc2mhsW2jatUR20jQNYQp X-Received: by 2002:a05:6402:35ce:b0:4ab:178f:e316 with SMTP id z14-20020a05640235ce00b004ab178fe316mr1082618edc.0.1675900299095; Wed, 08 Feb 2023 15:51:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1675900299; cv=pass; d=google.com; s=arc-20160816; b=skgnTGnBmn6O3cLJpM0/3YFs0k4S9zB2KUVzaWMO47MTRQfgL8cCHC+dMdmRpSZPDe sW9XiOdb401iCrO/FMBuLVbSSV5cYme+rGqE5gZQLYvmdd7kOSKdC3UH7dRf+tO1XIu4 ilaZZpOlWHLLNdLTUM3aRnTSWKbBA0dQj1cDP3eKem8Lht9h8ZjBDGsdTKIZBlzgk1/I MXXrtCOAKjFCv99K4gyiwYjn5MyfgLNCqxYmqOycuGiU5TXnJ3IP3zzyb5LdxxDpGy8V F4hdpDWFnnOT6TFisCF//aac87pPYL9SLN4xeiFJ+qmWTAVBNe9E5kyzr+/iZ9vJGKYM bacg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from :dkim-signature; bh=QTrlrNsgGBjmPWCO7OTllFbUZVUt298srufnD1ny7BA=; b=IFLWh0jRS+rZpcTKsscX857QEvZ76F4lK/zyYSDNTkVFFOMaSHAF17GIveXWbKsDjQ DJPU2aGfYI0Qde1pHrlT49LIvqI+vOAllJprKn4VGEE03P7ktySS/1TsK0spUEUMxlQW aJtNpMof/1ShrH9152+Ne41y5r+gxH6miJysyBaTPkAKvRSxlL9EIjxRMdCf3ODTFv5G mMaQIX8yCWcaHjnbuQDWJrVqRvGehoKL/KLyuz6xctFSH/aboN4It8IHI3Q6tX/39iMd 7UcLEgRItfVsEyi1h1XHyQ+lPet7eH4Pu5lCnaLrXU25E8kQnxkNmY+q/YFRB7ZXhb0E D4Rw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector2 header.b=ar9Pg0UR; arc=pass (i=1 spf=pass spfdomain=microsoft.com dkim=pass dkdomain=microsoft.com dmarc=pass fromdomain=microsoft.com); 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=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b7-20020aa7d487000000b004ab16fb53e2si70096edr.566.2023.02.08.15.51.15; Wed, 08 Feb 2023 15:51: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=@microsoft.com header.s=selector2 header.b=ar9Pg0UR; arc=pass (i=1 spf=pass spfdomain=microsoft.com dkim=pass dkdomain=microsoft.com dmarc=pass fromdomain=microsoft.com); 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=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230044AbjBHXu1 (ORCPT <rfc822;ivan.orlov0322@gmail.com> + 99 others); Wed, 8 Feb 2023 18:50:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230036AbjBHXuZ (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 8 Feb 2023 18:50:25 -0500 Received: from DM6FTOPR00CU001-vft-obe.outbound.protection.outlook.com (mail-cusazon11020026.outbound.protection.outlook.com [52.101.61.26]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F18E99EFC; Wed, 8 Feb 2023 15:50:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OY9O0ePJW+VEzjcpklPBAFVLu2NuuY7LkupIt5CqTq7aw11asbgC1OFY2KzN2+fGpJCcw/M231iM9vP7OCPOO2eUl3WK2AqnbGukPMQ1mkkF5gym5kKWoLMgs/A3kiUnUrUoD0Nkl944AHcE9bS2x0vWqdTDhDK6UgqtS6H/fDKLdn3edwry2dZoV3tjiPfwdfBUdCdgV9tmE3HuI/x8tA1hkPj0oQoAyGkVbW6GrHJ/LjkHeGlWQ9EegNHE4/ZID/+JerBMGY+AUO5ARohf8WqE/5y9eulAYQNyp652Zgp1H59zyOtA8M4DQLobJpWpOUGHHb9jQ2zr5VDvfVQ1zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=QTrlrNsgGBjmPWCO7OTllFbUZVUt298srufnD1ny7BA=; b=TOIzkKK455wQkk5tDTsCL11u1niCN3RHnr3ZGbX6mmETNu5xInIthUQ2bLjexb93C6qQB3yjNQpCxYz7c1ibqzFHh3bV9cENmib9weRjrEFJn3qu1E1EZXzT5uegb21Ccp8yHfIKvHE9N1H2AAQGMZvF2nN86hejKDAAUSIo1nnse5U2dWx2KhthYvWYOZX39XqvnNgO0W/6nj5pNfSLkrbNmJlRiC1hOyPjjFaSG9907nny4TofWWQ2GPbZbh+Jesv2/ZPyNMOIUsLiacqosJvSqJsnhPKsVIqI72x6ndGLNL7ik1NmsPy7VoytOavQVK7IbPwc429mKQZ7quRakA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QTrlrNsgGBjmPWCO7OTllFbUZVUt298srufnD1ny7BA=; b=ar9Pg0URetBLOGKCmgPVfo8z4BmMJDba4NLp2wD0Bv6C0UldBT3aJT7UzCUs0cULxpY/lMoa/FuicBpc1xuel15I8cBWcZbohV8mIwkn7YOGdfVzw7I3j44KeoyxLmOxrlNs5RAKidGv/PZZacIBmGLVaUfBsyYACixofQXC3O4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=microsoft.com; Received: from DM6PR21MB1370.namprd21.prod.outlook.com (2603:10b6:5:16b::28) by CH2PR21MB1384.namprd21.prod.outlook.com (2603:10b6:610:8c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.3; Wed, 8 Feb 2023 23:50:15 +0000 Received: from DM6PR21MB1370.namprd21.prod.outlook.com ([fe80::73b8:4677:8c77:5da0]) by DM6PR21MB1370.namprd21.prod.outlook.com ([fe80::73b8:4677:8c77:5da0%6]) with mapi id 15.20.6111.003; Wed, 8 Feb 2023 23:50:15 +0000 From: Michael Kelley <mikelley@microsoft.com> To: kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org Cc: mikelley@microsoft.com Subject: [PATCH net-next 1/1] hv_netvsc: Check status in SEND_RNDIS_PKT completion message Date: Wed, 8 Feb 2023 15:50:04 -0800 Message-Id: <1675900204-1953-1-git-send-email-mikelley@microsoft.com> X-Mailer: git-send-email 1.8.3.1 Content-Type: text/plain X-ClientProxiedBy: MW4PR03CA0039.namprd03.prod.outlook.com (2603:10b6:303:8e::14) To DM6PR21MB1370.namprd21.prod.outlook.com (2603:10b6:5:16b::28) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR21MB1370:EE_|CH2PR21MB1384:EE_ X-MS-Office365-Filtering-Correlation-Id: ed4056c9-6a57-4873-8409-08db0a2f3984 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XxS3ynZ4Mpet2EGmbAoT4QLwKh64OP9R+HawTC0E/52DSVPvP93XB0wMYo82KXUdfYHmZOXT2s7pJIA7t37Qd/RSrpF9MrWH7H6pvdpuTxj0gLPC/JG9dPGrlN+B6xjrSP87C9eh6w+m4fpR2Q7aZs6n72C0uS1ojerVoTPA+cxNqY+IzgjoCjJ3JvzbMk6WuDQ0pj+IvhZ0xBB+25l1yJFP3p8JZxgE3auveGEXxdLi2BFfk/X5rq5NqH91t6kEHE2ZjdBPH2tsgl/j4ZDEGFL5R9mnYG5aYJ6T/a6z9QMZXZRjya09gGneU8uC+Et/n5ROYGgRAPFtGtbOeOpEY14fEb7mCxXDGwihEnu3MnR5Z3YCTwjq48oHi/FzdisbQJeRIs8/LMGW8z8wSV+BWbdV+AzhwHkS9kyPYEAAZl1w0hlAx2y68wi9DOFXf26KUK9DVWIFQnhzpYAeFmNgk0mSeHeHbPoetkh6SAR/teplrpJj73wMOARXVwnCC4/ytaBMkHXr7sfhGNCIeC742iqN11+VAOTyxSZSlQ6jwaFQ75zgSRh2u2Sue/Zj+Bndp0mkEVgM8z0WPgeJlmr91kI8/U04Ro4c06GKKkoWKE6h239nqouKiiX336PSOQ4upBce+Is0SdGsNdjp5hoM9lAecJ1UmLAdE+RqNW61ue20FhKbRThHpTbySzX7FIHZWWdiqD1xkmwluaKKh0w6w1ecE+WyizuIWVvkvFPea+NOH2baFAx4HDzc4RjglrawwUwcJz2jzUU9ouYedhMwJQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR21MB1370.namprd21.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(346002)(376002)(39860400002)(366004)(136003)(396003)(451199018)(36756003)(2616005)(66476007)(107886003)(6506007)(6666004)(82960400001)(83380400001)(6486002)(82950400001)(38100700002)(38350700002)(8936002)(52116002)(478600001)(186003)(86362001)(26005)(41300700001)(2906002)(15650500001)(6512007)(5660300002)(316002)(921005)(10290500003)(66556008)(66946007)(4326008)(8676002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: z6IbIqyDH357AMGhXQy4S+lJZdqjMmiVuk+8IkgzpTQT+c01syjwVZXtaztfKMpyz+Ht9U/X7cD0RMkqZIKL2aeYrNrmAjR+m0ps8GmOnuPDLL/sp8WU/Mk/lIAD/sypviT2B0Ur2UUEVKMnEgqulPaWxSFciznuDm2IQWjFVVcCFM5IcrJ6whmyWUUGlxvUFUjT5UGSb3PF4UKlYalgafAKyOCcfGAYPkT0eWP8jbg3bsg5Apv1iklDQ+mdyGLpsiG7YcUMgVN6DC6l6SlHiK7grLvUIV5DiAcKVxQ/oGrpR2LttpsQij2D8qlNoGDZijUNxJT8YTa3MLmKuiWXjuOGY7PTBojNUBMnvwZHsTQOQiwAsJG55sPVhUjDloRjgRnbTSDGLE6icmNB7R4WaKjYA1bc9neuQu0ZVRbhh+RJpwtOGC0qY8ZSV3RPbOfPtGabfrRfQp9/BEYSXakJQS/xlI1oDCUbV7EV85Pzuk28BBv0wdjtfsVUKjL+VjQp8O4ZqGlxF3X1+pHT73LtfWNHok/P2sfolGbV2hSOKIpQ9VoSUw1UvUCnm2z0d7RB68aQgbe7+OLeD8H/HQbzrije8aKDo5zh6MEMfEnc2c98QLi596f4iLdrg90Ram73Inhd1XTkw9ve1StOTZ8xoxHnHCaClyO4Qfof/VrjPqgpkAuUbdkEVEFX68nTH9lMxebjFv8pnvf6ge0Xd8qkFGIUuTn7YGaNX4abgVG4JNmv5OXUKiEvxhhRedv3UzfPq+CDgruPZY8nVlFCrpW9/Q8zkjBAJP8mYwFXg/4Zhpk9izp7mEXknD35Da68cPrTtasodq9anUc3WbwJGWiIfwMcikWal72Ir86S7Dnoo5lgZktwx8FXAJwSgk03em12r/nx9THOQMMxpVfDPyLVwcIZOpL221O7LuupTVZ8J61K5nsyPNdTv1FI6EByZsumNyirCDacDVXMli2+9Xh+lRipNXJTU1ptoYst4TkEgfrBy+Mr55eLK9+SxSDM7o4DaRchxF6aMLNMGHO1966b1rDISWPSxMEz6H1zFTZTKRN2veQpVUONvsz+mS8Z1oTydDPfIIY6eS6kgIPQQPqXZzA9t+7ld/fCKG6hwk81EVgB0lbajY7LARIM6amVhUUJ+gA6YTcA8NrEa+Kua+E8CWfaAk05+rWWnM68eh8IfUDoTkzkOn5c1ORrgRjieTBEqD6zSK1f0xqgKeYR+WwFXJzXWpXeCzlaDje/am0VY49G5Z8THtvs62GquD/opICRk3wHjFMO6epp2Edzh+Ied1raQQxk6rFh6EqU0N0envl7Wzt6IPtowG7bQy8xy1jaDisH3egen/Y18RSGSEG4YfMqCksyG8N8B/wGUbixh0RovUHfvRL4pWIvnDdkOiFi7rMCoEaVPKmxIt+ijY8D6endQgZ3QB6Z7hqhOr9D6+i9m7ydYeF+wxqqBEU43LH43mcum2fEp0MpDK68XWEGeoYvAMYo304IJTZvbtumg0fssfho/mFYCSVSxqPniCyzkOR0lSFxpbD6sR7eLx8LehXwWxDWdsSNQNrwijvoCQ3P6vWbJE6Yd++Z5MXWumh93T8Xyi5aFcMYrnF188k0Hw== X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: ed4056c9-6a57-4873-8409-08db0a2f3984 X-MS-Exchange-CrossTenant-AuthSource: DM6PR21MB1370.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Feb 2023 23:50:14.9502 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: FJB5I8YYx0Qz4k9JibSYN0kEjdSZZaR+/egNDU6z9wGyznhg2K5jTgr5OLk+SepUpAsAPWBrKkre/MpeLhZR4A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR21MB1384 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_NONE autolearn=no 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757308832131630463?= X-GMAIL-MSGID: =?utf-8?q?1757308832131630463?= |
Series |
[net-next,1/1] hv_netvsc: Check status in SEND_RNDIS_PKT completion message
|
|
Commit Message
Michael Kelley (LINUX)
Feb. 8, 2023, 11:50 p.m. UTC
Completion responses to SEND_RNDIS_PKT messages are currently processed
regardless of the status in the response, so that resources associated
with the request are freed. While this is appropriate, code bugs that
cause sending a malformed message, or errors on the Hyper-V host, go
undetected. Fix this by checking the status and outputting a message
if there is an error.
Signed-off-by: Michael Kelley <mikelley@microsoft.com>
---
drivers/net/hyperv/netvsc.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
Comments
> -----Original Message----- > From: Michael Kelley (LINUX) <mikelley@microsoft.com> > Sent: Wednesday, February 8, 2023 6:50 PM > To: KY Srinivasan <kys@microsoft.com>; Haiyang Zhang > <haiyangz@microsoft.com>; wei.liu@kernel.org; Dexuan Cui > <decui@microsoft.com>; davem@davemloft.net; edumazet@google.com; > kuba@kernel.org; pabeni@redhat.com; netdev@vger.kernel.org; linux- > hyperv@vger.kernel.org; linux-kernel@vger.kernel.org > Cc: Michael Kelley (LINUX) <mikelley@microsoft.com> > Subject: [PATCH net-next 1/1] hv_netvsc: Check status in SEND_RNDIS_PKT > completion message > > Completion responses to SEND_RNDIS_PKT messages are currently processed > regardless of the status in the response, so that resources associated > with the request are freed. While this is appropriate, code bugs that > cause sending a malformed message, or errors on the Hyper-V host, go > undetected. Fix this by checking the status and outputting a message > if there is an error. > > Signed-off-by: Michael Kelley <mikelley@microsoft.com> > --- > drivers/net/hyperv/netvsc.c | 17 +++++++++++++++++ > 1 file changed, 17 insertions(+) > > diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c > index 661bbe6..caf22e9 100644 > --- a/drivers/net/hyperv/netvsc.c > +++ b/drivers/net/hyperv/netvsc.c > @@ -813,6 +813,7 @@ static void netvsc_send_completion(struct net_device > *ndev, > u32 msglen = hv_pkt_datalen(desc); > struct nvsp_message *pkt_rqst; > u64 cmd_rqst; > + u32 status; > > /* First check if this is a VMBUS completion without data payload */ > if (!msglen) { > @@ -884,6 +885,22 @@ static void netvsc_send_completion(struct > net_device *ndev, > break; > > case NVSP_MSG1_TYPE_SEND_RNDIS_PKT_COMPLETE: > + if (msglen < sizeof(struct nvsp_message_header) + > + sizeof(struct > nvsp_1_message_send_rndis_packet_complete)) { > + netdev_err(ndev, "nvsp_rndis_pkt_complete length > too small: %u\n", > + msglen); > + return; > + } > + > + /* If status indicates an error, output a message so we know > + * there's a problem. But process the completion anyway so > the > + * resources are released. > + */ > + status = nvsp_packet- > >msg.v1_msg.send_rndis_pkt_complete.status; > + if (status != NVSP_STAT_SUCCESS) > + netdev_err(ndev, "nvsp_rndis_pkt_complete error > status: %x\n", > + status); > + Could you add rate limit to this error, so in case it happens frequently, the errors won't fill up the dmesg. Or even better, add a counter for this. Thanks, - Haiyang
From: Haiyang Zhang <haiyangz@microsoft.com> Sent: Thursday, February 9, 2023 5:49 AM > > > -----Original Message----- > > From: Michael Kelley (LINUX) <mikelley@microsoft.com> > > Sent: Wednesday, February 8, 2023 6:50 PM > > To: KY Srinivasan <kys@microsoft.com>; Haiyang Zhang > > <haiyangz@microsoft.com>; wei.liu@kernel.org; Dexuan Cui > > <decui@microsoft.com>; davem@davemloft.net; edumazet@google.com; > > kuba@kernel.org; pabeni@redhat.com; netdev@vger.kernel.org; linux- > > hyperv@vger.kernel.org; linux-kernel@vger.kernel.org > > Cc: Michael Kelley (LINUX) <mikelley@microsoft.com> > > Subject: [PATCH net-next 1/1] hv_netvsc: Check status in SEND_RNDIS_PKT > > completion message > > > > Completion responses to SEND_RNDIS_PKT messages are currently processed > > regardless of the status in the response, so that resources associated > > with the request are freed. While this is appropriate, code bugs that > > cause sending a malformed message, or errors on the Hyper-V host, go > > undetected. Fix this by checking the status and outputting a message > > if there is an error. > > > > Signed-off-by: Michael Kelley <mikelley@microsoft.com> > > --- > > drivers/net/hyperv/netvsc.c | 17 +++++++++++++++++ > > 1 file changed, 17 insertions(+) > > > > diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c > > index 661bbe6..caf22e9 100644 > > --- a/drivers/net/hyperv/netvsc.c > > +++ b/drivers/net/hyperv/netvsc.c > > @@ -813,6 +813,7 @@ static void netvsc_send_completion(struct net_device *ndev, > > u32 msglen = hv_pkt_datalen(desc); > > struct nvsp_message *pkt_rqst; > > u64 cmd_rqst; > > + u32 status; > > > > /* First check if this is a VMBUS completion without data payload */ > > if (!msglen) { > > @@ -884,6 +885,22 @@ static void netvsc_send_completion(struct net_device *ndev, > > break; > > > > case NVSP_MSG1_TYPE_SEND_RNDIS_PKT_COMPLETE: > > + if (msglen < sizeof(struct nvsp_message_header) + > > + sizeof(struct nvsp_1_message_send_rndis_packet_complete)) { > > + netdev_err(ndev, "nvsp_rndis_pkt_complete length too small: %u\n", > > + msglen); > > + return; > > + } > > + > > + /* If status indicates an error, output a message so we know > > + * there's a problem. But process the completion anyway so the > > + * resources are released. > > + */ > > + status = nvsp_packet->msg.v1_msg.send_rndis_pkt_complete.status; > > + if (status != NVSP_STAT_SUCCESS) > > + netdev_err(ndev, "nvsp_rndis_pkt_complete error status: %x\n", > > + status); > > + > > Could you add rate limit to this error, so in case it happens frequently, the > errors won't fill up the dmesg. > > Or even better, add a counter for this. I thought about rate limiting. But my assumption is that such errors are very rare, and that it would be better to see all occurrences instead of potentially filtering some out due to rate limiting. If that assumption proves to not be true, then we probably have a bigger problem -- there's a bug in the Linux guest causing it to submit bad requests, or there's a bug on the Hyper-V side. That said, I don't feel strongly about it either way. Thoughts? Michael
> -----Original Message----- > From: Michael Kelley (LINUX) <mikelley@microsoft.com> > Sent: Thursday, February 9, 2023 12:11 PM > To: Haiyang Zhang <haiyangz@microsoft.com>; KY Srinivasan > <kys@microsoft.com>; wei.liu@kernel.org; Dexuan Cui > <decui@microsoft.com>; davem@davemloft.net; edumazet@google.com; > kuba@kernel.org; pabeni@redhat.com; netdev@vger.kernel.org; linux- > hyperv@vger.kernel.org; linux-kernel@vger.kernel.org > Subject: RE: [PATCH net-next 1/1] hv_netvsc: Check status in > SEND_RNDIS_PKT completion message > > From: Haiyang Zhang <haiyangz@microsoft.com> Sent: Thursday, February 9, > 2023 5:49 AM > > > > > -----Original Message----- > > > From: Michael Kelley (LINUX) <mikelley@microsoft.com> > > > Sent: Wednesday, February 8, 2023 6:50 PM > > > To: KY Srinivasan <kys@microsoft.com>; Haiyang Zhang > > > <haiyangz@microsoft.com>; wei.liu@kernel.org; Dexuan Cui > > > <decui@microsoft.com>; davem@davemloft.net; edumazet@google.com; > > > kuba@kernel.org; pabeni@redhat.com; netdev@vger.kernel.org; linux- > > > hyperv@vger.kernel.org; linux-kernel@vger.kernel.org > > > Cc: Michael Kelley (LINUX) <mikelley@microsoft.com> > > > Subject: [PATCH net-next 1/1] hv_netvsc: Check status in > SEND_RNDIS_PKT > > > completion message > > > > > > Completion responses to SEND_RNDIS_PKT messages are currently > processed > > > regardless of the status in the response, so that resources associated > > > with the request are freed. While this is appropriate, code bugs that > > > cause sending a malformed message, or errors on the Hyper-V host, go > > > undetected. Fix this by checking the status and outputting a message > > > if there is an error. > > > > > > Signed-off-by: Michael Kelley <mikelley@microsoft.com> > > > --- > > > drivers/net/hyperv/netvsc.c | 17 +++++++++++++++++ > > > 1 file changed, 17 insertions(+) > > > > > > diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c > > > index 661bbe6..caf22e9 100644 > > > --- a/drivers/net/hyperv/netvsc.c > > > +++ b/drivers/net/hyperv/netvsc.c > > > @@ -813,6 +813,7 @@ static void netvsc_send_completion(struct > net_device *ndev, > > > u32 msglen = hv_pkt_datalen(desc); > > > struct nvsp_message *pkt_rqst; > > > u64 cmd_rqst; > > > + u32 status; > > > > > > /* First check if this is a VMBUS completion without data payload */ > > > if (!msglen) { > > > @@ -884,6 +885,22 @@ static void netvsc_send_completion(struct > net_device *ndev, > > > break; > > > > > > case NVSP_MSG1_TYPE_SEND_RNDIS_PKT_COMPLETE: > > > + if (msglen < sizeof(struct nvsp_message_header) + > > > + sizeof(struct > nvsp_1_message_send_rndis_packet_complete)) { > > > + netdev_err(ndev, "nvsp_rndis_pkt_complete length > too small: %u\n", > > > + msglen); > > > + return; > > > + } > > > + > > > + /* If status indicates an error, output a message so we know > > > + * there's a problem. But process the completion anyway so > the > > > + * resources are released. > > > + */ > > > + status = nvsp_packet- > >msg.v1_msg.send_rndis_pkt_complete.status; > > > + if (status != NVSP_STAT_SUCCESS) > > > + netdev_err(ndev, "nvsp_rndis_pkt_complete error > status: %x\n", > > > + status); > > > + > > > > Could you add rate limit to this error, so in case it happens frequently, the > > errors won't fill up the dmesg. > > > > Or even better, add a counter for this. > > I thought about rate limiting. But my assumption is that such errors are > very rare, and that it would be better to see all occurrences instead of > potentially filtering some out due to rate limiting. If that assumption > proves to not be true, then we probably have a bigger problem -- there's > a bug in the Linux guest causing it to submit bad requests, or there's a > bug on the Hyper-V side. > > That said, I don't feel strongly about it either way. > > Thoughts? I haven't seen any cases of large amount of TX errors so far (Our existing code doesn't check it). But I'm just worried about if a VM sending at high speed, and host side is, for some reason, not able to send them correctly, the log file will become really big and difficult to download and read. With rate limit, we still see dozens of messages every 5 seconds or so, and it tells you how many messages are skipped. And, if the rate is lower, it won't skip anything. Isn't this info sufficient to debug? By the way, guests cannot trust the host -- probably we shouldn't allow the host to have a way to jam guest's log file? Thanks, - Haiyang
On Thu, 9 Feb 2023 19:10:16 +0000 Haiyang Zhang wrote: > But I'm just worried about if a VM sending at high speed, and host side is, > for some reason, not able to send them correctly, the log file will become > really big and difficult to download and read. With rate limit, we still see > dozens of messages every 5 seconds or so, and it tells you how many > messages are skipped. And, if the rate is lower, it won't skip anything. > Isn't this info sufficient to debug? > > By the way, guests cannot trust the host -- probably we shouldn't allow the > host to have a way to jam guest's log file? +1 FWIW, the general guidance is to always rate limit prints which may be triggered from the datapath (which I'm guessing this is based on the names of things)
From: Jakub Kicinski <kuba@kernel.org> Sent: Thursday, February 9, 2023 12:22 PM > > On Thu, 9 Feb 2023 19:10:16 +0000 Haiyang Zhang wrote: > > But I'm just worried about if a VM sending at high speed, and host side is, > > for some reason, not able to send them correctly, the log file will become > > really big and difficult to download and read. With rate limit, we still see > > dozens of messages every 5 seconds or so, and it tells you how many > > messages are skipped. And, if the rate is lower, it won't skip anything. > > Isn't this info sufficient to debug? Agreed. > > > > By the way, guests cannot trust the host -- probably we shouldn't allow the > > host to have a way to jam guest's log file? Actually, preventing jamming the guest's log file is not a requirement in Confidential VMs where the host is not trusted. Confidential VMs do not prevent denial-of-service attacks, or similar. But that's another topic. :-) > > +1 FWIW, the general guidance is to always rate limit prints > which may be triggered from the datapath (which I'm guessing > this is based on the names of things) Fair enough. I'll do a v2 with the rate limiting. Michael
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c index 661bbe6..caf22e9 100644 --- a/drivers/net/hyperv/netvsc.c +++ b/drivers/net/hyperv/netvsc.c @@ -813,6 +813,7 @@ static void netvsc_send_completion(struct net_device *ndev, u32 msglen = hv_pkt_datalen(desc); struct nvsp_message *pkt_rqst; u64 cmd_rqst; + u32 status; /* First check if this is a VMBUS completion without data payload */ if (!msglen) { @@ -884,6 +885,22 @@ static void netvsc_send_completion(struct net_device *ndev, break; case NVSP_MSG1_TYPE_SEND_RNDIS_PKT_COMPLETE: + if (msglen < sizeof(struct nvsp_message_header) + + sizeof(struct nvsp_1_message_send_rndis_packet_complete)) { + netdev_err(ndev, "nvsp_rndis_pkt_complete length too small: %u\n", + msglen); + return; + } + + /* If status indicates an error, output a message so we know + * there's a problem. But process the completion anyway so the + * resources are released. + */ + status = nvsp_packet->msg.v1_msg.send_rndis_pkt_complete.status; + if (status != NVSP_STAT_SUCCESS) + netdev_err(ndev, "nvsp_rndis_pkt_complete error status: %x\n", + status); + netvsc_send_tx_complete(ndev, net_device, incoming_channel, desc, budget); break;