From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=40.93.194.43 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796136696; b=Xe7Hzy1qBCyn+Yauv6WJB3xmEB6XnHjjYctl5LsXoQ98uXkH0CT7KALkNWtJIi0PI0o4 IJ000Ki44EFWcQLPegupODlZh5gHIMwvQd05tkkQcIgjQSypRXNMKYjpOi/d0gbAf4Zj8 K14lkaAyY2Q0CKYrWxQn/MIpKHQJxB3u+/gHgMw59hABwB8QhKziriI2LcJnGL131jaPj 3jkYGO47SfIQWYaduMK/28BW8aFaCMuNjyVPNKsBWRwhOpXUWW7/FMjZeq9DEGmt0CxjZ zg5YkOGzDBW5PLHmIQA4zgl98S1zklyLzS8kTgS9ayRKh2gzfgQM3gqliByDczI67gg== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796136696; h=DMARC-Filter:DKIM-Signature:Received:Received:Message-ID:Date: User-Agent:Subject:To:Cc:References:Content-Language:From:In-Reply-To: Content-Type:Content-Transfer-Encoding:X-ClientProxiedBy:MIME-Version: X-MS-PublicTrafficType:X-MS-TrafficTypeDiagnostic: X-MS-Office365-Filtering-Correlation-Id:X-MS-Exchange-SenderADCheck: X-MS-Exchange-AntiSpam-Relay:X-Microsoft-Antispam: X-Microsoft-Antispam-Message-Info:X-Forefront-Antispam-Report: X-MS-Exchange-AntiSpam-MessageData-ChunkCount: X-MS-Exchange-AntiSpam-MessageData-0:X-OriginatorOrg: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-AuthSource:X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-OriginalArrivalTime: X-MS-Exchange-CrossTenant-FromEntityHeader: X-MS-Exchange-CrossTenant-Id:X-MS-Exchange-CrossTenant-MailboxType: X-MS-Exchange-CrossTenant-UserPrincipalName: X-MS-Exchange-Transport-CrossTenantHeadersStamped; bh=XaawwRRZiCcaFLIT+eTD8DgGN2ww2dbtgUkvthicjJA=; b=QgY97824vtCXzPZql2ciD0eNY0OOV/17LnfQTK5IzEfuyqspEbQWOF4wdiNAHeqoX/TH qta9fpJIvDbhE5l9Ts0lzhvNBwtvzPkQa7qdte3HCRGQu+gFq3PQwqc5p/wjHsnUbe/W6 Ws+5KegseaEaljuzYTOEDVKQBNxHnInydA78JVPHJG079qCBU3iX88IiOkONANW7CEGFc WTXGfl3PeuqilSi1gFI9R1uwdd6IyusuGL6+jnVJ4g7rTG+VcC8OPozfHJsvk5NgGbGpJ 5qnidgs5GpFQxbrgMfMUukut54cL0ED36jSSIyl4BSMmalccrZ2AGc4DzDs5R/+byKQ== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=sO3E330+; arc=pass header.oldest-pass=0 smtp.remote-ip=40.93.194.43 Received: from SN4PR0501CU005.outbound.protection.outlook.com (mail-southcentralusazon11011043.outbound.protection.outlook.com [40.93.194.43]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (secp384r1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EE365606A329 for ; Tue, 1 Dec 2026 14:51:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org EE365606A329 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=sO3E330+ ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=NAy8b+zie42VgKHmuSkJ5IH6fE53siTRSNhGvGek1qz45P5SG99bAxLARk7cQhnZlqc89/KHDd70+F3lo9qkvw9JzaGGGbjlViZD4tPUqDiUtYxDKHJfTTcT3GP3FI1C1LD57rlyAGixEaniFmgycmmQsIa8oPL4Q8m75PiZr0HkMwaAmwUG2A3Taz/u4EURb4mxWhwUXr1WooNgKTLl0tSbsOv9Zvs5v2n6B8AxfI+7J/Zc/1Sg7318cg6gUfyk03WczdLyxxqL4Y/Rd8CLd8FuD5y3YZRfX2Vo7QyDe216soBZ1tZt9uYuw0yZUQ8LawyU0/eXrgVFhtZd2CDe2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=XaawwRRZiCcaFLIT+eTD8DgGN2ww2dbtgUkvthicjJA=; b=L1rtoc9EigDvy259U1DWcbF57nJ2uRTnqjr72CURvipgPobvlZiUwXVxucJ3Ak2p6u5iC/RHGM2KpfGz7jkHA65wEyNQ4nP8rxOa26o/Bkwj9rU5FCX8F6pPh/2Rz/AXjMvGFGhoiECmIKD8d3urJXhdeqa9opxXC87PTXHiby3gt0/Tl/m5eLrUAzgkh45B1l8NbI8GuW3xpWQoRxjDmgZfFs2URgmFpZpBwnrKTLChhWzB9PJUsd0uBdb7YHGeAhKfDkhOy8SOP+vFFt5w4WPSNAnAUdpwYqU/r5ose3q52iwiNneWVYXrg8s0o3RBeyd7FFBfTmiVzFaC8WONWw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XaawwRRZiCcaFLIT+eTD8DgGN2ww2dbtgUkvthicjJA=; b=sO3E330+jIp/nSHtgwVMuPvj9zO1tLbwSnw7xJ6DjOit1vbOyoQ+1p3qsbPdwusrLt7RlFcEw2MzAbLqei3nFVf5+ZpP6qElQ2cxdUXJqLu2VlYSmTU2sosXpTsLx+DXp8weiwtAR363tzCJbWamnRM+k4AqA4XevSCglvQwcGz9diqwnwLFXmOe9d87eGDIfw1LLlcwQicOp3v2B+iFC0M05XTyJ7qOw3QKAn4NT6bUeOXV6iFwzENgib5A5hUuSOVS4RzlSf7Eai92atygTHd/oZQSuI4KawVKqXXrfMY1zuOyrCrtbkUTD7n0UgJoscgZz1SjHDhvmc4d12tH7Q== Authentication-Results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from BL0PR12MB5505.namprd12.prod.outlook.com (2603:10b6:208:1ce::7) by PH7PR12MB5879.namprd12.prod.outlook.com (2603:10b6:510:1d7::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.662.13; Tue, 1 Dec 2026 14:51:29 +0000 Received: from BL0PR12MB5505.namprd12.prod.outlook.com ([fe80::9329:96cf:507a:eb21]) by BL0PR12MB5505.namprd12.prod.outlook.com ([fe80::9329:96cf:507a:eb21%5]) with mapi id 15.21.0688.009; Tue, 1 Dec 2026 14:51:29 +0000 Message-ID: <363d9a63-25a7-42cb-ace2-85e2b77eadc5@nvidia.com> Date: Tue, 1 Dec 2026 16:51:24 +0200 User-Agent: Mozilla Thunderbird Subject: Re: [net-next,v23,09/14] virtio_net: Implement layer 2 ethtool flow rules To: netdev-bot+sashiko@kernel.org Cc: netdev@vger.kernel.org, mst@redhat.com, jasowang@redhat.com, pabeni@redhat.com, virtualization@lists.linux.dev, parav@nvidia.com, yohadt@nvidia.com, xuanzhuo@linux.alibaba.com, eperezma@redhat.com, jgg@ziepe.ca, kevin.tian@intel.com, kuba@kernel.org, andrew+netdev@lunn.ch, edumazet@google.com, danielj@nvidia.com References: <20260831161109.2999926-10-shshitrit@nvidia.com> <178835474594.3394541.2565255737222929894@kernel.org> Content-Language: en-US From: Shahar Shitrit In-Reply-To: <178835474594.3394541.2565255737222929894@kernel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: TL0P290CA0002.ISRP290.PROD.OUTLOOK.COM (2603:1096:950:5::10) To BL0PR12MB5505.namprd12.prod.outlook.com (2603:10b6:208:1ce::7) X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL0PR12MB5505:EE_|PH7PR12MB5879:EE_ X-MS-Office365-Filtering-Correlation-Id: 99204ea3-bd7f-431c-0810-08df4fba9508 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|7416014|376014|23010399003|10067099003|5023799004|11063799006|56012099006|261022105027099003|261022115727099003|261021135927099003|261021130227099003|261021121427099003|261022075727099003|261021133027099003|261021123027099003|261026130827099003|261026121527099003|261028144727099003|261026140227099003|261026135527099003|261022113327099003|261102123227099003|261009223027099003|18002099003|22082099003|4143699003|6133799003|3023799007; X-Microsoft-Antispam-Message-Info: uZTZ21pHEiG5RbcGqLuSFgIXyTyIBEhMvZpmR5K2hcgycZBZHvICdyMlx/V1JFjPbIFthyJ5a6LH2kEbk5Qo/ZFJxcIJ6aQ70VekMp6R4Chrg5zdeuM3Ltq+vKRxfPt+0pySO4sz4ONUALG7iGYYQ2eUDOW/fpVEnEA0EPrD1E9tNhDkwqsBLHrItmzKDrCZ8z8jVp1KK2Rcj2BVR+xH9aSXK5KMe6iMo0HzsuCLBjmIq45nznMsb1oWUPyq7nucw4M2OZbDeGpwwd0wt4ltlLSJVpPcwQmQBO40eXn3SQFF04YG9gylZY2lAjIa/LNnZ8vqvMVnF7EarFnSzTi1VdDF+nzYJcMrpAaCsgCx3p+HzPuRiHXxxXf9xXsIqwNn19o/0xCJVW7Y6T+2ECMWtN485StXbaD6Tw0OkjIb2DkBX+7MyslCUIChNYrRmZC4ag9NKGWvRiFWE8+7mi7vWcgHqomRV4rYlKQylxYDwXJ3tHwu0iXbBYcVL6u9Eror3H6VUmjQrQBspdhPPxd3Wu2ZKg9p72x07DRhyOBspd7ZkywIb47kSKPTioqf7I6ZM/WWR1Dz4FZZ+WN/Yqxut7engK1rGINrMMAIdX9Jpc3FIBfdajsr6Q9lMO0rkosYyk1nYu3EJA6TlnwUr47IcW+K4dWcDRYu9Ca4rCIgv6A= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BL0PR12MB5505.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(7416014)(376014)(23010399003)(10067099003)(5023799004)(11063799006)(56012099006)(261022105027099003)(261022115727099003)(261021135927099003)(261021130227099003)(261021121427099003)(261022075727099003)(261021133027099003)(261021123027099003)(261026130827099003)(261026121527099003)(261028144727099003)(261026140227099003)(261026135527099003)(261022113327099003)(261102123227099003)(261009223027099003)(18002099003)(22082099003)(4143699003)(6133799003)(3023799007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?bFJ6bmRoUTBWT3N1QzZUMmN4MTVxZEV4dWtLQ1poMGE3c0hKS3RzbklxbnV5?= =?utf-8?B?Uk82WWtxR00ydUtORjZ0bGtybGxLMjh1QUN1YmhQOFFrd2h4eVpSUEdOc0g5?= =?utf-8?B?TnRPYW1LQ1dkbk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= =?utf-8?B?VkxnVExDUENQSFJ4STkyaXBBbGozd0ZRUFBnTmZGdUs4NjBDYnJwVXh1eERE?= =?utf-8?B?VkViMnBpZGcrcGUrY3g3aS9lVFNiL21KaEMwUWZ0Y1JTQzVMLzgyalVEVWZY?= =?utf-8?B?MzBKY2pzMkQzcVZ2dFBpUytuNHlpTHJhcFVybUlxbVV0U1pSdEVma2ZvQ09q?= =?utf-8?B?cDNQU3MySk9Kdll1RFBpb1Jrd3hoYXo1ZHYrZjdqU09sOFVLZTJvUWlYcmtV?= =?utf-8?B?QkJ1VTZueEZyQUpMUVI4U0J0SGFmTkI0QzV5YlM2VUcrYjBPK21JVU9vZ1o2?= =?utf-8?B?TEhXZzFuNDZGdzVhdnlYN1c2UzEwVmttVnVOMkdkRnpWMy9FWXk3YWszRHhn?= =?utf-8?B?TjU4dHd1Y2Y1Mis0QnY0L1hGQkxjZUYyQmw3VmhRVmRQSDVXR3AwZz09?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 99204ea3-bd7f-431c-0810-08df4fba9508 X-MS-Exchange-CrossTenant-AuthSource: BL0PR12MB5505.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2026 14:51:29.3975 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: nSjPDf9vnAPb79YLfaC+rfKBguoKoGAI/tzB+Br2un+odyoFXGM95INCopz3MITCZS0vOtikrNWMz9WIqw+1Mg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5879 On 02/09/2026 16:12, netdev-bot+sashiko@kernel.org wrote: > Thank you for your contribution! Sashiko AI review found 8 potential > issue(s) to consider: > > Critical: 0 · High: 0 · Medium: 6 · Low: 2 > > - [Medium] Installed flow-filter rules are never revalidated when the > number of active receive virtqueue pairs shrinks. > - [Medium] Rule precedence does not follow the ethtool uAPI contract. > - [Medium] virtio_net_ff_cap_data::rules_per_group_limit ("maximum number > of rules allowed in a single group") is validated as non-zero in… > - [Medium] All user-installed ethtool flow rules are silently destroyed > and never restored across a freeze/restore (suspend/resume) cycle. > - [Medium] Failed object-destroy admin commands are treated as success, > leaving the device with state the driver no longer tracks. > - [Medium] New teardown paths convert device-supplied error codes into > kernel WARN splats. > - [Low] DISCARDED AS FALSE POSITIVE (retained for policy reasons): > 'virtnet_ethtool_ops adds .set_rxnfc but no .get_rxnfc, so rules… > - [Low] validate_flow_input() returns -EOPNOTSUPP for every fs->location > other than RX_CLS_LOC_ANY, including unrecognised RX_CLS_LOC_SPECIAL… > > -- > > virtio_net: Implement layer 2 ethtool flow rules > > This adds ethtool ntuple rule insertion and removal for ETHER_FLOW by > creating VIRTIO_NET_RESOURCE_OBJ_FF_CLASSIFIER and > VIRTIO_NET_RESOURCE_OBJ_FF_RULE administrative objects, tracked in two > xarrays hanging off struct virtnet_ff. A few questions below. > >> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c >> index 294cfd70662d3..6217c5bcfee9f 100644 >> --- a/drivers/net/virtio_net.c >> +++ b/drivers/net/virtio_net.c > > [ ... ] > >> @@ -5742,6 +5722,445 @@ static const struct netdev_stat_ops virtnet_stat_ops = { >> .get_base_stats = virtnet_get_base_stats, >> }; >> > > [ ... ] > >> +static void destroy_classifier(struct virtnet_ff *ff, >> + u32 classifier_id) >> +{ >> + struct virtnet_classifier *c; >> + int err; >> + >> + c = xa_load(&ff->classifiers, classifier_id); >> + if (c) { >> + err = virtio_admin_obj_destroy(ff->vdev, >> + VIRTIO_NET_RESOURCE_OBJ_FF_CLASSIFIER, >> + c->id, >> + VIRTIO_ADMIN_GROUP_TYPE_SELF, >> + 0); >> + WARN_ON_ONCE(err); > > [Severity: Medium] > Is WARN_ON_ONCE() the right reaction to an error that the device chooses? > virtio_admin_obj_destroy() returns whatever vdev->config->admin_cmd_exec() > returns, so a non-zero command status from the device (or -EOPNOTSUPP, or > the -ENOMEM from its own kzalloc) lands directly in this WARN_ON_ONCE(). > The same value is turned into a WARN in virtnet_ff_cleanup(): > > xa_for_each(&ff->ethtool.rules, i, eth_rule) > WARN_ON_ONCE(destroy_ethtool_rule(ff, eth_rule)); > > A device that accepts OBJ_CREATE and then fails OBJ_DESTROY therefore > produces a splat on plain teardown or suspend, and with panic_on_warn=1 that > is a guest panic. Would a rate-limited netdev_warn() be more appropriate > for device-reported errors here? This follows MST's v22 review on virtio_admin_obj_destroy(): the function now returns the error, and callers that can't propagate it (teardown paths) warn. Ethtool delete propagates it to userspace. > >> + >> + xa_erase(&ff->classifiers, c->id); >> + kfree(c); >> + } >> +} >> + >> +static int destroy_ethtool_rule(struct virtnet_ff *ff, >> + struct virtnet_ethtool_rule *eth_rule) >> +{ >> + int err; >> + >> + ff->ethtool.num_rules--; >> + >> + err = virtio_admin_obj_destroy(ff->vdev, >> + VIRTIO_NET_RESOURCE_OBJ_FF_RULE, >> + eth_rule->flow_spec.location, >> + VIRTIO_ADMIN_GROUP_TYPE_SELF, >> + 0); >> + >> + xa_erase(&ff->ethtool.rules, eth_rule->flow_spec.location); >> + destroy_classifier(ff, eth_rule->classifier_id); >> + kfree(eth_rule); >> + >> + return err; >> +} > > [Severity: Medium] > Can the driver and the device diverge here when the destroy fails? err is > saved but the xa_erase(), destroy_classifier() and kfree(eth_rule) run > unconditionally, so on failure: > > - the device keeps an armed FF_RULE that the driver can no longer list or > delete, and virtnet_ff_cleanup() will not retry it because the xarray > entry is gone > - destroy_classifier() then tears down the classifier that the still-live > rule references > - the location id and the classifier id go back to their xa_alloc > allocators, so a later ethtool -U can pick an id the device still has > allocated and the following OBJ_CREATE collides with the stale object > > virtnet_ethtool_flow_remove() returns that err to userspace after the record > is already gone, so the user sees a failure but has nothing left to retry > against. > > Note this does not need a malicious device: virtio_admin_obj_destroy() can > fail before the command is sent, since its own kzalloc() can return -ENOMEM. > > Would it be better to keep the rule record and its classifier when the > device refuses the destroy? The same applies to the rollback in > build_and_insert(), which uses destroy_classifier() and so cannot tell that > the classifier is still allocated in the device. > Teardown is best effort by design: a failed destroy means the device is misbehaving, so we warn and release the driver state instead of keeping records that can't be recovered. Keeping the rule would also complicate virtnet_ff_cleanup(), which has to free everything unconditionally. Any device state left behind is discarded on reset. >> + >> +static int insert_rule(struct virtnet_ff *ff, >> + struct virtnet_ethtool_rule *eth_rule, >> + u32 classifier_id, >> + const u8 *key, >> + u8 key_size) >> +{ >> + struct ethtool_rx_flow_spec *fs = ð_rule->flow_spec; >> + struct virtio_net_resource_obj_ff_rule *ff_rule; >> + int err; >> + >> + ff_rule = kzalloc(sizeof(*ff_rule) + key_size, GFP_KERNEL); >> + if (!ff_rule) >> + return -ENOMEM; >> + >> + /* Intentionally leave the priority as 0. All rules have the same >> + * priority. >> + */ > > [Severity: Medium] > With every rule created at the same device priority, what decides which of > two overlapping rules wins? include/uapi/linux/ethtool.h documents > struct ethtool_rx_flow_spec::location as ordering-significant: > > * @location: Location of rule in the table. Locations must be > * numbered such that a flow matching multiple rules will be > * classified according to the first (lowest numbered) rule. > > Since rule_priority stays 0 for all rules, and last_rule_priority from > struct virtio_net_ff_cap_data is never referenced in the driver, two > overlapping rules resolve in a device-defined order rather than in location > order. For ETHER_FLOW alone one rule masking h_dest and another masking > h_source already match the same frame. Should the location ordering be > mapped onto rule_priority, or should the documented ordering guarantee be > called out as unsupported? > Specific locations are rejected (RX_CLS_LOC_ANY only), so there is no user-visible ordering to map. All rules share one group and priority, and the order for overlapping rules is device-defined. >> + ff_rule->group_id = cpu_to_le32(VIRTNET_FF_ETHTOOL_GROUP_PRIORITY); >> + ff_rule->classifier_id = cpu_to_le32(classifier_id); >> + ff_rule->key_length = key_size; >> + ff_rule->action = fs->ring_cookie == RX_CLS_FLOW_DISC ? >> + VIRTIO_NET_FF_ACTION_DROP : >> + VIRTIO_NET_FF_ACTION_RX_VQ; >> + ff_rule->vq_index = fs->ring_cookie != RX_CLS_FLOW_DISC ? >> + cpu_to_le16(rxq2vq(fs->ring_cookie)) : 0; >> + memcpy(&ff_rule->keys, key, key_size); >> + > > [ ... ] > >> +static int validate_flow_input(struct virtnet_ff *ff, >> + const struct ethtool_rx_flow_spec *fs, >> + u16 curr_queue_pairs) >> +{ >> + u8 required_action = fs->ring_cookie == RX_CLS_FLOW_DISC ? >> + VIRTIO_NET_FF_ACTION_DROP : >> + VIRTIO_NET_FF_ACTION_RX_VQ; >> + int i; >> + >> + /* Force users to use RX_CLS_LOC_ANY - don't allow specific locations */ >> + if (fs->location != RX_CLS_LOC_ANY) >> + return -EOPNOTSUPP; > > [Severity: Low] > Should an unrecognised RX_CLS_LOC_SPECIAL value return -EINVAL rather than > -EOPNOTSUPP? The struct ethtool_rxnfc documentation in > include/uapi/linux/ethtool.h says: > > * defined in future and drivers must return -%EINVAL for any > * unrecognised value. > > This blanket check returns -EOPNOTSUPP for every location other than > RX_CLS_LOC_ANY, including those unrecognised special values. > >> + >> + if (fs->ring_cookie != RX_CLS_FLOW_DISC && >> + fs->ring_cookie >= curr_queue_pairs) >> + return -EINVAL; > > [Severity: Medium] > This is the only bound on the target queue, and insert_rule() then commits > an absolute receive virtqueue index into the device object: > > ff_rule->vq_index = fs->ring_cookie != RX_CLS_FLOW_DISC ? > cpu_to_le16(rxq2vq(fs->ring_cookie)) : 0; > > What happens to that rule when curr_queue_pairs later shrinks? The > ethtool -L path is covered once .get_rxnfc exists later in the series, since > ethtool_check_max_channel() then refuses reductions below the highest in-use > ring, but virtnet_xdp_set() lowers the count without any such check: > > virtnet_xdp_set() > curr_qp = vi->curr_queue_pairs - vi->xdp_queue_pairs; > ... > err = virtnet_set_queues(vi, curr_qp + xdp_qp); > > So a rule inserted while an XDP program is attached, with ring_cookie in > [curr_qp, curr_qp + xdp_qp), survives program detach and then names a > receiveq the driver has just told the device to stop using via > VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET. Does matched traffic get silently dropped > while the rule is still listed as valid? > ethtool -L is handled in the last patch ("virtio_net: Add get ethtool flow rules ops"): it adds .get_rxnfc, so ethtool_check_max_channel() refuses shrinking below an in-use rule queue. The XDP attach/detach path isn't revalidated against existing rules, and we will no change that in this series. >> + >> + for (i = 0; i < ff->ff_actions->count; i++) >> + if (ff->ff_actions->actions[i] == required_action) >> + goto action_ok; >> + return -EOPNOTSUPP; >> + > > [ ... ] > >> +static int virtnet_ethtool_flow_insert(struct virtnet_ff *ff, >> + struct ethtool_rx_flow_spec *fs, >> + u16 curr_queue_pairs) >> +{ >> + struct virtnet_ethtool_rule *eth_rule; >> + int err; >> + >> + if (!ff->ff_supported) >> + return -EOPNOTSUPP; >> + >> + err = validate_flow_input(ff, fs, curr_queue_pairs); >> + if (err) >> + return err; >> + >> + eth_rule = kzalloc(sizeof(*eth_rule), GFP_KERNEL); >> + if (!eth_rule) >> + return -ENOMEM; >> + >> + err = xa_alloc(&ff->ethtool.rules, &fs->location, eth_rule, >> + XA_LIMIT(0, le32_to_cpu(ff->ff_caps->rules_limit) - 1), >> + GFP_KERNEL); > > [Severity: Medium] > Where is rules_per_group_limit enforced? Every ethtool rule is created in > the single ethtool group: > > ff_rule->group_id = cpu_to_le32(VIRTNET_FF_ETHTOOL_GROUP_PRIORITY); > > but the id allocation here is bounded only by rules_limit. On a device that > reports rules_per_group_limit smaller than rules_limit, repeated ethtool -U > insertions keep allocating locations and issuing OBJ_CREATE past the > per-group limit, and the failure then comes back from the device as an opaque > error instead of -ENOSPC. > > Later in the series this also contradicts what the driver advertises, since > virtnet_ethtool_get_flow_count() reports the table size as > min(rules_limit, rules_per_group_limit) | RX_CLS_LOC_SPECIAL while this path > can still hand out higher locations. The driver only accepts RX_CLS_LOC_ANY (validate_flow_input() rejects explicit locations), so users can't specify rule order and the location-based ordering guarantee doesn't apply. Overlapping rules are resolved by the device. > >> + if (err) >> + goto err_rule; >> + >> + eth_rule->flow_spec = *fs; >> + > > [ ... ] > >> @@ -5944,11 +6409,19 @@ static int virtnet_ff_init(struct virtnet_ff *ff, struct virtio_device *vdev) >> >> static void virtnet_ff_cleanup(struct virtnet_ff *ff) >> { >> + struct virtnet_ethtool_rule *eth_rule; >> + unsigned long i; >> int err; >> >> if (!ff->ff_supported) >> return; >> >> + xa_for_each(&ff->ethtool.rules, i, eth_rule) >> + WARN_ON_ONCE(destroy_ethtool_rule(ff, eth_rule)); >> + >> + xa_destroy(&ff->ethtool.rules); >> + xa_destroy(&ff->classifiers); > > [Severity: Medium] > Are the installed rules meant to survive a freeze/restore cycle? This > teardown is reached from the suspend path: > > virtnet_freeze_down() > rtnl_lock(); > virtnet_ff_cleanup(&vi->ff); > rtnl_unlock(); > > and destroy_ethtool_rule() kfree()s the only software copy of each > flow_spec, after which both xarrays are destroyed. On the way back up the > only flow filter work is: > > virtnet_restore_up() > err = virtnet_ff_init(&vi->ff, vi->vdev); > > which ends in xa_init_flags() on two empty xarrays, with nothing replaying > the classifier and rule creates. > > After resume, does userspace keep believing rules exist that the device no > longer enforces? A rule with RX_CLS_FLOW_DISC would start delivering > traffic again, and ETHTOOL_SRXCLSRLDEL for a previously reported location > takes the !eth_rule path in virtnet_ethtool_flow_remove() and returns > -ENOENT. Before this patch only the group object was recreated, so no > user-visible configuration was lost. Rules are not preserved across suspend and resume in this series. This could be a follow up. > >> + >> err = virtio_admin_obj_destroy(ff->vdev, >> VIRTIO_NET_RESOURCE_OBJ_FF_GROUP, >> VIRTNET_FF_ETHTOOL_GROUP_PRIORITY, > > [ ... ] >