From nobody Sun Feb 8 14:10:24 2026 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 3D051364026 for ; Fri, 9 Jan 2026 15:25:01 +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=1767972303; cv=none; b=Zx/21xxZ4mw2zdyUNQu+y0cRqwUmnJe08cFMwyiJACAh/3ThdE3YYekaMVHm9NM38kZNMB0qysJLJYF4VGSuJmULj3r2QI+LgJ/PvgTxE+bprfw1UlqTz8PA48IbRZu1KJYBLqOyBrbDGtYOf3V8lp9N7sKTsEAoqIP/H83Na6E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767972303; c=relaxed/simple; bh=rA7Y8UtPyPdBI05CiEUYF3kYY4huvyzrXM2GLlcFOnQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IrXNqdm3NmTwstHcM7li+K0t9iSTCEYvUd5hTjNslqSKKFqd1WENeVz//YgPboGWA4V1r5nWKCWKqaFMGupIVmfddXp+TGmcBS9bV4LkOmvw80BskIYnIWCdiKkwkWbpolZS0ilnb2urLqGt4c+fJwk8B63SRWmLN+UpMmYQQ68= 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=Noc/sQBk; 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="Noc/sQBk" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1767972300; 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=Qiyx/HCZumfyMdPnf6Hh0v4xd6N/Ss7/doFj/s49iR4=; b=Noc/sQBkeWU95Aqfhlt/6K3pi2H7yeGOhglp+tMvlKYdQTDF+mET4Xm1PWAJUfGEUH8CgR smMPz4ygfEcuMTdpMCO0xCmrxIlz//PWW36cMCuW3+8k3kFa5dEkFRi8F3Q1ei5bFJIy4S cHe+pfPNjM1h/4t3e1Kqe6DpoDzyhF8= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-592-AysicHXFOPyKsyS6AbmiaA-1; Fri, 09 Jan 2026 10:24:59 -0500 X-MC-Unique: AysicHXFOPyKsyS6AbmiaA-1 X-Mimecast-MFC-AGG-ID: AysicHXFOPyKsyS6AbmiaA_1767972298 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A8A2318002FE; Fri, 9 Jan 2026 15:24:55 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.44.32.96]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 064981956048; Fri, 9 Jan 2026 15:24:49 +0000 (UTC) From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: "Michael S . Tsirkin " Cc: linux-kernel@vger.kernel.org, virtualization@lists.linux.dev, Maxime Coquelin , Laurent Vivier , Cindy Lu , jasowang@redhat.com, Xuan Zhuo , Stefano Garzarella , Yongji Xie , =?UTF-8?q?Eugenio=20P=C3=A9rez?= Subject: [PATCH v11 04/12] vhost: move vdpa group bound check to vhost_vdpa Date: Fri, 9 Jan 2026 16:24:22 +0100 Message-ID: <20260109152430.512923-5-eperezma@redhat.com> In-Reply-To: <20260109152430.512923-1-eperezma@redhat.com> References: <20260109152430.512923-1-eperezma@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Remove duplication by consolidating these here. This reduces the posibility of a parent driver missing them. Signed-off-by: Eugenio P=C3=A9rez --- drivers/vdpa/mlx5/net/mlx5_vnet.c | 3 --- drivers/vdpa/vdpa_sim/vdpa_sim.c | 6 ------ drivers/vhost/vdpa.c | 2 +- 3 files changed, 1 insertion(+), 10 deletions(-) diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5= _vnet.c index ddaa1366704b..44062e9d68f0 100644 --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c @@ -3640,9 +3640,6 @@ static int mlx5_set_group_asid(struct vdpa_device *vd= ev, u32 group, struct mlx5_vdpa_dev *mvdev =3D to_mvdev(vdev); int err =3D 0; =20 - if (group >=3D MLX5_VDPA_NUMVQ_GROUPS) - return -EINVAL; - mvdev->mres.group2asid[group] =3D asid; =20 mutex_lock(&mvdev->mres.lock); diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_= sim.c index c1c6431950e1..df9c7ddc5d78 100644 --- a/drivers/vdpa/vdpa_sim/vdpa_sim.c +++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c @@ -606,12 +606,6 @@ static int vdpasim_set_group_asid(struct vdpa_device *= vdpa, unsigned int group, struct vhost_iotlb *iommu; int i; =20 - if (group > vdpasim->dev_attr.ngroups) - return -EINVAL; - - if (asid >=3D vdpasim->dev_attr.nas) - return -EINVAL; - iommu =3D &vdpasim->iommu[asid]; =20 mutex_lock(&vdpasim->mutex); diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c index 05a481e4c385..9d25b735b43d 100644 --- a/drivers/vhost/vdpa.c +++ b/drivers/vhost/vdpa.c @@ -680,7 +680,7 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v= , unsigned int cmd, case VHOST_VDPA_SET_GROUP_ASID: if (copy_from_user(&s, argp, sizeof(s))) return -EFAULT; - if (s.num >=3D vdpa->nas) + if (idx >=3D vdpa->ngroups || s.num >=3D vdpa->nas) return -EINVAL; if (!ops->set_group_asid) return -EOPNOTSUPP; --=20 2.52.0