Skip to contentSkip to conversation

FAILED: patch "[PATCH] virtio_net: clamp rss_max_key_size to NETDEV_RSS_KEY_LEN" failed to apply to 6.1-stable tree

PATCH In review [email protected] 3 participants 7 messages Apr 8

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 6.1-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.1.y
git checkout FETCH_HEAD
git cherry-pick -x b4e5f04c58a29c499faa85d12952ca9a4faf1cb9
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026040856-ploy-antiviral-fecc@gregkh' --subject-prefix 'PATCH 6.1.y' HEAD^..

Possible dependencies:

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From b4e5f04c58a29c499faa85d12952ca9a4faf1cb9 Mon Sep 17 00:00:00 2001
From: Srujana Challa <[email protected]>
Date: Thu, 26 Mar 2026 19:53:44 +0530
Subject: [PATCH] virtio_net: clamp rss_max_key_size to NETDEV_RSS_KEY_LEN

rss_max_key_size in the virtio spec is the maximum key size supported by the device, not a mandatory size the driver must use. Also the value 40 is a spec minimum, not a spec maximum.

The current code rejects RSS and can fail probe when the device reports a larger rss_max_key_size than the driver buffer limit. Instead, clamp the effective key length to min(device rss_max_key_size, NETDEV_RSS_KEY_LEN) and keep RSS enabled.

This keeps probe working on devices that advertise larger maximum key sizes while respecting the netdev RSS key buffer size limit.

drivers/net/virtio_net.c +9 -11
index ab2108ee206a..c0b9bc5574e2 100644
@@ -381,8 +381,6 @@ struct receive_queue {
 	struct xdp_buff **xsk_buffs;
 };
 
-#define VIRTIO_NET_RSS_MAX_KEY_SIZE     40
-
 /* Control VQ buffers: protected by the rtnl lock */
 struct control_buf {
 	struct virtio_net_ctrl_hdr hdr;
@@ -486,7 +484,7 @@ struct virtnet_info {
 
 	/* Must be last as it ends in a flexible-array member. */
 	TRAILING_OVERLAP(struct virtio_net_rss_config_trailer, rss_trailer, hash_key_data,
-		u8 rss_hash_key_data[VIRTIO_NET_RSS_MAX_KEY_SIZE];
+		u8 rss_hash_key_data[NETDEV_RSS_KEY_LEN];
 	);
 };
 static_assert(offsetof(struct virtnet_info, rss_trailer.hash_key_data) ==
@@ -6708,6 +6706,7 @@ static int virtnet_probe(struct virtio_device *vdev)
 	struct virtnet_info *vi;
 	u16 max_queue_pairs;
 	int mtu = 0;
+	u16 key_sz;
 
 	/* Find if host supports multiqueue/rss virtio_net device */
 	max_queue_pairs = 1;
@@ -6842,14 +6841,13 @@ static int virtnet_probe(struct virtio_device *vdev)
 	}
 
 	if (vi->has_rss || vi->has_rss_hash_report) {
-		vi->rss_key_size =
-			virtio_cread8(vdev, offsetof(struct virtio_net_config, rss_max_key_size));
-		if (vi->rss_key_size > VIRTIO_NET_RSS_MAX_KEY_SIZE) {
-			dev_err(&vdev->dev, "rss_max_key_size=%u exceeds the limit %u.\n",
-				vi->rss_key_size, VIRTIO_NET_RSS_MAX_KEY_SIZE);
-			err = -EINVAL;
-			goto free;
-		}
+		key_sz = virtio_cread8(vdev, offsetof(struct virtio_net_config, rss_max_key_size));
+
+		vi->rss_key_size = min_t(u16, key_sz, NETDEV_RSS_KEY_LEN);
+		if (key_sz > vi->rss_key_size)
+			dev_warn(&vdev->dev,
+				 "rss_max_key_size=%u exceeds driver limit %u, clamping\n",
+				 key_sz, vi->rss_key_size);
 
 		vi->rss_hash_types_supported =
 		    virtio_cread32(vdev, offsetof(struct virtio_net_config, supported_hash_types));
maintainer
#1 lore raw

PATCH 1/1 virtio_net: clamp rss_max_key_size to NETDEV_RSS_KEY_LEN

From: Srujana Challa <[email protected]>

[ Upstream commit b4e5f04c58a29c499faa85d12952ca9a4faf1cb9 ]

rss_max_key_size in the virtio spec is the maximum key size supported by the device, not a mandatory size the driver must use. Also the value 40 is a spec minimum, not a spec maximum.

The current code rejects RSS and can fail probe when the device reports a larger rss_max_key_size than the driver buffer limit. Instead, clamp the effective key length to min(device rss_max_key_size, NETDEV_RSS_KEY_LEN) and keep RSS enabled.

This keeps probe working on devices that advertise larger maximum key sizes while respecting the netdev RSS key buffer size limit.

Fixes 3f7d9c1964fc ("virtio_net: Add hash_key_length check")
[ changed clamp target from NETDEV_RSS_KEY_LEN to VIRTIO_NET_RSS_MAX_KEY_SIZE ]
---
 drivers/net/virtio_net.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/net/virtio_net.c +8 -8
index 9ee3465082c5a..0fcd662d15d51 100644
@@ -3796,6 +3796,7 @@ static int virtnet_probe(struct virtio_device *vdev)
 	struct virtnet_info *vi;
 	u16 max_queue_pairs;
 	int mtu = 0;
+	u16 key_sz;
 
 	/* Find if host supports multiqueue/rss virtio_net device */
 	max_queue_pairs = 1;
@@ -3915,14 +3916,13 @@ static int virtnet_probe(struct virtio_device *vdev)
 	}
 
 	if (vi->has_rss || vi->has_rss_hash_report) {
-		vi->rss_key_size =
-			virtio_cread8(vdev, offsetof(struct virtio_net_config, rss_max_key_size));
-		if (vi->rss_key_size > VIRTIO_NET_RSS_MAX_KEY_SIZE) {
-			dev_err(&vdev->dev, "rss_max_key_size=%u exceeds the limit %u.\n",
-				vi->rss_key_size, VIRTIO_NET_RSS_MAX_KEY_SIZE);
-			err = -EINVAL;
-			goto free;
-		}
+		key_sz = virtio_cread8(vdev, offsetof(struct virtio_net_config, rss_max_key_size));
+
+		vi->rss_key_size = min_t(u16, key_sz, VIRTIO_NET_RSS_MAX_KEY_SIZE);
+		if (key_sz > vi->rss_key_size)
+			dev_warn(&vdev->dev,
+				 "rss_max_key_size=%u exceeds driver limit %u, clamping\n",
+				 key_sz, vi->rss_key_size);
 
 		vi->rss_hash_types_supported =
 		    virtio_cread32(vdev, offsetof(struct virtio_net_config, supported_hash_types));
Signature · 1 line
2.53.0
#2 lore raw

Re: [PATCH 6.1.y] virtio_net: clamp rss_max_key_size to NETDEV_RSS_KEY_LEN

Quoted 16 lines · Sasha Levin

From: Srujana Challa <[email protected]>

[ Upstream commit b4e5f04c58a29c499faa85d12952ca9a4faf1cb9 ]

rss_max_key_size in the virtio spec is the maximum key size supported by the device, not a mandatory size the driver must use. Also the value 40 is a spec minimum, not a spec maximum.

The current code rejects RSS and can fail probe when the device reports a larger rss_max_key_size than the driver buffer limit. Instead, clamp the effective key length to min(device rss_max_key_size, NETDEV_RSS_KEY_LEN) and keep RSS enabled.

This keeps probe working on devices that advertise larger maximum key sizes while respecting the netdev RSS key buffer size limit.

Quoted 7 lines
Fixes 3f7d9c1964fc ("virtio_net: Add hash_key_length check")
[ changed clamp target from NETDEV_RSS_KEY_LEN to VIRTIO_NET_RSS_MAX_KEY_SIZE ]

Does this not make the subject and the commit log misleading?

Quoted 41 lines
---
 drivers/net/virtio_net.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/net/virtio_net.c +8 -8
index 9ee3465082c5a..0fcd662d15d51 100644
@@ -3796,6 +3796,7 @@ static int virtnet_probe(struct virtio_device *vdev)
 	struct virtnet_info *vi;
 	u16 max_queue_pairs;
 	int mtu = 0;
+	u16 key_sz;
 
 	/* Find if host supports multiqueue/rss virtio_net device */
 	max_queue_pairs = 1;
@@ -3915,14 +3916,13 @@ static int virtnet_probe(struct virtio_device *vdev)
 	}
 
 	if (vi->has_rss || vi->has_rss_hash_report) {
-		vi->rss_key_size =
-			virtio_cread8(vdev, offsetof(struct virtio_net_config, rss_max_key_size));
-		if (vi->rss_key_size > VIRTIO_NET_RSS_MAX_KEY_SIZE) {
-			dev_err(&vdev->dev, "rss_max_key_size=%u exceeds the limit %u.\n",
-				vi->rss_key_size, VIRTIO_NET_RSS_MAX_KEY_SIZE);
-			err = -EINVAL;
-			goto free;
-		}
+		key_sz = virtio_cread8(vdev, offsetof(struct virtio_net_config, rss_max_key_size));
+
+		vi->rss_key_size = min_t(u16, key_sz, VIRTIO_NET_RSS_MAX_KEY_SIZE);
+		if (key_sz > vi->rss_key_size)
+			dev_warn(&vdev->dev,
+				 "rss_max_key_size=%u exceeds driver limit %u, clamping\n",
+				 key_sz, vi->rss_key_size);
 
 		vi->rss_hash_types_supported =
 		    virtio_cread32(vdev, offsetof(struct virtio_net_config, supported_hash_types));
Signature · 1 line
2.53.0
maintainer
#3 lore raw

Re: [PATCH 6.1.y] virtio_net: clamp rss_max_key_size to NETDEV_RSS_KEY_LEN

Quoted 25 lines · Michael S. Tsirkin
Quoted 16 lines · Sasha Levin

From: Srujana Challa <[email protected]>

[ Upstream commit b4e5f04c58a29c499faa85d12952ca9a4faf1cb9 ]

rss_max_key_size in the virtio spec is the maximum key size supported by the device, not a mandatory size the driver must use. Also the value 40 is a spec minimum, not a spec maximum.

The current code rejects RSS and can fail probe when the device reports a larger rss_max_key_size than the driver buffer limit. Instead, clamp the effective key length to min(device rss_max_key_size, NETDEV_RSS_KEY_LEN) and keep RSS enabled.

This keeps probe working on devices that advertise larger maximum key sizes while respecting the netdev RSS key buffer size limit.

Quoted 7 lines
Fixes 3f7d9c1964fc ("virtio_net: Add hash_key_length check")
[ changed clamp target from NETDEV_RSS_KEY_LEN to VIRTIO_NET_RSS_MAX_KEY_SIZE ]
Quoted 1 line

Does this not make the subject and the commit log misleading?

Probably, but changing the commit subject will just create more confusion.

Signature · 2 lines
Thanks,
Sasha
#4 lore raw

Re: [PATCH 6.1.y] virtio_net: clamp rss_max_key_size to NETDEV_RSS_KEY_LEN

Quoted 26 lines · Sasha Levin
Quoted 25 lines · Michael S. Tsirkin
Quoted 23 lines · Sasha Levin

From: Srujana Challa <[email protected]>

[ Upstream commit b4e5f04c58a29c499faa85d12952ca9a4faf1cb9 ]

rss_max_key_size in the virtio spec is the maximum key size supported by the device, not a mandatory size the driver must use. Also the value 40 is a spec minimum, not a spec maximum.

The current code rejects RSS and can fail probe when the device reports a larger rss_max_key_size than the driver buffer limit. Instead, clamp the effective key length to min(device rss_max_key_size, NETDEV_RSS_KEY_LEN) and keep RSS enabled.

This keeps probe working on devices that advertise larger maximum key sizes while respecting the netdev RSS key buffer size limit.

Fixes 3f7d9c1964fc ("virtio_net: Add hash_key_length check")
[ changed clamp target from NETDEV_RSS_KEY_LEN to VIRTIO_NET_RSS_MAX_KEY_SIZE ]
Quoted 7 lines
Quoted 1 line

Does this not make the subject and the commit log misleading?

Probably, but changing the commit subject will just create more confusion.

Signature · 2 lines
Thanks,
Sasha

It's not just the subject. The commit log says:

Also the value 40 is a spec minimum, not a spec maximum.

but the changed patch seems to treat it as a maximum:

+ vi->rss_key_size = min_t(u16, key_sz, VIRTIO_NET_RSS_MAX_KEY_SIZE);

so unless I misread the code, the value is never > 40.

Signature · 1 line
MST
maintainer
#5 lore raw

Re: [PATCH 6.1.y] virtio_net: clamp rss_max_key_size to NETDEV_RSS_KEY_LEN

Quoted 37 lines · Michael S. Tsirkin
Quoted 26 lines · Sasha Levin
Quoted 25 lines · Michael S. Tsirkin
Quoted 23 lines · Sasha Levin

From: Srujana Challa <[email protected]>

[ Upstream commit b4e5f04c58a29c499faa85d12952ca9a4faf1cb9 ]

rss_max_key_size in the virtio spec is the maximum key size supported by the device, not a mandatory size the driver must use. Also the value 40 is a spec minimum, not a spec maximum.

The current code rejects RSS and can fail probe when the device reports a larger rss_max_key_size than the driver buffer limit. Instead, clamp the effective key length to min(device rss_max_key_size, NETDEV_RSS_KEY_LEN) and keep RSS enabled.

This keeps probe working on devices that advertise larger maximum key sizes while respecting the netdev RSS key buffer size limit.

Fixes 3f7d9c1964fc ("virtio_net: Add hash_key_length check")
[ changed clamp target from NETDEV_RSS_KEY_LEN to VIRTIO_NET_RSS_MAX_KEY_SIZE ]
Quoted 7 lines
Quoted 1 line

Does this not make the subject and the commit log misleading?

Probably, but changing the commit subject will just create more confusion.

--
Thanks,
Sasha

It's not just the subject. The commit log says:

Quoted 8 lines

Also the value 40 is a spec minimum, not a spec maximum.

but the changed patch seems to treat it as a maximum:

+ vi->rss_key_size = min_t(u16, key_sz, VIRTIO_NET_RSS_MAX_KEY_SIZE);

so unless I misread the code, the value is never > 40.

I tried to explain it here: https://lore.kernel.org/all/adZitVex9UGVyH-V@laps/

Signature · 2 lines
Thanks,
Sasha
#6 lore raw

Re: [PATCH 6.1.y] virtio_net: clamp rss_max_key_size to NETDEV_RSS_KEY_LEN

Quoted 40 lines · Sasha Levin
Quoted 39 lines · Michael S. Tsirkin
Quoted 26 lines · Sasha Levin
Quoted 25 lines · Michael S. Tsirkin
Quoted 23 lines · Sasha Levin

From: Srujana Challa <[email protected]>

[ Upstream commit b4e5f04c58a29c499faa85d12952ca9a4faf1cb9 ]

rss_max_key_size in the virtio spec is the maximum key size supported by the device, not a mandatory size the driver must use. Also the value 40 is a spec minimum, not a spec maximum.

The current code rejects RSS and can fail probe when the device reports a larger rss_max_key_size than the driver buffer limit. Instead, clamp the effective key length to min(device rss_max_key_size, NETDEV_RSS_KEY_LEN) and keep RSS enabled.

This keeps probe working on devices that advertise larger maximum key sizes while respecting the netdev RSS key buffer size limit.

Fixes 3f7d9c1964fc ("virtio_net: Add hash_key_length check")
[ changed clamp target from NETDEV_RSS_KEY_LEN to VIRTIO_NET_RSS_MAX_KEY_SIZE ]
Quoted 7 lines
Quoted 1 line

Does this not make the subject and the commit log misleading?

Probably, but changing the commit subject will just create more confusion.

--
Thanks,
Sasha

It's not just the subject. The commit log says:

Also the value 40 is a spec minimum, not a spec maximum.

Quoted 12 lines
Quoted 6 lines

but the changed patch seems to treat it as a maximum:

+ vi->rss_key_size = min_t(u16, key_sz, VIRTIO_NET_RSS_MAX_KEY_SIZE);

so unless I misread the code, the value is never > 40.

I tried to explain it here: https://lore.kernel.org/all/adZitVex9UGVyH-V@laps/

Signature · 2 lines
Thanks,
Sasha

OK let us take the discussion there.