From patchwork Mon Feb 13 05:08:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael Kelley (LINUX)" X-Patchwork-Id: 56046 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2184357wrn; Sun, 12 Feb 2023 21:29:37 -0800 (PST) X-Google-Smtp-Source: AK7set8sZ14pimYPT7ZRR53EzpWSjiYVFmME5L9iqB93p6PAKhlTE1omoJS8AozGx/l0Rmbd72et X-Received: by 2002:a17:906:85d2:b0:879:767f:6e45 with SMTP id i18-20020a17090685d200b00879767f6e45mr22628812ejy.17.1676266177573; Sun, 12 Feb 2023 21:29:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1676266177; cv=pass; d=google.com; s=arc-20160816; b=S9nRf4iOgEbdJhBsrXwVEk5qJP3H5ym0Di0wM1kaKGuqCXq6bNStARFKkDJleRK0qt bp4MDUUjF4tmqa1zrXKAF1vuLwQ+2iwgxt8OnNZm06oYiwqEdhw+Pue2PdQrpcbklWq4 n317jC1qiK7UduFERabRf88wzKdDkFheqi32SVRe/ubFiGmC9xdKJv1qdhOcObAnaz6S bC6LiMRgyITXc4xjzq3kpsO+yqfajBWdMqS/l8Z5fUTL4KtkozL8YvkkN/GXJ72SItAZ Fp984JB197UGsYGWMFZx0vwGuETakzKU2GnzDQuhFgbe4yszB7dALA5C1EDVV6m3F8xd uEMg== 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=aXV23WKaTR5SPivWsX/fGaAxePQuax//CkkAs6WfjHo=; b=ZaCJUbyCs/KPlUQN2t7UW7Vu/6y8kNRTy9RxmDbYMg9KKv3a6ig9dueHHThbBti/o1 GWBsbqIKOimXT/TcMa3E2H+yDAN5ME57BKCB+t00hF0lvbYtLPNEek45wKppYqueK13a Fi/6okFyhcx2frOqy1W+Z/i2p6qOqUKyvV/YSMi9lDpUqsrEJrvZRAzNV50Q/xKvHEOd La1RO77ZQClKdyR1pzg5zqoVY9aelsDb+7s8X8s/tfbsmQaoKY8+1pXMszZIC3d3xJ1W cua/naMZAy4nWL/6e4STlKl0bzSY3b54OAIUO1IAF0YGbJKnP8BNtLU96N3zHs9TZizC ZBuQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector2 header.b=WTQ3o1gv; 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 r6-20020a170906958600b0088c3baf23a2si12061839ejx.558.2023.02.12.21.29.15; Sun, 12 Feb 2023 21:29:37 -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=WTQ3o1gv; 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 S229536AbjBMFIu (ORCPT + 99 others); Mon, 13 Feb 2023 00:08:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229441AbjBMFIs (ORCPT ); Mon, 13 Feb 2023 00:08:48 -0500 Received: from BN6PR00CU002-vft-obe.outbound.protection.outlook.com (mail-eastus2azon11021022.outbound.protection.outlook.com [52.101.57.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C775DBE8; Sun, 12 Feb 2023 21:08:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z4+oUIXJOpXiCK9JwlMWK9EQkqcNe1+jLefQkWnCggmqs65mNGmdOX4fEM6OpBsu4TQUttQ+e1TYQDrvY87HCkQxF1vIatH9LHitJ5mSLgxSpZ684ByCqG3LFpV7yavOBpTga01OgDlWK3CQFakegT/7zL+21NS+13TjUoOiwRWZ5l48R8kg6N+hgrCswrevj2o3Y22PXjws+y+zw02t7YhhE+aNzA/cX1d+EuCkH/UpvA0RT/tjBSkVJb3tS7sAzgoYA2jj8oK4MHPyHTtbuA6vpEECcSh7X0cwjsKAgmH7x/wOd4GipX/koY/W9nRNVnn5LvbxtYLTu7sRxatxtQ== 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=aXV23WKaTR5SPivWsX/fGaAxePQuax//CkkAs6WfjHo=; b=nRN0ZoAKBfBkwmHwlstSu5qN3ERThW2RhPqiphpsWXkUIaG09tMtH5q71CkePVOVDmVP3nKMEfW+AReOigwzVxku89R4yYq+6v5lVsXw7JJDZNB5swqeGTyCmgoQBWXV1qT1v+obz+G9CxgCaARfwDxi27T5UKXLErH0lOKt8vFLrs8XUpodOTVm34y1LoNBsfrnBH4Jty+ukAxe/ng5R4ZA1l5i57dYH48dMQWCo0fnlvHK5tkKCHDq4WW4NN9jTIUGvzZHuW2/Ohqcm9zfgcs/4oSEAIPzw49ReKceT+5MG10gMNC237AtKhnwum8UG02ChZKw4u4DuN5B5Az9BA== 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=aXV23WKaTR5SPivWsX/fGaAxePQuax//CkkAs6WfjHo=; b=WTQ3o1gvyJyUU1AbZLAfkU6+jEkK2Q88gSN/XKpd6ZBEOve1GWQ6N3kFbBwXwbqRz/uHTSB6U9OQwgISNkCuf2MKt/MpNtRVxyuKYC8Yz17NFqYj+hlgdC1bjtQomLOgkzS4hTUp9keBgqxCLE9dn5QNQid/4pC6h4n3HRlwCC0= 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 BY5PR21MB1444.namprd21.prod.outlook.com (2603:10b6:a03:233::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.2; Mon, 13 Feb 2023 05:08:42 +0000 Received: from DM6PR21MB1370.namprd21.prod.outlook.com ([fe80::caf1:81fb:4297:bf17]) by DM6PR21MB1370.namprd21.prod.outlook.com ([fe80::caf1:81fb:4297:bf17%4]) with mapi id 15.20.6134.002; Mon, 13 Feb 2023 05:08:42 +0000 From: Michael Kelley 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 v3 1/1] hv_netvsc: Check status in SEND_RNDIS_PKT completion message Date: Sun, 12 Feb 2023 21:08:01 -0800 Message-Id: <1676264881-48928-1-git-send-email-mikelley@microsoft.com> X-Mailer: git-send-email 1.8.3.1 X-ClientProxiedBy: MW4PR03CA0306.namprd03.prod.outlook.com (2603:10b6:303:dd::11) 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_|BY5PR21MB1444:EE_ X-MS-Office365-Filtering-Correlation-Id: 38c56dd0-e665-4555-42a5-08db0d805fd0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: j7kPwZ1fBOpwEbJUQWCh+5W8wzOy7E1bYmab2SZEEoUt+IyFRum6YX9dKBGn9CKTRoqUS+BPCA8HwEd4m1P4mmVnZKwAhwnIs/ihaPGaiPnuE7PuYlUjqzYKqB1FyLPrBHdAzCI1OVoK1Gn0aK0Rmoqlz1oMCA/hvS298zEXk7pl8erjZg4BfJf/cO+BsvOzHF8P08nXMMBN1LbjocEJe2+EFO8CVRXN1CHAJubrzcIuMNd7U29cWg+dTO79Zq3LlW4mP+UflG57YY7S8ePDDT0ui7Xg+FkwXtNDmhU9iU0cYvpnhZZZocSLDfZzn4FDLE61vMl+bp8GpcRnlQNTxY1Q25TRtao5lmifH30hoAK3OBznpCzMXzZKrRNFx9zKRuIP+gSNgnaSNwRcPrvXTe5mbZTddeEzwUrwi0vDyFlhv90451NIq5q7lxChMA3h89KXeHe4OLYB2ZZsEAKtNLKY8coxi2iHU/5Z4dRa8epBizFd4m/QQyKrI6nFeQFfxvyCWv5D1GeeEvqB2JETPt9x7BbSzAXWZO1gCm4D8+086vFcGIQNZsyBBnhSrE9g+0sog1lHiCaxazrZtPTfr1qEd8CgFIEPpfll5o2xp5fcHncdiaA5LIcdq3FiMtlS8OfrJ99W6w5i4orD8Cm9ZYOB4omB2UioogaQCb6UiIU4Y8+FROH5BgS9nCuQM8YqPUAGR9Op2uW4stbOCB6rjdjDDbVQ0M3AapP5qOAo4TdCypW7DUANnbs0oji10Zc8cf1r0icPxja36kg3PNIeew== 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)(136003)(366004)(39860400002)(376002)(396003)(346002)(451199018)(2616005)(86362001)(52116002)(83380400001)(2906002)(15650500001)(36756003)(6486002)(478600001)(107886003)(6506007)(6512007)(26005)(6666004)(186003)(10290500003)(38350700002)(921005)(82950400001)(38100700002)(82960400001)(41300700001)(66946007)(5660300002)(8936002)(8676002)(4326008)(66476007)(66556008)(316002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hFmHVbqRcvDBwx2QRqKjWP6IyQD8+/84akvT3mWrm7f46AehO5UjJLF9gDXFfSUnNwTaqHUaYMRJGGq1MdpoAfXMlrgnb8OBjopPZwVV36FYVp7BPE8M1PKXTtzoHJVtZourlCAOT3AOwpz/mIomUkNF8oz93slvIhCSwPPac0tbxN272YXYFRXuUtAmjJpokeOOWdcB7vP+GXFEfWFQVEhrcec5xL912DonqByhvUc+jRp7lqyahLprOgWSNbLkJryWqkzsjf3l07iwt7gTGYNWEFi07ujAyMYQ5wzDSCEmgKaxKMGDoRFOeLsuNFI2JccSe9EkxHsaneqTsRYBsENJKuUTnUMVVSpMML4/fJnZRTs4DOWu7sVz5bRD7eSBgRjJXw0MPHQmRe3k/s9Yxuj7PMwSsSOl6mja098fzP/rJnH7jJwHIaYAU9PSrOymSfRCKiGKSh5iyU6lkusAK1eeOGKzQNGsXXzWcvZjSGc27vDrF5sXKq+HRPjuCvFrj3iZHD3f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4FCvGNdRkAf+4oWB7X2+lhi4Gs/A9nbQ== X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 38c56dd0-e665-4555-42a5-08db0d805fd0 X-MS-Exchange-CrossTenant-AuthSource: DM6PR21MB1370.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2023 05:08:41.9078 (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: szXQyjR1uKG5+Md6AocMSjww6EI2KeGLbJYLrXzqT2QNArKiV16QC3VzP7vI176YDoT5zcC2OjdXRBB2hj7xfw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR21MB1444 X-Spam-Status: No, score=-1.5 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757577525997451773?= X-GMAIL-MSGID: =?utf-8?q?1757692483590093264?= 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 rate-limited message if there is an error. Signed-off-by: Michael Kelley Reviewed-by: Haiyang Zhang --- Changes in v3: * Fix rate-limit logic when msglen is too small [Haiyang Zhang] Changes in v2: * Add rate-limiting to error messages [Haiyang Zhang] drivers/net/hyperv/netvsc.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c index 661bbe6..f702807 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,23 @@ 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)) { + if (net_ratelimit()) + 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 && net_ratelimit()) + netdev_err(ndev, "nvsp_rndis_pkt_complete error status: %x\n", + status); + netvsc_send_tx_complete(ndev, net_device, incoming_channel, desc, budget); break;