Skip to content

Commit e70c84f

Browse files
author
CKI KWF Bot
committed
Merge: octeon_ep: Validate the VF ID
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/7358 JIRA: https://issues.redhat.com/browse/RHEL-113707 commit af82e85 Author: Kamal Heib <kheib@redhat.com> Date: Thu Sep 11 18:36:10 2025 -0400 octeon_ep: Validate the VF ID Add a helper to validate the VF ID and use it in the VF ndo ops to prevent accessing out-of-range entries. Without this check, users can run commands such as: 2: enp135s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000 link/ether 00:00:00:01:01:00 brd ff:ff:ff:ff:ff:ff vf 0 link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff, spoof checking on, link-state enable, trust off vf 1 link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff, spoof checking on, link-state enable, trust off 0 even though VF 4 does not exist, which results in silent success instead of returning an error. Fixes: 8a241ef ("octeon_ep: add ndo ops for VFs in PF driver") Signed-off-by: Kamal Heib <kheib@redhat.com> Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://patch.msgid.link/20250911223610.1803144-1-kheib@redhat.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Kamal Heib <kheib@redhat.com> Approved-by: José Ignacio Tornos Martínez <jtornosm@redhat.com> Approved-by: Michal Schmidt <mschmidt@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: CKI GitLab Kmaint Pipeline Bot <26919896-cki-kmaint-pipeline-bot@users.noreply.gitlab.com>
2 parents 0855e43 + 033ec00 commit e70c84f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

drivers/net/ethernet/marvell/octeon_ep/octep_main.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,11 +1124,24 @@ static int octep_set_features(struct net_device *dev, netdev_features_t features
11241124
return err;
11251125
}
11261126

1127+
static bool octep_is_vf_valid(struct octep_device *oct, int vf)
1128+
{
1129+
if (vf >= CFG_GET_ACTIVE_VFS(oct->conf)) {
1130+
netdev_err(oct->netdev, "Invalid VF ID %d\n", vf);
1131+
return false;
1132+
}
1133+
1134+
return true;
1135+
}
1136+
11271137
static int octep_get_vf_config(struct net_device *dev, int vf,
11281138
struct ifla_vf_info *ivi)
11291139
{
11301140
struct octep_device *oct = netdev_priv(dev);
11311141

1142+
if (!octep_is_vf_valid(oct, vf))
1143+
return -EINVAL;
1144+
11321145
ivi->vf = vf;
11331146
ether_addr_copy(ivi->mac, oct->vf_info[vf].mac_addr);
11341147
ivi->spoofchk = true;
@@ -1143,6 +1156,9 @@ static int octep_set_vf_mac(struct net_device *dev, int vf, u8 *mac)
11431156
struct octep_device *oct = netdev_priv(dev);
11441157
int err;
11451158

1159+
if (!octep_is_vf_valid(oct, vf))
1160+
return -EINVAL;
1161+
11461162
if (!is_valid_ether_addr(mac)) {
11471163
dev_err(&oct->pdev->dev, "Invalid MAC Address %pM\n", mac);
11481164
return -EADDRNOTAVAIL;

0 commit comments

Comments
 (0)