Skip to content

Commit 1de95db

Browse files
committed
Merge branch '100GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/net-queue
Tony Nguyen says: ==================== Intel Wired LAN Driver Updates 2025-09-02 (ice, idpf, i40e, ixgbe, e1000e) For ice: Jake adds checks for initialization of Tx timestamp tracking structure to prevent NULL pointer dereferences. For idpf: Josh moves freeing of auxiliary device id to prevent use-after-free issue. Emil sets, expected, MAC type value when sending virtchnl add/delete MAC commands. For i40e: Jake removes read debugfs access as 'netdev_ops' has the possibility to overflow. Zhen Ni adds handling for when MAC list is empty. For ixgbe: Alok Tiwari corrects bitmap being used for link speeds. For e1000e: Vitaly adds check to ensure overflow does not occur in e1000_set_eeprom(). * '100GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/net-queue: e1000e: fix heap overflow in e1000_set_eeprom ixgbe: fix incorrect map used in eee linkmode i40e: Fix potential invalid access when MAC list is empty i40e: remove read access to debugfs files idpf: set mac type when adding and removing MAC filters idpf: fix UAF in RDMA core aux dev deinitialization ice: fix NULL access of tx->in_use in ice_ll_ts_intr ice: fix NULL access of tx->in_use in ice_ptp_ts_irq ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 5d6b58c + 90fb7db commit 1de95db

File tree

9 files changed

+65
-126
lines changed

9 files changed

+65
-126
lines changed

drivers/net/ethernet/intel/e1000e/ethtool.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -549,12 +549,12 @@ static int e1000_set_eeprom(struct net_device *netdev,
549549
{
550550
struct e1000_adapter *adapter = netdev_priv(netdev);
551551
struct e1000_hw *hw = &adapter->hw;
552+
size_t total_len, max_len;
552553
u16 *eeprom_buff;
553-
void *ptr;
554-
int max_len;
554+
int ret_val = 0;
555555
int first_word;
556556
int last_word;
557-
int ret_val = 0;
557+
void *ptr;
558558
u16 i;
559559

560560
if (eeprom->len == 0)
@@ -569,6 +569,10 @@ static int e1000_set_eeprom(struct net_device *netdev,
569569

570570
max_len = hw->nvm.word_size * 2;
571571

572+
if (check_add_overflow(eeprom->offset, eeprom->len, &total_len) ||
573+
total_len > max_len)
574+
return -EFBIG;
575+
572576
first_word = eeprom->offset >> 1;
573577
last_word = (eeprom->offset + eeprom->len - 1) >> 1;
574578
eeprom_buff = kmalloc(max_len, GFP_KERNEL);

drivers/net/ethernet/intel/i40e/i40e_client.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,8 +359,8 @@ static void i40e_client_add_instance(struct i40e_pf *pf)
359359
if (i40e_client_get_params(vsi, &cdev->lan_info.params))
360360
goto free_cdev;
361361

362-
mac = list_first_entry(&cdev->lan_info.netdev->dev_addrs.list,
363-
struct netdev_hw_addr, list);
362+
mac = list_first_entry_or_null(&cdev->lan_info.netdev->dev_addrs.list,
363+
struct netdev_hw_addr, list);
364364
if (mac)
365365
ether_addr_copy(cdev->lan_info.lanmac, mac->addr);
366366
else

drivers/net/ethernet/intel/i40e/i40e_debugfs.c

Lines changed: 19 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -40,48 +40,6 @@ static struct i40e_vsi *i40e_dbg_find_vsi(struct i40e_pf *pf, int seid)
4040
* setup, adding or removing filters, or other things. Many of
4141
* these will be useful for some forms of unit testing.
4242
**************************************************************/
43-
static char i40e_dbg_command_buf[256] = "";
44-
45-
/**
46-
* i40e_dbg_command_read - read for command datum
47-
* @filp: the opened file
48-
* @buffer: where to write the data for the user to read
49-
* @count: the size of the user's buffer
50-
* @ppos: file position offset
51-
**/
52-
static ssize_t i40e_dbg_command_read(struct file *filp, char __user *buffer,
53-
size_t count, loff_t *ppos)
54-
{
55-
struct i40e_pf *pf = filp->private_data;
56-
struct i40e_vsi *main_vsi;
57-
int bytes_not_copied;
58-
int buf_size = 256;
59-
char *buf;
60-
int len;
61-
62-
/* don't allow partial reads */
63-
if (*ppos != 0)
64-
return 0;
65-
if (count < buf_size)
66-
return -ENOSPC;
67-
68-
buf = kzalloc(buf_size, GFP_KERNEL);
69-
if (!buf)
70-
return -ENOSPC;
71-
72-
main_vsi = i40e_pf_get_main_vsi(pf);
73-
len = snprintf(buf, buf_size, "%s: %s\n", main_vsi->netdev->name,
74-
i40e_dbg_command_buf);
75-
76-
bytes_not_copied = copy_to_user(buffer, buf, len);
77-
kfree(buf);
78-
79-
if (bytes_not_copied)
80-
return -EFAULT;
81-
82-
*ppos = len;
83-
return len;
84-
}
8543

8644
static char *i40e_filter_state_string[] = {
8745
"INVALID",
@@ -1621,7 +1579,6 @@ static ssize_t i40e_dbg_command_write(struct file *filp,
16211579
static const struct file_operations i40e_dbg_command_fops = {
16221580
.owner = THIS_MODULE,
16231581
.open = simple_open,
1624-
.read = i40e_dbg_command_read,
16251582
.write = i40e_dbg_command_write,
16261583
};
16271584

@@ -1630,48 +1587,6 @@ static const struct file_operations i40e_dbg_command_fops = {
16301587
* The netdev_ops entry in debugfs is for giving the driver commands
16311588
* to be executed from the netdev operations.
16321589
**************************************************************/
1633-
static char i40e_dbg_netdev_ops_buf[256] = "";
1634-
1635-
/**
1636-
* i40e_dbg_netdev_ops_read - read for netdev_ops datum
1637-
* @filp: the opened file
1638-
* @buffer: where to write the data for the user to read
1639-
* @count: the size of the user's buffer
1640-
* @ppos: file position offset
1641-
**/
1642-
static ssize_t i40e_dbg_netdev_ops_read(struct file *filp, char __user *buffer,
1643-
size_t count, loff_t *ppos)
1644-
{
1645-
struct i40e_pf *pf = filp->private_data;
1646-
struct i40e_vsi *main_vsi;
1647-
int bytes_not_copied;
1648-
int buf_size = 256;
1649-
char *buf;
1650-
int len;
1651-
1652-
/* don't allow partal reads */
1653-
if (*ppos != 0)
1654-
return 0;
1655-
if (count < buf_size)
1656-
return -ENOSPC;
1657-
1658-
buf = kzalloc(buf_size, GFP_KERNEL);
1659-
if (!buf)
1660-
return -ENOSPC;
1661-
1662-
main_vsi = i40e_pf_get_main_vsi(pf);
1663-
len = snprintf(buf, buf_size, "%s: %s\n", main_vsi->netdev->name,
1664-
i40e_dbg_netdev_ops_buf);
1665-
1666-
bytes_not_copied = copy_to_user(buffer, buf, len);
1667-
kfree(buf);
1668-
1669-
if (bytes_not_copied)
1670-
return -EFAULT;
1671-
1672-
*ppos = len;
1673-
return len;
1674-
}
16751590

16761591
/**
16771592
* i40e_dbg_netdev_ops_write - write into netdev_ops datum
@@ -1685,35 +1600,36 @@ static ssize_t i40e_dbg_netdev_ops_write(struct file *filp,
16851600
size_t count, loff_t *ppos)
16861601
{
16871602
struct i40e_pf *pf = filp->private_data;
1603+
char *cmd_buf, *buf_tmp;
16881604
int bytes_not_copied;
16891605
struct i40e_vsi *vsi;
1690-
char *buf_tmp;
16911606
int vsi_seid;
16921607
int i, cnt;
16931608

16941609
/* don't allow partial writes */
16951610
if (*ppos != 0)
16961611
return 0;
1697-
if (count >= sizeof(i40e_dbg_netdev_ops_buf))
1698-
return -ENOSPC;
16991612

1700-
memset(i40e_dbg_netdev_ops_buf, 0, sizeof(i40e_dbg_netdev_ops_buf));
1701-
bytes_not_copied = copy_from_user(i40e_dbg_netdev_ops_buf,
1702-
buffer, count);
1703-
if (bytes_not_copied)
1613+
cmd_buf = kzalloc(count + 1, GFP_KERNEL);
1614+
if (!cmd_buf)
1615+
return count;
1616+
bytes_not_copied = copy_from_user(cmd_buf, buffer, count);
1617+
if (bytes_not_copied) {
1618+
kfree(cmd_buf);
17041619
return -EFAULT;
1705-
i40e_dbg_netdev_ops_buf[count] = '\0';
1620+
}
1621+
cmd_buf[count] = '\0';
17061622

1707-
buf_tmp = strchr(i40e_dbg_netdev_ops_buf, '\n');
1623+
buf_tmp = strchr(cmd_buf, '\n');
17081624
if (buf_tmp) {
17091625
*buf_tmp = '\0';
1710-
count = buf_tmp - i40e_dbg_netdev_ops_buf + 1;
1626+
count = buf_tmp - cmd_buf + 1;
17111627
}
17121628

1713-
if (strncmp(i40e_dbg_netdev_ops_buf, "change_mtu", 10) == 0) {
1629+
if (strncmp(cmd_buf, "change_mtu", 10) == 0) {
17141630
int mtu;
17151631

1716-
cnt = sscanf(&i40e_dbg_netdev_ops_buf[11], "%i %i",
1632+
cnt = sscanf(&cmd_buf[11], "%i %i",
17171633
&vsi_seid, &mtu);
17181634
if (cnt != 2) {
17191635
dev_info(&pf->pdev->dev, "change_mtu <vsi_seid> <mtu>\n");
@@ -1735,8 +1651,8 @@ static ssize_t i40e_dbg_netdev_ops_write(struct file *filp,
17351651
dev_info(&pf->pdev->dev, "Could not acquire RTNL - please try again\n");
17361652
}
17371653

1738-
} else if (strncmp(i40e_dbg_netdev_ops_buf, "set_rx_mode", 11) == 0) {
1739-
cnt = sscanf(&i40e_dbg_netdev_ops_buf[11], "%i", &vsi_seid);
1654+
} else if (strncmp(cmd_buf, "set_rx_mode", 11) == 0) {
1655+
cnt = sscanf(&cmd_buf[11], "%i", &vsi_seid);
17401656
if (cnt != 1) {
17411657
dev_info(&pf->pdev->dev, "set_rx_mode <vsi_seid>\n");
17421658
goto netdev_ops_write_done;
@@ -1756,8 +1672,8 @@ static ssize_t i40e_dbg_netdev_ops_write(struct file *filp,
17561672
dev_info(&pf->pdev->dev, "Could not acquire RTNL - please try again\n");
17571673
}
17581674

1759-
} else if (strncmp(i40e_dbg_netdev_ops_buf, "napi", 4) == 0) {
1760-
cnt = sscanf(&i40e_dbg_netdev_ops_buf[4], "%i", &vsi_seid);
1675+
} else if (strncmp(cmd_buf, "napi", 4) == 0) {
1676+
cnt = sscanf(&cmd_buf[4], "%i", &vsi_seid);
17611677
if (cnt != 1) {
17621678
dev_info(&pf->pdev->dev, "napi <vsi_seid>\n");
17631679
goto netdev_ops_write_done;
@@ -1775,21 +1691,20 @@ static ssize_t i40e_dbg_netdev_ops_write(struct file *filp,
17751691
dev_info(&pf->pdev->dev, "napi called\n");
17761692
}
17771693
} else {
1778-
dev_info(&pf->pdev->dev, "unknown command '%s'\n",
1779-
i40e_dbg_netdev_ops_buf);
1694+
dev_info(&pf->pdev->dev, "unknown command '%s'\n", cmd_buf);
17801695
dev_info(&pf->pdev->dev, "available commands\n");
17811696
dev_info(&pf->pdev->dev, " change_mtu <vsi_seid> <mtu>\n");
17821697
dev_info(&pf->pdev->dev, " set_rx_mode <vsi_seid>\n");
17831698
dev_info(&pf->pdev->dev, " napi <vsi_seid>\n");
17841699
}
17851700
netdev_ops_write_done:
1701+
kfree(cmd_buf);
17861702
return count;
17871703
}
17881704

17891705
static const struct file_operations i40e_dbg_netdev_ops_fops = {
17901706
.owner = THIS_MODULE,
17911707
.open = simple_open,
1792-
.read = i40e_dbg_netdev_ops_read,
17931708
.write = i40e_dbg_netdev_ops_write,
17941709
};
17951710

drivers/net/ethernet/intel/ice/ice_main.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3176,12 +3176,14 @@ static irqreturn_t ice_ll_ts_intr(int __always_unused irq, void *data)
31763176
hw = &pf->hw;
31773177
tx = &pf->ptp.port.tx;
31783178
spin_lock_irqsave(&tx->lock, flags);
3179-
ice_ptp_complete_tx_single_tstamp(tx);
3179+
if (tx->init) {
3180+
ice_ptp_complete_tx_single_tstamp(tx);
31803181

3181-
idx = find_next_bit_wrap(tx->in_use, tx->len,
3182-
tx->last_ll_ts_idx_read + 1);
3183-
if (idx != tx->len)
3184-
ice_ptp_req_tx_single_tstamp(tx, idx);
3182+
idx = find_next_bit_wrap(tx->in_use, tx->len,
3183+
tx->last_ll_ts_idx_read + 1);
3184+
if (idx != tx->len)
3185+
ice_ptp_req_tx_single_tstamp(tx, idx);
3186+
}
31853187
spin_unlock_irqrestore(&tx->lock, flags);
31863188

31873189
val = GLINT_DYN_CTL_INTENA_M | GLINT_DYN_CTL_CLEARPBA_M |

drivers/net/ethernet/intel/ice/ice_ptp.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2701,16 +2701,19 @@ irqreturn_t ice_ptp_ts_irq(struct ice_pf *pf)
27012701
*/
27022702
if (hw->dev_caps.ts_dev_info.ts_ll_int_read) {
27032703
struct ice_ptp_tx *tx = &pf->ptp.port.tx;
2704-
u8 idx;
2704+
u8 idx, last;
27052705

27062706
if (!ice_pf_state_is_nominal(pf))
27072707
return IRQ_HANDLED;
27082708

27092709
spin_lock(&tx->lock);
2710-
idx = find_next_bit_wrap(tx->in_use, tx->len,
2711-
tx->last_ll_ts_idx_read + 1);
2712-
if (idx != tx->len)
2713-
ice_ptp_req_tx_single_tstamp(tx, idx);
2710+
if (tx->init) {
2711+
last = tx->last_ll_ts_idx_read + 1;
2712+
idx = find_next_bit_wrap(tx->in_use, tx->len,
2713+
last);
2714+
if (idx != tx->len)
2715+
ice_ptp_req_tx_single_tstamp(tx, idx);
2716+
}
27142717
spin_unlock(&tx->lock);
27152718

27162719
return IRQ_HANDLED;

drivers/net/ethernet/intel/idpf/idpf_idc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,10 @@ static void idpf_unplug_aux_dev(struct auxiliary_device *adev)
247247
if (!adev)
248248
return;
249249

250+
ida_free(&idpf_idc_ida, adev->id);
251+
250252
auxiliary_device_delete(adev);
251253
auxiliary_device_uninit(adev);
252-
253-
ida_free(&idpf_idc_ida, adev->id);
254254
}
255255

256256
/**

drivers/net/ethernet/intel/idpf/idpf_lib.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2344,6 +2344,7 @@ static int idpf_set_mac(struct net_device *netdev, void *p)
23442344
struct idpf_netdev_priv *np = netdev_priv(netdev);
23452345
struct idpf_vport_config *vport_config;
23462346
struct sockaddr *addr = p;
2347+
u8 old_mac_addr[ETH_ALEN];
23472348
struct idpf_vport *vport;
23482349
int err = 0;
23492350

@@ -2367,17 +2368,19 @@ static int idpf_set_mac(struct net_device *netdev, void *p)
23672368
if (ether_addr_equal(netdev->dev_addr, addr->sa_data))
23682369
goto unlock_mutex;
23692370

2371+
ether_addr_copy(old_mac_addr, vport->default_mac_addr);
2372+
ether_addr_copy(vport->default_mac_addr, addr->sa_data);
23702373
vport_config = vport->adapter->vport_config[vport->idx];
23712374
err = idpf_add_mac_filter(vport, np, addr->sa_data, false);
23722375
if (err) {
23732376
__idpf_del_mac_filter(vport_config, addr->sa_data);
2377+
ether_addr_copy(vport->default_mac_addr, netdev->dev_addr);
23742378
goto unlock_mutex;
23752379
}
23762380

2377-
if (is_valid_ether_addr(vport->default_mac_addr))
2378-
idpf_del_mac_filter(vport, np, vport->default_mac_addr, false);
2381+
if (is_valid_ether_addr(old_mac_addr))
2382+
__idpf_del_mac_filter(vport_config, old_mac_addr);
23792383

2380-
ether_addr_copy(vport->default_mac_addr, addr->sa_data);
23812384
eth_hw_addr_set(netdev, addr->sa_data);
23822385

23832386
unlock_mutex:

drivers/net/ethernet/intel/idpf/idpf_virtchnl.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3765,6 +3765,16 @@ u32 idpf_get_vport_id(struct idpf_vport *vport)
37653765
return le32_to_cpu(vport_msg->vport_id);
37663766
}
37673767

3768+
static void idpf_set_mac_type(struct idpf_vport *vport,
3769+
struct virtchnl2_mac_addr *mac_addr)
3770+
{
3771+
bool is_primary;
3772+
3773+
is_primary = ether_addr_equal(vport->default_mac_addr, mac_addr->addr);
3774+
mac_addr->type = is_primary ? VIRTCHNL2_MAC_ADDR_PRIMARY :
3775+
VIRTCHNL2_MAC_ADDR_EXTRA;
3776+
}
3777+
37683778
/**
37693779
* idpf_mac_filter_async_handler - Async callback for mac filters
37703780
* @adapter: private data struct
@@ -3894,13 +3904,15 @@ int idpf_add_del_mac_filters(struct idpf_vport *vport,
38943904
list) {
38953905
if (add && f->add) {
38963906
ether_addr_copy(mac_addr[i].addr, f->macaddr);
3907+
idpf_set_mac_type(vport, &mac_addr[i]);
38973908
i++;
38983909
f->add = false;
38993910
if (i == total_filters)
39003911
break;
39013912
}
39023913
if (!add && f->remove) {
39033914
ether_addr_copy(mac_addr[i].addr, f->macaddr);
3915+
idpf_set_mac_type(vport, &mac_addr[i]);
39043916
i++;
39053917
f->remove = false;
39063918
if (i == total_filters)

drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3571,13 +3571,13 @@ ixgbe_get_eee_fw(struct ixgbe_adapter *adapter, struct ethtool_keee *edata)
35713571

35723572
for (i = 0; i < ARRAY_SIZE(ixgbe_ls_map); ++i) {
35733573
if (hw->phy.eee_speeds_supported & ixgbe_ls_map[i].mac_speed)
3574-
linkmode_set_bit(ixgbe_lp_map[i].link_mode,
3574+
linkmode_set_bit(ixgbe_ls_map[i].link_mode,
35753575
edata->supported);
35763576
}
35773577

35783578
for (i = 0; i < ARRAY_SIZE(ixgbe_ls_map); ++i) {
35793579
if (hw->phy.eee_speeds_advertised & ixgbe_ls_map[i].mac_speed)
3580-
linkmode_set_bit(ixgbe_lp_map[i].link_mode,
3580+
linkmode_set_bit(ixgbe_ls_map[i].link_mode,
35813581
edata->advertised);
35823582
}
35833583

0 commit comments

Comments
 (0)