From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2C4293AEF40 for ; Wed, 25 Feb 2026 12:25:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772022304; cv=none; b=kEdQi2s/ALkTBQbiF6hcEhbQiWaakhCN6fJuUJS3ylvrm+KJpZ1xcoU9UO28s5p1O2h+bU5kLIM4THcqzZ5Mfh5/viS5g56MGsYr/awGJx0GXBuCa0RvgEmd8vOCd1P4AUG/ThzmBbcG+QbOh/S4rgBpdDoxFrVKB0uxxu27d2Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772022304; c=relaxed/simple; bh=KpzWjtfsWv3qhAGhWyvVbyhPwgnmWZ3Fr4zjNZr3GdU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=JRAjOQXomVpRlDhZuKCxQ5QY8GYwEMpccyImFISLpFuer5vtDSvnNUSZFSegRp8S7a/SYN0wAf7Sgd3qzgvAuSYPo8XfMU3qF7EHkVWSwX3zn5933KL3inZvtsFu+xQtlP8Y9xRHMy5YRrHQ8WURCAlIxaFj+7qnYArPp8z4slo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=UYZIKKo7; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=JEdVTRyL; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="UYZIKKo7"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="JEdVTRyL" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1772022302; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LMzUQOTDOi7UoTOS/hJ+EQEdYM7FgK5Sbr9EcZoRwiY=; b=UYZIKKo79psuCtgoz3gbRTuov8qK59BLTRELMmi6ivTA7krI4F4Rzyt7wzFMUZpgxI9iHZ EnGhRuV7sbnFfT37Gcw6L+pPscQ3rzDPVD6IKj/o0bAMnuWdzy9JnI8T2xJVTtvE1xdJ9x RKQox9ovBYsDe+8onEFRgPU/XstLNIw= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-170-0bFBd5-6NL2pfHivlWSaiA-1; Wed, 25 Feb 2026 07:25:00 -0500 X-MC-Unique: 0bFBd5-6NL2pfHivlWSaiA-1 X-Mimecast-MFC-AGG-ID: 0bFBd5-6NL2pfHivlWSaiA_1772022300 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-48079ae1001so35756065e9.0 for ; Wed, 25 Feb 2026 04:25:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1772022299; x=1772627099; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=LMzUQOTDOi7UoTOS/hJ+EQEdYM7FgK5Sbr9EcZoRwiY=; b=JEdVTRyLI3+YCqdHhT56QZdhyObhaHQCzxYdtUl2lkk8NvlvegMNhaWFFpVnP8UQkO tM6oozZmbB1hTP0ioiSl3NjazcLzafOJ9CaV6SvaQ+ZvuRkXC3HpZoSCl7Xku27QHPNe cLU0w/QD87CpvO34H6QoQu40jPoEgqArVBcZXYgD1Xgvh3uuIX4+hGdxADRtNoX2auLV 2zY6EJFcxDKTIBXV12mq3lLcXuKrQcQdQ06xowRIHPGkyzrrenoQnvjP01uYCzywjN11 UNMbiH0l7ymTm4NojuIylaHYdQ9oMUQXnB89+7t7NU7f8Lkg4W3uJGRODNNSACUF0z4o 5auA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772022299; x=1772627099; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=LMzUQOTDOi7UoTOS/hJ+EQEdYM7FgK5Sbr9EcZoRwiY=; b=S7JHkIRLWj/f9FqlKvoUSImuaxLErctspZadTl1xwKTJv1TIlz0Ecb47gkLVNr4Zkz 9rhSYSPmsLftPqtiXh0Kejxo8sBQ4xC7MNDB2UvqgyRdjjjR2t3Q7Hv/QQq5BoBMdQGq 1ihHM76j2wpDQZI0Wg2eNTcq4/NM2x6X53mXFHCd7BNjTEQWLryU+ssTy61Vr5ORFnPk nxBf7LYFAV8z3wkaVLqZTCuaMdGx+QzHFNQaf/yhRgxaNTtbHmIvInG6xPVGXXYk4v0A g9H2mA739MOB+S4TVeYIOwCZ455ub2N9gAHwDXtsMeNTIVgBkeIxRmiProK23U5Y4xlY Txzg== X-Gm-Message-State: AOJu0Yy+CPz3CUOHankW+1ie+68A0Yy140RLdHB1x3kL6V3l68qWyex5 MVyzJpKK8HYFBp4TjxQx4KHZGjb5JkZy0rjUdFkXgGY1IFbSfa1KFgres2fpZsnlzjty5wPI0nB gCcL9+D/YPYuKkhM3fH4ajXMvInS8kc2vVvDc5gUdH3DZh1PJlbsRSa94+w== X-Gm-Gg: ATEYQzw3nfWtlrwIFK9Xs5xfYjreLvlFvRCHe4CK+k2TAcYIU7Jr1Gl9BHLIL3a2ov8 66DOvxVCH3gp85CBasU90xnTIFpmJr0KsIpaRlMWJ/YLacW1adkw0Th0Qd/5yaZV0kib7YrQVVp 6+kivUfADn5CKU6jizZguFqNAenPPDyJnE8+zIqsrr5jsw1/cvG/6QyNmykcD+aMYNW4I1R66CE NFGz0iU0Bak4hWgcbNhnYZpKE4ufqhtBFCLwz7opjX84jM1eM1Qy4OSHaRxsiZOtZLCsze9RTj3 0YDqP7Z/+bDTQcXdlM565AflElk4wnl7oSzN8kYWej6bWkeXQV46iCm31gwGGGdm79yWajWpO8A LUtt/VgdYCsxICMyBKu0YddpHLTMWbhA/G1PczXWijoaDsw== X-Received: by 2002:a05:600c:3e0b:b0:480:1c85:88bf with SMTP id 5b1f17b1804b1-483c21a57aemr2858145e9.27.1772022299477; Wed, 25 Feb 2026 04:24:59 -0800 (PST) X-Received: by 2002:a05:600c:3e0b:b0:480:1c85:88bf with SMTP id 5b1f17b1804b1-483c21a57aemr2857655e9.27.1772022299002; Wed, 25 Feb 2026 04:24:59 -0800 (PST) Received: from redhat.com (IGLD-80-230-79-166.inter.net.il. [80.230.79.166]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483bd70e692sm61847325e9.7.2026.02.25.04.24.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Feb 2026 04:24:58 -0800 (PST) Date: Wed, 25 Feb 2026 07:24:55 -0500 From: "Michael S. Tsirkin" To: Srujana Challa Cc: "netdev@vger.kernel.org" , "virtualization@lists.linux.dev" , "pabeni@redhat.com" , "jasowang@redhat.com" , "xuanzhuo@linux.alibaba.com" , "eperezma@redhat.com" , "davem@davemloft.net" , "edumazet@google.com" , "kuba@kernel.org" , Nithin Kumar Dabilpuram , Shiva Shankar Kommula , "stable@vger.kernel.org" Subject: Re: [EXTERNAL] Re: [PATCH net,v4,1/2] virtio_net: Improve RSS key size validation and use NETDEV_RSS_KEY_LEN Message-ID: <20260225072355-mutt-send-email-mst@kernel.org> References: <20260224065850.962826-1-schalla@marvell.com> <20260225050154-mutt-send-email-mst@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Wed, Feb 25, 2026 at 12:22:50PM +0000, Srujana Challa wrote: > > On Tue, Feb 24, 2026 at 12:28:49PM +0530, Srujana Challa wrote: > > > Replace hardcoded RSS max key size limit with NETDEV_RSS_KEY_LEN to > > > align with kernel's standard RSS key length. Add validation for RSS > > > key size against spec minimum (40 bytes) and driver maximum. When > > > validation fails, gracefully disable RSS features and continue > > > initialization rather than failing completely. > > > > > > Cc: stable@vger.kernel.org > > > Fixes: 3f7d9c1964fc ("virtio_net: Add hash_key_length check") > > > Signed-off-by: Srujana Challa > > > > --- should come here before changelog. > > > > > v3: > > > - Moved RSS key validation checks to virtnet_validate. > > > - Add fixes: tag and CC -stable > > > v4: > > > - Use NETDEV_RSS_KEY_LEN instead of type_max for the maximum rss key > > size. > > > --- > > > drivers/net/virtio_net.c | 34 ++++++++++++++++++++++++---------- > > > 1 file changed, 24 insertions(+), 10 deletions(-) > > > > > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index > > > db88dcaefb20..eeefe8abc122 100644 > > > --- a/drivers/net/virtio_net.c > > > +++ b/drivers/net/virtio_net.c > > > @@ -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) == @@ -6627,6 +6625,29 @@ static int > > virtnet_validate(struct virtio_device *vdev) > > > __virtio_clear_bit(vdev, VIRTIO_NET_F_STANDBY); > > > } > > > > > > + if (virtio_has_feature(vdev, VIRTIO_NET_F_RSS) || > > > + virtio_has_feature(vdev, VIRTIO_NET_F_HASH_REPORT)) { > > > + u8 key_sz = virtio_cread8(vdev, > > > + offsetof(struct virtio_net_config, > > > + rss_max_key_size)); > > > + /* Spec requires at least 40 bytes */ #define > > > +VIRTIO_NET_RSS_MIN_KEY_SIZE 40 > > > + if (key_sz < VIRTIO_NET_RSS_MIN_KEY_SIZE) { > > > + dev_warn(&vdev->dev, > > > + "rss_max_key_size=%u is less than spec > > minimum %u, disabling RSS\n", > > > + key_sz, VIRTIO_NET_RSS_MIN_KEY_SIZE); > > > + __virtio_clear_bit(vdev, VIRTIO_NET_F_RSS); > > > + __virtio_clear_bit(vdev, > > VIRTIO_NET_F_HASH_REPORT); > > > + } > > > + if (key_sz > NETDEV_RSS_KEY_LEN) { > > > + dev_warn(&vdev->dev, > > > + "rss_max_key_size=%u exceeds driver limit > > %u, disabling RSS\n", > > > + key_sz, NETDEV_RSS_KEY_LEN); > > > + __virtio_clear_bit(vdev, VIRTIO_NET_F_RSS); > > > + __virtio_clear_bit(vdev, > > VIRTIO_NET_F_HASH_REPORT); > > > > you flipped the logic here and it makes no sense now. > > > > Did you test this path? > Yes, tested with Marvell's Octeon device. > > > > > > So if device is powerful and supports a very big key size then... > > we disable the feature? how does this make sense? > The intent isn’t to disable the feature on capable devices, but to ensure the driver never advertises > support for RSS key sizes larger than what the net device can actually handle. Even if a device reports > a very large key size, the driver is constrained by NETDEV_RSS_KEY_LEN, since netdev_rss_key_fill() enforces: > BUG_ON(len > sizeof(netdev_rss_key)); so cap it to NETDEV_RSS_KEY_LEN. Why is that a reason to clear the feature? > > > > > > > + } > > > + } > > > + > > > return 0; > > > } > > > > > > @@ -6839,13 +6860,6 @@ 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; > > > - } > > > - > > > vi->rss_hash_types_supported = > > > virtio_cread32(vdev, offsetof(struct virtio_net_config, > > supported_hash_types)); > > > vi->rss_hash_types_supported &= > > > -- > > > 2.25.1 >