Skip to content

Commit e1cd42a

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-03-18 (ice, idpf) For ice: Przemek modifies string declarations to resolve compile issues on gcc 7.5. Karol adds padding to initial programming of GLTSYN_TIME* registers to ensure it will occur in the future to prevent hardware issues. Jesse Brandeburg turns off driver RDMA capability when the corresponding kernel config is not enabled to aid in preventing resource exhaustion. Jan adjusts type declaration to properly catch error conditions and prevent truncation of values. He also adds bounds checking to prevent overflow in ice_vc_cfg_q_quanta(). Lukasz adds checking and error reporting for invalid values in ice_vc_cfg_q_bw(). Mateusz adds check for valid size for ice_vc_fdir_parse_raw(). For idpf: Emil adds check, and handling, on failure to register netdev. * '100GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/net-queue: idpf: check error for register_netdev() on init ice: fix using untrusted value of pkt_len in ice_vc_fdir_parse_raw() ice: fix input validation for virtchnl BW ice: validate queue quanta parameters to prevent OOB access ice: stop truncating queue ids when checking virtchnl: make proto and filter action count unsigned ice: fix reservation of resources for RDMA when disabled ice: ensure periodic output start time is in the future ice: health.c: fix compilation on gcc 7.5 ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents cec7dde + 680811c commit e1cd42a

File tree

7 files changed

+79
-34
lines changed

7 files changed

+79
-34
lines changed

drivers/net/ethernet/intel/ice/devlink/health.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ struct ice_health_status {
2525
* The below lookup requires to be sorted by code.
2626
*/
2727

28-
static const char *const ice_common_port_solutions =
28+
static const char ice_common_port_solutions[] =
2929
"Check your cable connection. Change or replace the module or cable. Manually set speed and duplex.";
30-
static const char *const ice_port_number_label = "Port Number";
31-
static const char *const ice_update_nvm_solution = "Update to the latest NVM image.";
30+
static const char ice_port_number_label[] = "Port Number";
31+
static const char ice_update_nvm_solution[] = "Update to the latest NVM image.";
3232

3333
static const struct ice_health_status ice_health_status_lookup[] = {
3434
{ICE_AQC_HEALTH_STATUS_ERR_UNKNOWN_MOD_STRICT, "An unsupported module was detected.",

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2271,7 +2271,8 @@ ice_parse_common_caps(struct ice_hw *hw, struct ice_hw_common_caps *caps,
22712271
caps->nvm_unified_update);
22722272
break;
22732273
case ICE_AQC_CAPS_RDMA:
2274-
caps->rdma = (number == 1);
2274+
if (IS_ENABLED(CONFIG_INFINIBAND_IRDMA))
2275+
caps->rdma = (number == 1);
22752276
ice_debug(hw, ICE_DBG_INIT, "%s: rdma = %d\n", prefix, caps->rdma);
22762277
break;
22772278
case ICE_AQC_CAPS_MAX_MTU:

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1783,6 +1783,7 @@ static int ice_ptp_write_perout(struct ice_hw *hw, unsigned int chan,
17831783
8 + chan + (tmr_idx * 4));
17841784

17851785
wr32(hw, GLGEN_GPIO_CTL(gpio_pin), val);
1786+
ice_flush(hw);
17861787

17871788
return 0;
17881789
}
@@ -1843,9 +1844,10 @@ static int ice_ptp_cfg_perout(struct ice_pf *pf, struct ptp_perout_request *rq,
18431844
div64_u64_rem(start, period, &phase);
18441845

18451846
/* If we have only phase or start time is in the past, start the timer
1846-
* at the next multiple of period, maintaining phase.
1847+
* at the next multiple of period, maintaining phase at least 0.5 second
1848+
* from now, so we have time to write it to HW.
18471849
*/
1848-
clk = ice_ptp_read_src_clk_reg(pf, NULL);
1850+
clk = ice_ptp_read_src_clk_reg(pf, NULL) + NSEC_PER_MSEC * 500;
18491851
if (rq->flags & PTP_PEROUT_PHASE || start <= clk - prop_delay_ns)
18501852
start = div64_u64(clk + period - 1, period) * period + phase;
18511853

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

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ bool ice_vc_isvalid_vsi_id(struct ice_vf *vf, u16 vsi_id)
562562
*
563563
* check for the valid queue ID
564564
*/
565-
static bool ice_vc_isvalid_q_id(struct ice_vsi *vsi, u8 qid)
565+
static bool ice_vc_isvalid_q_id(struct ice_vsi *vsi, u16 qid)
566566
{
567567
/* allocated Tx and Rx queues should be always equal for VF VSI */
568568
return qid < vsi->alloc_txq;
@@ -1862,15 +1862,33 @@ static int ice_vc_cfg_q_bw(struct ice_vf *vf, u8 *msg)
18621862

18631863
for (i = 0; i < qbw->num_queues; i++) {
18641864
if (qbw->cfg[i].shaper.peak != 0 && vf->max_tx_rate != 0 &&
1865-
qbw->cfg[i].shaper.peak > vf->max_tx_rate)
1865+
qbw->cfg[i].shaper.peak > vf->max_tx_rate) {
18661866
dev_warn(ice_pf_to_dev(vf->pf), "The maximum queue %d rate limit configuration may not take effect because the maximum TX rate for VF-%d is %d\n",
18671867
qbw->cfg[i].queue_id, vf->vf_id,
18681868
vf->max_tx_rate);
1869+
v_ret = VIRTCHNL_STATUS_ERR_PARAM;
1870+
goto err;
1871+
}
18691872
if (qbw->cfg[i].shaper.committed != 0 && vf->min_tx_rate != 0 &&
1870-
qbw->cfg[i].shaper.committed < vf->min_tx_rate)
1873+
qbw->cfg[i].shaper.committed < vf->min_tx_rate) {
18711874
dev_warn(ice_pf_to_dev(vf->pf), "The minimum queue %d rate limit configuration may not take effect because the minimum TX rate for VF-%d is %d\n",
18721875
qbw->cfg[i].queue_id, vf->vf_id,
1873-
vf->max_tx_rate);
1876+
vf->min_tx_rate);
1877+
v_ret = VIRTCHNL_STATUS_ERR_PARAM;
1878+
goto err;
1879+
}
1880+
if (qbw->cfg[i].queue_id > vf->num_vf_qs) {
1881+
dev_warn(ice_pf_to_dev(vf->pf), "VF-%d trying to configure invalid queue_id\n",
1882+
vf->vf_id);
1883+
v_ret = VIRTCHNL_STATUS_ERR_PARAM;
1884+
goto err;
1885+
}
1886+
if (qbw->cfg[i].tc >= ICE_MAX_TRAFFIC_CLASS) {
1887+
dev_warn(ice_pf_to_dev(vf->pf), "VF-%d trying to configure a traffic class higher than allowed\n",
1888+
vf->vf_id);
1889+
v_ret = VIRTCHNL_STATUS_ERR_PARAM;
1890+
goto err;
1891+
}
18741892
}
18751893

18761894
for (i = 0; i < qbw->num_queues; i++) {
@@ -1900,13 +1918,21 @@ static int ice_vc_cfg_q_bw(struct ice_vf *vf, u8 *msg)
19001918
*/
19011919
static int ice_vc_cfg_q_quanta(struct ice_vf *vf, u8 *msg)
19021920
{
1921+
u16 quanta_prof_id, quanta_size, start_qid, num_queues, end_qid, i;
19031922
enum virtchnl_status_code v_ret = VIRTCHNL_STATUS_SUCCESS;
1904-
u16 quanta_prof_id, quanta_size, start_qid, end_qid, i;
19051923
struct virtchnl_quanta_cfg *qquanta =
19061924
(struct virtchnl_quanta_cfg *)msg;
19071925
struct ice_vsi *vsi;
19081926
int ret;
19091927

1928+
start_qid = qquanta->queue_select.start_queue_id;
1929+
num_queues = qquanta->queue_select.num_queues;
1930+
1931+
if (check_add_overflow(start_qid, num_queues, &end_qid)) {
1932+
v_ret = VIRTCHNL_STATUS_ERR_PARAM;
1933+
goto err;
1934+
}
1935+
19101936
if (!test_bit(ICE_VF_STATE_ACTIVE, vf->vf_states)) {
19111937
v_ret = VIRTCHNL_STATUS_ERR_PARAM;
19121938
goto err;
@@ -1918,8 +1944,6 @@ static int ice_vc_cfg_q_quanta(struct ice_vf *vf, u8 *msg)
19181944
goto err;
19191945
}
19201946

1921-
end_qid = qquanta->queue_select.start_queue_id +
1922-
qquanta->queue_select.num_queues;
19231947
if (end_qid > ICE_MAX_RSS_QS_PER_VF ||
19241948
end_qid > min_t(u16, vsi->alloc_txq, vsi->alloc_rxq)) {
19251949
dev_err(ice_pf_to_dev(vf->pf), "VF-%d trying to configure more than allocated number of queues: %d\n",
@@ -1948,7 +1972,6 @@ static int ice_vc_cfg_q_quanta(struct ice_vf *vf, u8 *msg)
19481972
goto err;
19491973
}
19501974

1951-
start_qid = qquanta->queue_select.start_queue_id;
19521975
for (i = start_qid; i < end_qid; i++)
19531976
vsi->tx_rings[i]->quanta_prof_id = quanta_prof_id;
19541977

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

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -832,21 +832,27 @@ ice_vc_fdir_parse_raw(struct ice_vf *vf,
832832
struct virtchnl_proto_hdrs *proto,
833833
struct virtchnl_fdir_fltr_conf *conf)
834834
{
835-
u8 *pkt_buf, *msk_buf __free(kfree);
835+
u8 *pkt_buf, *msk_buf __free(kfree) = NULL;
836836
struct ice_parser_result rslt;
837837
struct ice_pf *pf = vf->pf;
838+
u16 pkt_len, udp_port = 0;
838839
struct ice_parser *psr;
839840
int status = -ENOMEM;
840841
struct ice_hw *hw;
841-
u16 udp_port = 0;
842842

843-
pkt_buf = kzalloc(proto->raw.pkt_len, GFP_KERNEL);
844-
msk_buf = kzalloc(proto->raw.pkt_len, GFP_KERNEL);
843+
pkt_len = proto->raw.pkt_len;
844+
845+
if (!pkt_len || pkt_len > VIRTCHNL_MAX_SIZE_RAW_PACKET)
846+
return -EINVAL;
847+
848+
pkt_buf = kzalloc(pkt_len, GFP_KERNEL);
849+
msk_buf = kzalloc(pkt_len, GFP_KERNEL);
850+
845851
if (!pkt_buf || !msk_buf)
846852
goto err_mem_alloc;
847853

848-
memcpy(pkt_buf, proto->raw.spec, proto->raw.pkt_len);
849-
memcpy(msk_buf, proto->raw.mask, proto->raw.pkt_len);
854+
memcpy(pkt_buf, proto->raw.spec, pkt_len);
855+
memcpy(msk_buf, proto->raw.mask, pkt_len);
850856

851857
hw = &pf->hw;
852858

@@ -862,7 +868,7 @@ ice_vc_fdir_parse_raw(struct ice_vf *vf,
862868
if (ice_get_open_tunnel_port(hw, &udp_port, TNL_VXLAN))
863869
ice_parser_vxlan_tunnel_set(psr, udp_port, true);
864870

865-
status = ice_parser_run(psr, pkt_buf, proto->raw.pkt_len, &rslt);
871+
status = ice_parser_run(psr, pkt_buf, pkt_len, &rslt);
866872
if (status)
867873
goto err_parser_destroy;
868874

@@ -876,7 +882,7 @@ ice_vc_fdir_parse_raw(struct ice_vf *vf,
876882
}
877883

878884
status = ice_parser_profile_init(&rslt, pkt_buf, msk_buf,
879-
proto->raw.pkt_len, ICE_BLK_FD,
885+
pkt_len, ICE_BLK_FD,
880886
conf->prof);
881887
if (status)
882888
goto err_parser_profile_init;
@@ -885,7 +891,7 @@ ice_vc_fdir_parse_raw(struct ice_vf *vf,
885891
ice_parser_profile_dump(hw, conf->prof);
886892

887893
/* Store raw flow info into @conf */
888-
conf->pkt_len = proto->raw.pkt_len;
894+
conf->pkt_len = pkt_len;
889895
conf->pkt_buf = pkt_buf;
890896
conf->parser_ena = true;
891897

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

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -927,15 +927,19 @@ static int idpf_stop(struct net_device *netdev)
927927
static void idpf_decfg_netdev(struct idpf_vport *vport)
928928
{
929929
struct idpf_adapter *adapter = vport->adapter;
930+
u16 idx = vport->idx;
930931

931932
kfree(vport->rx_ptype_lkup);
932933
vport->rx_ptype_lkup = NULL;
933934

934-
unregister_netdev(vport->netdev);
935-
free_netdev(vport->netdev);
935+
if (test_and_clear_bit(IDPF_VPORT_REG_NETDEV,
936+
adapter->vport_config[idx]->flags)) {
937+
unregister_netdev(vport->netdev);
938+
free_netdev(vport->netdev);
939+
}
936940
vport->netdev = NULL;
937941

938-
adapter->netdevs[vport->idx] = NULL;
942+
adapter->netdevs[idx] = NULL;
939943
}
940944

941945
/**
@@ -1536,13 +1540,22 @@ void idpf_init_task(struct work_struct *work)
15361540
}
15371541

15381542
for (index = 0; index < adapter->max_vports; index++) {
1539-
if (adapter->netdevs[index] &&
1540-
!test_bit(IDPF_VPORT_REG_NETDEV,
1541-
adapter->vport_config[index]->flags)) {
1542-
register_netdev(adapter->netdevs[index]);
1543-
set_bit(IDPF_VPORT_REG_NETDEV,
1544-
adapter->vport_config[index]->flags);
1543+
struct net_device *netdev = adapter->netdevs[index];
1544+
struct idpf_vport_config *vport_config;
1545+
1546+
vport_config = adapter->vport_config[index];
1547+
1548+
if (!netdev ||
1549+
test_bit(IDPF_VPORT_REG_NETDEV, vport_config->flags))
1550+
continue;
1551+
1552+
err = register_netdev(netdev);
1553+
if (err) {
1554+
dev_err(&pdev->dev, "failed to register netdev for vport %d: %pe\n",
1555+
index, ERR_PTR(err));
1556+
continue;
15451557
}
1558+
set_bit(IDPF_VPORT_REG_NETDEV, vport_config->flags);
15461559
}
15471560

15481561
/* As all the required vports are created, clear the reset flag

include/linux/avf/virtchnl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,7 +1283,7 @@ struct virtchnl_proto_hdrs {
12831283
* 2 - from the second inner layer
12841284
* ....
12851285
**/
1286-
int count; /* the proto layers must < VIRTCHNL_MAX_NUM_PROTO_HDRS */
1286+
u32 count; /* the proto layers must < VIRTCHNL_MAX_NUM_PROTO_HDRS */
12871287
union {
12881288
struct virtchnl_proto_hdr
12891289
proto_hdr[VIRTCHNL_MAX_NUM_PROTO_HDRS];
@@ -1335,7 +1335,7 @@ VIRTCHNL_CHECK_STRUCT_LEN(36, virtchnl_filter_action);
13351335

13361336
struct virtchnl_filter_action_set {
13371337
/* action number must be less then VIRTCHNL_MAX_NUM_ACTIONS */
1338-
int count;
1338+
u32 count;
13391339
struct virtchnl_filter_action actions[VIRTCHNL_MAX_NUM_ACTIONS];
13401340
};
13411341

0 commit comments

Comments
 (0)