Intel Wired LAN Driver Updates 2026-07-17 (ice, idpf, iavf)
Subsystems (4)
Tony Nguyen
maintainerFor ice:
Vincent Chen fixes issue preventing VF creation when switchdev is not enabled in the configuration.
Michal fixes issue with checksum advertisement and handling with extension headers.
Additional details:
https://lore.kernel.org/intel-wired-lan/[email protected]/
Marcin corrects iteration value for profile association that was truncating profiles.
Karol bypasses, unnecessary, waiting on sideband queue PTP writes which can cause failures with phc_ctl program.
Sergey adds READ_ONCE() to access of PHC time to prevent torn read on 32-bit systems.
Paul adds a check for uninitialized PTP state before attempting to rebuild it and restricts check of TxTime to be for PF VSI only.
Alex adds bounds check on PTYPE to prevent possible out-of-bounds write.
For idpf:
Emil defers setting of adapter max_vports value to prevent inadvertent use if interim allocation errors are encountered.
For iavf:
Junrui Luo checks and clamps VSI size from virtchnl to prevent out-of-bounds accesses.
The following are changes since commit 56d96fededd61192cd7cc8d2b0f36adfd59036c3:
mpls: fix NULL deref in mpls_valid_fib_dump_req() on CONFIG_INET=n
and are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/net-queue 100GbE
Aleksandr Loktionov (1):
ice: reject out-of-range ptype in ice_parser_profile_init
Emil Tantilov (1):
idpf: fix max_vport related crash on allocation error during init
Junrui Luo (1):
iavf: validate num_vsis in VIRTCHNL_OP_GET_VF_RESOURCES response
Karol Kolacinski (1):
ice: support SBQ posted writes with non-posted support for CGU
Marcin Szycik (1):
ice: fix LAG recipe to profile association
Michal Swiatkowski (3):
ice: pass the return value of skb_checksum_help()
ice: always do GCS if hardware supports it
ice: use NETIF_F_HW_CSUM instead of IP/IPV6
Paul Greenwalt (2):
ice: fix PTP Call Trace during PTP release
ice: prevent tstamp ring allocation for non-PF VSI types
Sergey Temerkhanov (1):
ice: use READ_ONCE() to access cached PHC time
Vincent Chen (2):
ice: allow creating VFs when !CONFIG_ICE_SWITCHDEV
ice: remove redundant switchdev check in ice_eswitch_attach_vf()
.../net/ethernet/intel/iavf/iavf_virtchnl.c | 26 ++++++++-- drivers/net/ethernet/intel/ice/ice.h | 3 ++ drivers/net/ethernet/intel/ice/ice_common.c | 25 ++++++++-- drivers/net/ethernet/intel/ice/ice_controlq.c | 4 ++ drivers/net/ethernet/intel/ice/ice_controlq.h | 1 + drivers/net/ethernet/intel/ice/ice_eswitch.c | 3 -- drivers/net/ethernet/intel/ice/ice_lag.c | 2 +- drivers/net/ethernet/intel/ice/ice_lib.c | 4 ++ drivers/net/ethernet/intel/ice/ice_main.c | 21 +-------- drivers/net/ethernet/intel/ice/ice_parser.c | 3 ++ drivers/net/ethernet/intel/ice/ice_ptp.c | 7 ++- drivers/net/ethernet/intel/ice/ice_ptp_hw.c | 47 +++++++++++++------ drivers/net/ethernet/intel/ice/ice_sbq_cmd.h | 2 +- drivers/net/ethernet/intel/ice/ice_sriov.c | 14 +++--- drivers/net/ethernet/intel/ice/ice_txrx.c | 22 ++++----- drivers/net/ethernet/intel/ice/ice_txrx.h | 1 + drivers/net/ethernet/intel/ice/ice_vf_lib.c | 3 +- .../net/ethernet/intel/idpf/idpf_virtchnl.c | 7 ++- 18 files changed, 124 insertions(+), 71 deletions(-)
Signature · 1 line
2.47.1
Tony Nguyen
maintainerPATCH 1/13 ice: allow creating VFs when !CONFIG_ICE_SWITCHDEV
From: Vincent Chen <[email protected]>
Currently ice_eswitch_attach_vf() is called unconditionally in ice_start_vfs(), which causes VF creation to fail when CONFIG_ICE_SWITCHDEV is not defined.
Fix this by adding switchdev mode checks at the call sites before calling ice_eswitch_attach_vf(), consistent with how ice_eswitch_attach_sf() is already handled in ice_devlink_port_new(). This is similar to commit aacca7a83b97 ("ice: allow creating VFs for !CONFIG_NET_SWITCHDEV") which fixed the same issue for the previous ice_eswitch_configure() API.
--- drivers/net/ethernet/intel/ice/ice_sriov.c | 14 ++++++++------ drivers/net/ethernet/intel/ice/ice_vf_lib.c | 3 ++- 2 files changed, 10 insertions(+), 7 deletions(-)
drivers/net/ethernet/intel/ice/ice_sriov.c +8 -6
@@ -484,12 +484,14 @@ static int ice_start_vfs(struct ice_pf *pf) goto teardown; } - retval =ice_eswitch_attach_vf (pf, vf); -if (retval) { -dev_err (ice_pf_to_dev (pf),"Failed to attach VF %d to eswitch, error %d" , - vf->vf_id, retval); -ice_vf_vsi_release (vf); - goto teardown; +if (ice_is_eswitch_mode_switchdev (pf)) { + retval =ice_eswitch_attach_vf (pf, vf); +if (retval) { +dev_err (ice_pf_to_dev (pf),"Failed to attach VF %d to eswitch, error %d" , + vf->vf_id, retval); +ice_vf_vsi_release (vf); + goto teardown; + } }set_bit (ICE_VF_STATE_INIT , vf->vf_states);
drivers/net/ethernet/intel/ice/ice_vf_lib.c +2 -1
@@ -812,7 +812,8 @@ void ice_reset_all_vfs(struct ice_pf *pf) }ice_vf_post_vsi_rebuild (vf); -ice_eswitch_attach_vf (pf, vf); +if (ice_is_eswitch_mode_switchdev (pf)) +ice_eswitch_attach_vf (pf, vf);mutex_unlock (&vf->cfg_lock); }
Signature · 1 line
2.47.1
Tony Nguyen
maintainerPATCH 2/13 ice: remove redundant switchdev check in ice_eswitch_attach_vf()
In reply to Tony NguyenFrom: Vincent Chen <[email protected]>
All callers of ice_eswitch_attach_vf() check the switchdev mode before calling the function, the internal switchdev mode check in ice_eswitch_attach_vf() is redundant. Remove this check to align with the design pattern used for ice_eswitch_attach_sf(), where the caller is responsible for checking switchdev mode before attachment.
--- drivers/net/ethernet/intel/ice/ice_eswitch.c | 3 --- 1 file changed, 3 deletions(-)
drivers/net/ethernet/intel/ice/ice_eswitch.c +0 -3
@@ -512,9 +512,6 @@ int ice_eswitch_attach_vf(struct ice_pf *pf, struct ice_vf *vf)struct ice_repr *repr;int err; -if (!ice_is_eswitch_mode_switchdev (pf)) -return 0 ; - repr =ice_repr_create_vf (vf);if (IS_ERR (repr))return PTR_ERR (repr);
Signature · 1 line
2.47.1
Tony Nguyen
maintainerPATCH 3/13 ice: pass the return value of skb_checksum_help()
In reply to Tony NguyenFrom: Michal Swiatkowski <[email protected]>
skb_checksum_help() can fail. Pass its return value back to the caller.
Commonize this software path in goto.
Instead of just returning error try calculating software checksum first. There is a check for TSO in checksum_sw_fb.
--- drivers/net/ethernet/intel/ice/ice_txrx.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-)
drivers/net/ethernet/intel/ice/ice_txrx.c +9 -11
@@ -1654,7 +1654,7 @@ int ice_tx_csum(struct ice_tx_buf *first, struct ice_tx_offload_params *off) ret =ipv6_skip_exthdr (skb, exthdr - skb->data, &l4_proto, &frag_off);if (ret <0 ) -return -1 ; + goto checksum_sw_fb; }/* define outer transport */
@@ -1673,11 +1673,7 @@ int ice_tx_csum(struct ice_tx_buf *first, struct ice_tx_offload_params *off) l4.hdr =skb_inner_network_header (skb);break ;default : -if (first->tx_flags &ICE_TX_FLAGS_TSO ) -return -1 ; - -skb_checksum_help (skb); -return 0 ; + goto checksum_sw_fb; }/* compute outer L3 header size */
@@ -1736,7 +1732,7 @@ int ice_tx_csum(struct ice_tx_buf *first, struct ice_tx_offload_params *off)ipv6_skip_exthdr (skb, exthdr - skb->data, &l4_proto, &frag_off); }else { -return -1 ; + goto checksum_sw_fb; }/* compute inner L3 header size */
@@ -1789,15 +1785,17 @@ int ice_tx_csum(struct ice_tx_buf *first, struct ice_tx_offload_params *off)break ;default : -if (first->tx_flags &ICE_TX_FLAGS_TSO ) -return -1 ; -skb_checksum_help (skb); -return 0 ; + goto checksum_sw_fb; } off->td_cmd |= cmd; off->td_offset |= offset;return 1 ; + +checksum_sw_fb: +if (first->tx_flags &ICE_TX_FLAGS_TSO ) +return -1 ; +return skb_checksum_help (skb); }/**
Signature · 1 line
2.47.1
Tony Nguyen
maintainerPATCH 4/13 ice: always do GCS if hardware supports it
In reply to Tony NguyenFrom: Michal Swiatkowski <[email protected]>
There is no need to check for NETIF_HW_CSUM. If the code reach calculating checksum it means that correct checksum flags are set, because kernel is checking that when setting ip->summed.
Instead of netdev feature flag use Tx ring flag to check if the hardware can use special descriptor for checksum calculating.
--- drivers/net/ethernet/intel/ice/ice_lib.c | 4 ++++ drivers/net/ethernet/intel/ice/ice_txrx.c | 2 +- drivers/net/ethernet/intel/ice/ice_txrx.h | 1 + 3 files changed, 6 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_lib.c +4 -0
@@ -1415,6 +1415,10 @@ static int ice_vsi_alloc_rings(struct ice_vsi *vsi)set_bit (ICE_TX_RING_FLAGS_VLAN_L2TAG2 , ring->flags); else set_bit(ICE_TX_RING_FLAGS_VLAN_L2TAG1, ring->flags); + +if (ice_is_feature_supported (pf,ICE_F_GCS )) +set_bit (ICE_TX_RING_FLAGS_GCS , ring->flags); +WRITE_ONCE (vsi->tx_rings[i], ring); }
drivers/net/ethernet/intel/ice/ice_txrx.c +1 -1
@@ -1739,7 +1739,7 @@ int ice_tx_csum(struct ice_tx_buf *first, struct ice_tx_offload_params *off) l3_len = l4.hdr - ip.hdr; offset |= (l3_len /4 ) <<ICE_TX_DESC_LEN_IPLEN_S ; -if ((tx_ring->netdev->features &NETIF_F_HW_CSUM ) && +if (test_bit (ICE_TX_RING_FLAGS_GCS , tx_ring->flags) && !(first->tx_flags &ICE_TX_FLAGS_TSO ) && !skb_csum_is_sctp (skb)) {/* Set GCS */
drivers/net/ethernet/intel/ice/ice_txrx.h +1 -0
@@ -217,6 +217,7 @@ enum ice_tx_ring_flags {ICE_TX_RING_FLAGS_VLAN_L2TAG1 ,ICE_TX_RING_FLAGS_VLAN_L2TAG2 ,ICE_TX_RING_FLAGS_TXTIME , +ICE_TX_RING_FLAGS_GCS , ICE_TX_RING_FLAGS_NBITS, };
Signature · 1 line
2.47.1
Tony Nguyen
maintainerPATCH 5/13 ice: use NETIF_F_HW_CSUM instead of IP/IPV6
In reply to Tony NguyenFrom: Michal Swiatkowski <[email protected]>
The hardware is capable of calculating checksum for IPV6 packets with extension header. To not drop such packets switch from IP/IPV6 checksum to HW_CSUM.
HW_CSUM is also used in previous generation (i40e).
Previously HW_CSUM was used to indicate that hardware supports general checksum. Drop it assuming that if the hardware supports it, it is used.
Disabling offload for E830 in case of TSO isn't needed anymore as the check for TSO is done in Tx path just before preparation of the special GCS descriptor.
The commit from Fixes didn't introduce a bug, it just shown that the driver is doing sth wrong with the checksum features.
--- drivers/net/ethernet/intel/ice/ice_main.c | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-)
drivers/net/ethernet/intel/ice/ice_main.c +1 -20
@@ -3491,9 +3491,8 @@ void ice_set_netdev_features(struct net_device *netdev)NETIF_F_RXHASH ; csumo_features =NETIF_F_RXCSUM | -NETIF_F_IP_CSUM |NETIF_F_SCTP_CRC | -NETIF_F_IPV6_CSUM ; +NETIF_F_HW_CSUM ; vlano_features =NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_HW_VLAN_CTAG_TX |
@@ -3555,12 +3554,6 @@ void ice_set_netdev_features(struct net_device *netdev)/* Allow core to manage IRQs affinity */ netif_set_affinity_auto (netdev); -/* Mutual exclusivity for TSO and GCS is enforced by the set features -* ndo callback. -*/ -if (ice_is_feature_supported (pf,ICE_F_GCS )) - netdev->hw_features |=NETIF_F_HW_CSUM ; -netif_set_tso_max_size (netdev,ICE_MAX_TSO_SIZE ); }
@@ -6500,18 +6493,6 @@ ice_set_features(struct net_device *netdev, netdev_features_t features)if (changed &NETIF_F_LOOPBACK ) ret =ice_set_loopback (vsi, !!(features &NETIF_F_LOOPBACK )); -/* Due to E830 hardware limitations, TSO (NETIF_F_ALL_TSO) with GCS -* (NETIF_F_HW_CSUM) is not supported. -*/ -if (ice_is_feature_supported (pf,ICE_F_GCS ) && - ((features &NETIF_F_HW_CSUM ) && (features &NETIF_F_ALL_TSO ))) { -if (netdev->features &NETIF_F_HW_CSUM ) -dev_err (ice_pf_to_dev (pf),"To enable TSO, you must first disable HW checksum.\n" ); -else -dev_err (ice_pf_to_dev (pf),"To enable HW checksum, you must first disable TSO.\n" ); -return -EIO ; - } -return ret; }
Signature · 1 line
2.47.1
Jakub Kicinski
maintainerRe: [PATCH net 05/13] ice: use NETIF_F_HW_CSUM instead of IP/IPV6
Quoted 9 lines · On Fri, 17 Jul 2026 11:53:27 -0700 Tony Nguyen wrote:
The hardware is capable of calculating checksum for IPV6 packets with extension header. To not drop such packets switch from IP/IPV6 checksum to
HW_CSUM.
HW_CSUMis also used in previous generation (i40e).Previously
HW_CSUMwas used to indicate that hardware supports general checksum. Drop it assuming that if the hardware supports it, it is used.
Quoted 6 lines
Disabling offload for E830 in case of TSO isn't needed anymore as the check for TSO is done in Tx path just before preparation of the special GCS descriptor.
The commit from Fixes didn't introduce a bug, it just shown that the driver is doing sth wrong with the checksum features.
This really reads like net-next material :/
Tony Nguyen
maintainerRe: [PATCH net 05/13] ice: use NETIF_F_HW_CSUM instead of IP/IPV6
Quoted 10 lines · Jakub Kicinski
Quoted 9 lines · On Fri, 17 Jul 2026 11:53:27 -0700 Tony Nguyen wrote:
The hardware is capable of calculating checksum for IPV6 packets with extension header. To not drop such packets switch from IP/IPV6 checksum to
HW_CSUM.
HW_CSUMis also used in previous generation (i40e).Previously
HW_CSUMwas used to indicate that hardware supports general checksum. Drop it assuming that if the hardware supports it, it is used.
Quoted 8 lines
Quoted 6 lines
Disabling offload for E830 in case of TSO isn't needed anymore as the check for TSO is done in Tx path just before preparation of the special GCS descriptor.
The commit from Fixes didn't introduce a bug, it just shown that the driver is doing sth wrong with the checksum features.
This really reads like net-next material :/
In certain cases this can cause packets drops which is why we routed to net; we can submit it to net-next though.
Thanks,
Toy
Tony Nguyen
maintainerPATCH 6/13 ice: fix LAG recipe to profile association
In reply to Tony NguyenFrom: Marcin Szycik <[email protected]>
ice_init_lag() associates recipes to profiles, assuming that Link Aggregation-related profiles will always have profile ID lower than 70 (ICE_PROFID_IPV6_GTPU_IPV6_TCP_INNER). This value seems arbitrary and might not always be valid for some versions of DDP package, i.e. LAG profiles may have profile ID greater than 70. This would lead to misconfigured switch and LAG not working properly.
Fix it by checking up to maximum profile ID.
--- drivers/net/ethernet/intel/ice/ice_lag.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_lag.c +1 -1
@@ -2623,7 +2623,7 @@ int ice_init_lag(struct ice_pf *pf) goto free_lport_res;/* associate recipes to profiles */ -for (n =0 ; n <ICE_PROFID_IPV6_GTPU_IPV6_TCP_INNER ; n++) { +for (n =0 ; n <ICE_MAX_NUM_PROFILES ; n++) { err =ice_aq_get_recipe_to_profile (&pf->hw, n, &recipe_bits,NULL );if (err)
Signature · 1 line
2.47.1
Tony Nguyen
maintainerPATCH 7/13 ice: support SBQ posted writes with non-posted support for CGU
In reply to Tony NguyenFrom: Karol Kolacinski <[email protected]>
Sideband queue (SBQ) is a HW queue with very short completion time. All SBQ writes were posted by default, which means that the driver did not have to wait for completion from the neighbor device, because there was none. This introduced unnecessary delays, where only those delays were "ensuring" that the command is "completed" and this was a potential race condition.
Add the possibility to perform non-posted writes where it's necessary to wait for completion, instead of relying on fake completion from the FW, where only the delays are guarding the writes.
Flush the SBQ by reading address 0 from the PHY 0 before issuing SYNC command to ensure that writes to all PHYs were completed and skip SBQ message completion if it's posted.
E810 only supports opcode 0x01, but its FW always sends completion responses for this opcode, so the driver waits for each write to complete. This makes E810 writes synchronous and eliminates the need for SBQ flush.
To analyze if delays are gone, look for and compare time spent in ice_sq_send_cmd - posted writes should return immediately after the wr32. That can be done for example by adjusting phc time with phc_ctl on E830 device, for less than 2 seconds to use this new mechanism. Without it, command below will fail.
Reproduction steps:phc_ctl eth13 adj 1
phc_ctl[4478170.994]: adjusted clock by 1.000000 seconds
Check trace for timing for comparisons:
echo ice_sbq_send_cmd > /sys/kernel/debug/tracing/set_ftrace_filter echo function_graph > /sys/kernel/debug/tracing/current_tracer cat /sys/kernel/debug/tracing/trace
--- drivers/net/ethernet/intel/ice/ice_common.c | 25 ++++++++-- drivers/net/ethernet/intel/ice/ice_controlq.c | 4 ++ drivers/net/ethernet/intel/ice/ice_controlq.h | 1 + drivers/net/ethernet/intel/ice/ice_ptp_hw.c | 47 +++++++++++++------ drivers/net/ethernet/intel/ice/ice_sbq_cmd.h | 2 +- 5 files changed, 58 insertions(+), 21 deletions(-)
drivers/net/ethernet/intel/ice/ice_common.c +20 -5
@@ -1762,6 +1762,7 @@ int ice_sbq_rw_reg(struct ice_hw *hw, struct ice_sbq_msg_input *in, u16 flags) {struct ice_sbq_cmd_desc desc = {0 };struct ice_sbq_msg_req msg = {0 }; +struct ice_sq_cd cd = {};u16 msg_len;int status;
@@ -1774,19 +1775,33 @@ int ice_sbq_rw_reg(struct ice_hw *hw, struct ice_sbq_msg_input *in, u16 flags) msg.msg_addr_low =cpu_to_le16 (in->msg_addr_low); msg.msg_addr_high =cpu_to_le32 (in->msg_addr_high); -if (in->opcode) +switch (in->opcode) { +case ice_sbq_msg_wr_p: +case ice_sbq_msg_wr_np: msg.data =cpu_to_le32 (in->data); -else +/* E810 FW only supports opcode 0x01, convert non-posted to posted */ +if (hw->mac_type ==ICE_MAC_E810 ) + msg.opcode = ice_sbq_msg_wr_p; +break ; +case ice_sbq_msg_rd:/* data read comes back in completion, so shorten the struct by * sizeof(msg.data) */ msg_len -=sizeof (msg.data); +break ; +default : +return -EINVAL ; + } + +/* E810 doesn't support posted mode, always wait for completion */ + cd.posted = in->opcode == ice_sbq_msg_wr_p && + hw->mac_type !=ICE_MAC_E810 ; desc.flags =cpu_to_le16 (flags); desc.opcode =cpu_to_le16 (ice_sbq_opc_neigh_dev_req); desc.param0.cmd_len =cpu_to_le16 (msg_len); - status =ice_sbq_send_cmd (hw, &desc, &msg, msg_len,NULL ); -if (!status && !in->opcode) + status =ice_sbq_send_cmd (hw, &desc, &msg, msg_len, &cd); +if (!status && in->opcode == ice_sbq_msg_rd) in->data =le32_to_cpu (((struct ice_sbq_msg_cmpl *)&msg)->data);return status;
@@ -6547,7 +6562,7 @@ int ice_write_cgu_reg(struct ice_hw *hw, u32 addr, u32 val) {struct ice_sbq_msg_input cgu_msg = { .dest_dev =ice_get_dest_cgu (hw), - .opcode = ice_sbq_msg_wr, + .opcode = ice_sbq_msg_wr_np, .msg_addr_low = addr, .data = val };
drivers/net/ethernet/intel/ice/ice_controlq.c +4 -0
@@ -1086,6 +1086,10 @@ ice_sq_send_cmd(struct ice_hw *hw, struct ice_ctl_q_info *cq,wr32 (hw, cq->sq.tail, cq->sq.next_to_use);ice_flush (hw); +/* If the message is posted, don't wait for completion. */ +if (cd && cd->posted) + goto sq_send_command_error; +/* Wait for the command to complete. If it finishes within the * timeout, copy the descriptor back to temp. */
drivers/net/ethernet/intel/ice/ice_controlq.h +1 -0
@@ -77,6 +77,7 @@ struct ice_ctl_q_ring {/* sq transaction details */ struct ice_sq_cd {struct libie_aq_desc *wb_desc; +u8 posted :1 ; };/* rq event information */
drivers/net/ethernet/intel/ice/ice_ptp_hw.c +32 -15
95 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_sbq_cmd.h +1 -1
@@ -55,7 +55,7 @@ enum ice_sbq_dev_id {enum ice_sbq_msg_opcode { ice_sbq_msg_rd =0x00 , - ice_sbq_msg_wr =0x01 , + ice_sbq_msg_wr_p =0x01 , ice_sbq_msg_wr_np =0x02 };
Signature · 1 line
2.47.1
Jakub Kicinski
maintainerRe: [PATCH net 07/13] ice: support SBQ posted writes with non-posted support for CGU
This is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible.
---
ice: support SBQ posted writes with non-posted support for CGU
This change introduces posted SBQ writes to remove the delay-based "completion" the driver was relying on, adds a pre-SYNC SBQ flush in ice_ptp_exec_tmr_cmd() to order posted PHY writes before GLTSYN_CMD_SYNC, and keeps CGU accesses non-posted. E810 always waits for completion since its firmware answers every write.
Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_common.c +0
-0
[ ... ]
drivers/net/ethernet/intel/ice/ice_controlq.c ice_sq_send_cmd(struct ice_hw *hw, struct ice_ctl_q_info *cq, · line 1092
Quoted 12 lines
drivers/net/ethernet/intel/ice/ice_controlq.c +4
-0@@ -1086,6 +1086,10 @@ ice_sq_send_cmd(struct ice_hw *hw, struct ice_ctl_q_info *cq,wr32 (hw, cq->sq.tail, cq->sq.next_to_use);ice_flush (hw); +/* If the message is posted, don't wait for completion. */ +if (cd && cd->posted) + goto sq_send_command_error; +
[Low]
For the posted success path, could the goto target be renamed (or a dedicated label added) so the normal success exit no longer jumps to a label named for the error cleanup path?
The success path here relies on status still being 0 at the point of the goto. Any future change that sets status earlier in ice_sq_send_cmd() (for tracing, logging, or a refactor of the send path) would silently turn successful posted writes into errors.
The posted path also skips the ice_debug() writeback traces, the cd->wb_desc copy, and the timeout classification block, but neither the goto site nor the new struct ice_sq_cd posted bit mentions this. Would a short comment on struct ice_sq_cd's posted field, describing what the posted path skips, help?
Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_controlq.c +0
-0/* Wait for the command to complete. If it finishes within the * timeout, copy the descriptor back to temp. */
[ ... ]
Quoted 12 lines
drivers/net/ethernet/intel/ice/ice_ptp_hw.c +4
-0@@ -352,6 +352,20 @@ void ice_ptp_src_cmd(struct ice_hw *hw, enum ice_ptp_tmr_cmd cmd)static void ice_ptp_exec_tmr_cmd (struct ice_hw *hw) { struct ice_pf *pf = container_of(hw, struct ice_pf, hw); +struct ice_sbq_msg_input msg = { + .dest_dev = ice_sbq_dev_phy_0, + .opcode = ice_sbq_msg_rd, + };
drivers/net/ethernet/intel/ice/ice_ptp_hw.c void ice_ptp_src_cmd(struct ice_hw *hw, enum ice_ptp_tmr_cmd cmd) · line 368
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_ptp_hw.c +10
-0+int err; + +/* Flush SBQ to ensure posted writes complete before SYNC command. +* Skip for E810 - FW always sends completions, so writes are synchronous. +*/ +if (hw->mac_type !=ICE_MAC_E810 ) { + err =ice_sbq_rw_reg (hw, &msg,LIBIE_AQ_FLAG_RD ); +if (err) +dev_warn (ice_hw_to_dev (hw),"Failed to flush SBQ: %d\n" , err); + }
[Medium]
When ice_sbq_rw_reg() fails here (for example -EBUSY when hw->reset_ongoing is set, or -ENOSPC / -EIO / -ETIMEDOUT from ice_sq_send_cmd()), the code logs a warning and then unconditionally proceeds to issue wr32(GLTSYN_CMD_SYNC, SYNC_EXEC_CMD).
The commit message states:
Flush the SBQ by reading address 0 from the PHY 0 before issuing SYNC command to ensure that writes to all PHYs were completed
If the flush is what "ensures that writes to all PHYs were completed", does silently continuing on flush failure reopen the race the patch is trying to close?
ice_ptp_exec_tmr_cmd() returns void, and none of its callers (ice_ptp_tmr_cmd, ice_start_phy_timer_e82x / eth56g, ice_sync_phy_timer_e82x / eth56g, ice_read_phy_and_phc_time_e82x / eth56g) can react to the failure. Should this path propagate the error, or at least skip the SYNC issue when the flush fails?
Also, is a non-rate-limited dev_warn appropriate in this hot PTP path? Repeated failures (for example during a reset storm) could flood the kernel log.
[Medium]
Does the phy_0-only flush actually order writes issued to other SBQ destinations?
ice_write_phy_eth56g() now issues posted writes and picks the destination via ice_ptp_get_dest_dev_e825():
static enum ice_sbq_dev_id ice_ptp_get_dest_dev_e825(struct ice_hw *hw,
u8 port)
{
...
if ((!ice_is_dual(hw) && tgt_phy == 1) ||
(ice_is_dual(hw) && tgt_phy != curr_phy))
return ice_sbq_dev_phy_0_peer;
else
return ice_sbq_dev_phy_0;
}So on single-complex E825-C with ports >= ports_per_phy, and on dual-complex E825-C for cross-complex writes, posted writes can go to ice_sbq_dev_phy_0_peer. The flush here reads from a hardcoded ice_sbq_dev_phy_0:
struct ice_sbq_msg_input msg = {
.dest_dev = ice_sbq_dev_phy_0,
.opcode = ice_sbq_msg_rd,
};If the SBQ does not enforce global commit ordering across distinct neighbor destinations, does a read completing on phy_0 guarantee that a previously-issued posted write to phy_0_peer has landed on the destination device before GLTSYN_CMD_SYNC executes?
The commit message says:
Flush the SBQ by reading address 0 from the PHY 0 before issuing SYNC command to ensure that writes to all PHYs were completed
Is that guarantee documented for cross-destination SBQ traffic, or should the flush also target ice_sbq_dev_phy_0_peer (and any other destination that received a posted write) on multi-PHY / dual-complex E825-C?
Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_ptp_hw.c +0
-0if (!ice_is_primary (hw)) hw =ice_get_primary_hw (pf);
[ ... ]
Re: [PATCH net 07/13] ice: support SBQ posted writes with non-posted support for CGU
sure, can do that
Quoted 51 lines
Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_controlq.c +0
-0/* Wait for the command to complete. If it finishes within the * timeout, copy the descriptor back to temp. */ [ ... ]
Quoted 12 lines
drivers/net/ethernet/intel/ice/ice_ptp_hw.c +4
-0@@ -352,6 +352,20 @@ void ice_ptp_src_cmd(struct ice_hw *hw, enum ice_ptp_tmr_cmd cmd)static void ice_ptp_exec_tmr_cmd (struct ice_hw *hw) { struct ice_pf *pf = container_of(hw, struct ice_pf, hw); +struct ice_sbq_msg_input msg = { + .dest_dev = ice_sbq_dev_phy_0, + .opcode = ice_sbq_msg_rd, + };drivers/net/ethernet/intel/ice/ice_ptp_hw.c void ice_ptp_src_cmd(struct ice_hw *hw, enum ice_ptp_tmr_cmd cmd) · line 368
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_ptp_hw.c +10
-0+int err; + +/* Flush SBQ to ensure posted writes complete before SYNC command. +* Skip for E810 - FW always sends completions, so writes are synchronous. +*/ +if (hw->mac_type !=ICE_MAC_E810 ) { + err =ice_sbq_rw_reg (hw, &msg,LIBIE_AQ_FLAG_RD ); +if (err) +dev_warn (ice_hw_to_dev (hw),"Failed to flush SBQ: %d\n" , err); + }[Medium]
Whenice_sbq_rw_reg()fails here (for example-EBUSYwhenhw->reset_ongoingis set, or-ENOSPC/-EIO/-ETIMEDOUTfromice_sq_send_cmd()), the code logs a warning and then unconditionally proceeds to issuewr32(GLTSYN_CMD_SYNC, SYNC_EXEC_CMD).The commit message states:
Flush the SBQ by reading address 0 from the PHY 0 before issuing SYNC command to ensure that writes to all PHYs were completed
If the flush is what "ensures that writes to all PHYs were completed", does silently continuing on flush failure reopen the race the patch is trying to close?
ice_ptp_exec_tmr_cmd()returns void, and none of its callers (ice_ptp_tmr_cmd,ice_start_phy_timer_e82x/ eth56g,ice_sync_phy_timer_e82x/ eth56g,ice_read_phy_and_phc_time_e82x/ eth56g) can react to the failure. Should this path propagate the error, or at least skip the SYNC issue when the flush fails?
Quoted 4 lines
Also, is a non-rate-limited
dev_warnappropriate in this hot PTP path? Repeated failures (for example during a reset storm) could flood the kernel log.
yeah, making sure it returns earlier on failure is a good idea.
Quoted 33 lines
[Medium]
Does the phy_0-only flush actually order writes issued to other SBQ destinations?
ice_write_phy_eth56g()now issues posted writes and picks the destination viaice_ptp_get_dest_dev_e825():static enum ice_sbq_dev_id ice_ptp_get_dest_dev_e825(struct ice_hw *hw, u8 port) { ... if ((!ice_is_dual(hw) && tgt_phy == 1) || (ice_is_dual(hw) && tgt_phy != curr_phy)) return ice_sbq_dev_phy_0_peer; else return ice_sbq_dev_phy_0; }So on single-complex E825-C with ports >=
ports_per_phy, and on dual-complex E825-C for cross-complex writes, posted writes can go toice_sbq_dev_phy_0_peer. The flush here reads from a hardcodedice_sbq_dev_phy_0:struct ice_sbq_msg_input msg = { .dest_dev = ice_sbq_dev_phy_0, .opcode = ice_sbq_msg_rd, };If the SBQ does not enforce global commit ordering across distinct neighbor destinations, does a read completing on
phy_0guarantee that a previously-issued posted write tophy_0_peerhas landed on the destination device beforeGLTSYN_CMD_SYNCexecutes?
Quoted 9 lines
The commit message says:
Flush the SBQ by reading address 0 from the PHY 0 before issuing SYNC command to ensure that writes to all PHYs were completed
Is that guarantee documented for cross-destination SBQ traffic, or should the flush also target
ice_sbq_dev_phy_0_peer(and any other destination that received a posted write) on multi-PHY / dual-complex E825-C?
I tested mainly on E830. If someone is using E-825 device it indeed might be different. I've heard some information that it causes failure on some setups, but I asked an waiting on some details regarding what sort of failure it is and what's the failing device. Will most likely need that information before sending new version.
Quoted 5 lines
Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_ptp_hw.c +0
-0if (!ice_is_primary (hw)) hw =ice_get_primary_hw (pf);[ ... ]
Tony Nguyen
maintainerPATCH 8/13 ice: use READ_ONCE() to access cached PHC time
In reply to Tony NguyenFrom: Sergey Temerkhanov <[email protected]>
ptp.cached_phc_time is a 64-bit value updated by a periodic work item on one CPU and read locklessly on another. On 32-bit or non-atomic architectures this can result in a torn read. Use READ_ONCE() to enforce a single atomic load.
--- drivers/net/ethernet/intel/ice/ice_ptp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_ptp.c +1 -1
@@ -346,7 +346,7 @@ static u64 ice_ptp_extend_40b_ts(struct ice_pf *pf, u64 in_tstamp)return 0 ; } -return ice_ptp_extend_32b_ts (pf->ptp.cached_phc_time, +return ice_ptp_extend_32b_ts (READ_ONCE (pf->ptp.cached_phc_time), (in_tstamp >>8 ) & mask); }
Signature · 1 line
2.47.1
Tony Nguyen
maintainerPATCH 9/13 ice: fix PTP Call Trace during PTP release
In reply to Tony NguyenFrom: Paul Greenwalt <[email protected]>
If a PF reset occurs when the PTP state is ICE_PTP_UNINIT, then ice_ptp_rebuild() will update the state to ICE_PTP_ERROR. This will result in the following PTP release call trace during driver unload:
kernel BUG at lib/list_debug.c:52!
ice_ptp_release+0x332/0x3c0 [ice]
ice_deinit_features.part.0+0x10e/0x120 [ice]
ice_remove+0x100/0x220 [ice]This was observed when passing PF1 through to a VM. ice_ptp_init() fails because ctrl_pf is NULL and sets the state to ICE_PTP_UNINIT.
Fix by detecting the ICE_PTP_UNINIT state in ice_ptp_rebuild() and returning without error, preventing the invalid state transition to ICE_PTP_ERROR. The only valid path to ICE_PTP_ERROR is from ICE_PTP_RESETTING after a failed rebuild.
--- drivers/net/ethernet/intel/ice/ice_ptp.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/ethernet/intel/ice/ice_ptp.c +5 -0
@@ -3037,6 +3037,11 @@ void ice_ptp_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type)struct ice_ptp *ptp = &pf->ptp;int err; +if (ptp->state ==ICE_PTP_UNINIT ) { +dev_dbg (ice_pf_to_dev (pf),"PTP was not initialized, skipping rebuild\n" ); +return ; + } +if (ptp->state ==ICE_PTP_READY ) {ice_ptp_prepare_for_reset (pf, reset_type); }else if (ptp->state !=ICE_PTP_RESETTING ) {
Signature · 1 line
2.47.1
Tony Nguyen
maintainerPATCH 10/13 ice: prevent tstamp ring allocation for non-PF VSI types
In reply to Tony NguyenFrom: Paul Greenwalt <[email protected]>
The pf->txtime_txqs bitmap tracks which Tx queues have ETF (Earliest TxTime First) offload enabled. This bitmap is indexed by queue number and is set by ice_offload_txtime(), which only operates on PF VSI queues.
However, ice_is_txtime_ena() does not check the VSI type before consulting the bitmap. When ETF offload is enabled on PF Tx queue 0, bit 0 is set in pf->txtime_txqs. During a subsequent PCI reset rebuild, the CTRL VSI's Tx queue 0 is reconfigured and ice_is_txtime_ena() is called for that ring. Since it only checks pf->txtime_txqs by queue index without distinguishing VSI type, it finds bit 0 set and returns true, matching the PF VSI's ETF queue, not the CTRL VSI's. This causes ice_vsi_cfg_txq() to spuriously allocate a tstamp_ring for the CTRL VSI ring.
Since CTRL VSI rings have no associated netdev, ice_clean_tx_ring() takes an early return at the !netdev check before reaching ice_free_tx_tstamp_ring(), leaking the allocation. Each PCI reset leaks one 64-byte tstamp_ring.
Fix this by restricting ice_is_txtime_ena() to return true only for PF VSI rings, since txtime_txqs is only meaningful for PF VSI queues.
--- drivers/net/ethernet/intel/ice/ice.h | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/intel/ice/ice.h +3 -0
@@ -767,6 +767,9 @@ static inline bool ice_is_txtime_ena(const struct ice_tx_ring *ring)struct ice_vsi *vsi = ring->vsi;struct ice_pf *pf = vsi->back; +if (vsi->type !=ICE_VSI_PF ) +return false; +return test_bit (ring->q_index, pf->txtime_txqs); }
Signature · 1 line
2.47.1
Tony Nguyen
maintainerPATCH 11/13 ice: reject out-of-range ptype in ice_parser_profile_init
In reply to Tony NguyenFrom: Aleksandr Loktionov <[email protected]>
set_bit(rslt->ptype, prof->ptypes) operates on a DECLARE_BITMAP of ICE_FLOW_PTYPE_MAX (1024) bits. Nothing prevents a malicious VF from providing ptype >= 1024 through VIRTCHNL, resulting in a write past the end of the bitmap and a kernel page fault.
Reproduced with a custom kernel module injecting a crafted VIRTCHNL_OP_ADD_RSS_CFG on E810-C QSFP (8086:1592), FW 4.91 0x800214af 1.3909.0, ICE COMMS DDP 1.3.53.0, kernel 7.1.0-rc1.
crash_parser: ice_parser_profile_init @ ffffffffc0d61b60crash_parser: setting ptype=0xffff (max valid=1023)crash_parser: calling ice_parser_profile_init -- expect OOB crash!
BUG: kernel NULL pointer dereference, address: 0000000000000000 Oops: Oops: 0002 [#1] SMP NOPTI CPU: 56 UID: 0 PID: 165011 Comm: insmod Kdump: loaded Tainted: G S U OE 7.1.0-rc1 #1 Hardware name: Intel Corporation S2600BPB/S2600BPB RIP: 0010:ice_parser_profile_init+0x2d/0x1d0 [ice] Call Trace: <TASK> ? __pfx_ice_parser_profile_init+0x10/0x10 [ice] crash_init+0x127/0xff0 [crash_parser] do_one_initcall+0x45/0x310 do_init_module+0x64/0x270 init_module_from_file+0xcc/0xf0 idempotent_init_module+0x17b/0x280 __x64_sys_finit_module+0x6e/0xe0
Bail out early with -EINVAL when ptype is out of range.
--- drivers/net/ethernet/intel/ice/ice_parser.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/intel/ice/ice_parser.c +3 -0
@@ -2368,6 +2368,9 @@ int ice_parser_profile_init(struct ice_parser_result *rslt,u16 proto_off =0 ;u16 off; +if (rslt->ptype >=ICE_FLOW_PTYPE_MAX ) +return -EINVAL ; +memset (prof,0 ,sizeof (*prof));set_bit (rslt->ptype, prof->ptypes);if (blk ==ICE_BLK_SW ) {
Signature · 1 line
2.47.1
Tony Nguyen
maintainerPATCH 12/13 idpf: fix max_vport related crash on allocation error during init
In reply to Tony NguyenFrom: Emil Tantilov <[email protected]>
Set adapter->max_vports only after successful allocation of vports, netdevs and vport_config buffers. This fixes possible crashes on reset or rmmod, following failed allocation on init
[ 305.981402] idpf 0000:83:00.0: enabling device (0100 -> 0102) [ 305.994464] idpf 0000:83:00.0: Device HW Reset initiated [ 320.416872] BUG: kernel NULL pointer dereference, address: 0000000000000000 [ 320.416918] #PF: supervisor read access in kernel mode [ 320.416942] #PF: error_code(0x0000) - not-present page [ 320.416963] PGD 2099657067 P4D 0 [ 320.416983] Oops: Oops: 0000 [#1] SMP NOPTI ... [ 320.417093] RIP: 0010:idpf_remove+0x118/0x200 [idpf] [ 320.417130] Code: 8b bb 98 09 00 00 e8 17 0f 5b e5 48 8b bb e8 08 00 00 e8 0b 0f 5b e5 66 83 bb 28 06 00 00 00 48 8b bb 20 06 00 00 74 49 31 ed <48> 8b 04 ef 48 85 c0 74 2f 48 8b 78 20 e8 66 58 91 e5 48 8b 83 20 [ 320.417183] RSP: 0018:ff7322212903fdb8 EFLAGS: 00010246 [ 320.417205] RAX: 0000000000000000 RBX: ff4463de40300000 RCX: ff7322212903fd4c [ 320.417228] RDX: 0000000000000001 RSI: ffffffffa7f7d100 RDI: 0000000000000000 [ 320.417250] RBP: 0000000000000000 R08: 0000000000000001 R09: 0000000000000000 [ 320.417272] R10: 0000000000000001 R11: ff4463de3a638f58 R12: ff4463be89ac7000 [ 320.417294] R13: ff4463be89ac7198 R14: ff4463be94fc7198 R15: ffffffffc0f10f20 [ 320.417317] FS: 00007f963c0e6740(0000) GS:ff4463fdd65d8000(0000) knlGS:0000000000000000 [ 320.417342] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 320.417362] CR2: 0000000000000000 CR3: 00000020ba674002 CR4: 0000000000773ef0 [ 320.417385] PKRU: 55555554 [ 320.417398] Call Trace: [ 320.417412] <TASK> [ 320.417429] pci_device_remove+0x42/0xb0 [ 320.417459] device_release_driver_internal+0x1a9/0x210 [ 320.417492] driver_detach+0x4b/0x90 [ 320.417516] bus_remove_driver+0x70/0x100 [ 320.417539] pci_unregister_driver+0x2e/0xb0 [ 320.417564] __do_sys_delete_module.constprop.0+0x190/0x2f0 [ 320.417592] ? kmem_cache_free+0x31e/0x550 [ 320.417619] ? lockdep_hardirqs_on_prepare+0xde/0x190 [ 320.417644] ? do_syscall_64+0x38/0x6b0 [ 320.417665] do_syscall_64+0xc8/0x6b0 [ 320.417683] ? clear_bhb_loop+0x30/0x80 [ 320.417706] entry_SYSCALL_64_after_hwframe+0x76/0x7e [ 320.417727] RIP: 0033:0x7f963bb30beb
--- drivers/net/ethernet/intel/idpf/idpf_virtchnl.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +6 -1
@@ -3555,7 +3555,6 @@ int idpf_vc_core_init(struct idpf_adapter *adapter)pci_sriov_set_totalvfs (adapter->pdev,idpf_get_max_vfs (adapter)); num_max_vports =idpf_get_max_vports (adapter); - adapter->max_vports = num_max_vports; adapter->vports =kzalloc_objs (*adapter->vports, num_max_vports);if (!adapter->vports)return -ENOMEM ;
@@ -3576,6 +3575,12 @@ int idpf_vc_core_init(struct idpf_adapter *adapter) goto err_netdev_alloc; } +/* Set max_vports only after vports, netdevs and vport_config buffers +* are allocated to make sure max_vport bound loops don't end up +* crashing, following allocation errors on init. +*/ + adapter->max_vports = num_max_vports; +/* Start the mailbox task before requesting vectors. This will ensure * vector information response from mailbox is handled */
Signature · 1 line
2.47.1
Tony Nguyen
maintainerPATCH 13/13 iavf: validate num_vsis in VIRTCHNL_OP_GET_VF_RESOURCES response
In reply to Tony NguyenFrom: Junrui Luo <[email protected]>
The VF allocates a fixed-size buffer for IAVF_MAX_VF_VSI (3) VSI entries when processing a VIRTCHNL_OP_GET_VF_RESOURCES response from the PF. However, num_vsis from the PF response is used unchecked as the loop bound when iterating over vsi_res[] in multiple functions.
A PF sending num_vsis greater than IAVF_MAX_VF_VSI, or the received message is shorter than num_vsis claims leads to out-of-bounds accesses on the vsi_res[] array.
Clamp num_vsis based on the actual bytes copied from the PF response.
--- .../net/ethernet/intel/iavf/iavf_virtchnl.c | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-)
drivers/net/ethernet/intel/iavf/iavf_virtchnl.c +21 -5
@@ -248,12 +248,28 @@ int iavf_send_vf_ptp_caps_msg(struct iavf_adapter *adapter)/** * iavf_validate_num_queues * @adapter: adapter structure +* @msglen: length of the received VF resource message * -* Validate that the number of queues the PF has sent in -* VIRTCHNL_OP_GET_VF_RESOURCES is not larger than the VF can handle. +* Validate the VIRTCHNL_OP_GET_VF_RESOURCES response from the PF. Ensure +* num_vsis does not exceed what the message length can cover, and cap +* num_queue_pairs to the VF maximum. **/ -static void iavf_validate_num_queues (struct iavf_adapter *adapter) +static void iavf_validate_num_queues (struct iavf_adapter *adapter,u16 msglen) { +u16 max_vsis; + +if (msglen <sizeof (struct virtchnl_vf_resource )) + max_vsis =0 ; +else + max_vsis = (msglen -sizeof (struct virtchnl_vf_resource )) / +sizeof (struct virtchnl_vsi_resource ); + +if (adapter->vf_res->num_vsis > max_vsis) { +dev_info (&adapter->pdev->dev,"Received %d VSIs, but message can only cover %d\n" , + adapter->vf_res->num_vsis, max_vsis); + adapter->vf_res->num_vsis = max_vsis; + } +if (adapter->vf_res->num_queue_pairs >IAVF_MAX_REQ_QUEUES ) {struct virtchnl_vsi_resource *vsi_res;int i;
@@ -300,7 +316,7 @@ int iavf_get_vf_config(struct iavf_adapter *adapter)* we aren't getting too many queues */ if (!err) -iavf_validate_num_queues (adapter); +iavf_validate_num_queues (adapter,min (event.msg_len, len));iavf_vf_parse_hw_config (hw, adapter->vf_res);kfree (event.msg_buf);
@@ -2578,7 +2594,7 @@ void iavf_virtchnl_completion(struct iavf_adapter *adapter,u16 len =IAVF_VIRTCHNL_VF_RESOURCE_SIZE ;memcpy (adapter->vf_res, msg,min (msglen, len)); -iavf_validate_num_queues (adapter); +iavf_validate_num_queues (adapter,min (msglen, len));iavf_vf_parse_hw_config (&adapter->hw, adapter->vf_res);if (is_zero_ether_addr (adapter->hw.mac.addr)) {/* restore current mac address */
Signature · 1 line
2.47.1
Jakub Kicinski
maintainerRe: [PATCH net 13/13] iavf: validate num_vsis in VIRTCHNL_OP_GET_VF_RESOURCES response
This is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible.
---
iavf: validate num_vsis in VIRTCHNL_OP_GET_VF_RESOURCES response
This patch clamps the num_vsis field from the PF's VIRTCHNL_OP_GET_VF_RESOURCES response so that the loop bound used when iterating over the fixed-size vsi_res[] buffer cannot exceed what the received message length can cover.
Quoted 4 lines
drivers/net/ethernet/intel/iavf/iavf_virtchnl.c +0
-0
[ ... ]
drivers/net/ethernet/intel/iavf/iavf_virtchnl.c int iavf_get_vf_config(struct iavf_adapter *adapter) · line 322
Quoted 9 lines
drivers/net/ethernet/intel/iavf/iavf_virtchnl.c +1
-1@@ -300,7 +316,7 @@ int iavf_get_vf_config(struct iavf_adapter *adapter)* we aren't getting too many queues */ if (!err) -iavf_validate_num_queues (adapter); +iavf_validate_num_queues (adapter,min (event.msg_len, len));iavf_vf_parse_hw_config (hw, adapter->vf_res);kfree (event.msg_buf);
[High]
Does the error path in iavf_get_vf_config() still allow the out-of-bounds access on vsi_res[] that the commit message describes?
Looking at the surrounding code:
err = iavf_poll_virtchnl_msg(hw, &event, VIRTCHNL_OP_GET_VF_RESOURCES);
memcpy(adapter->vf_res, event.msg_buf, min(event.msg_len, len));
/* some PFs send more queues than we should have so validate that
* we aren't getting too many queues
*/
if (!err)
iavf_validate_num_queues(adapter, min(event.msg_len, len));
iavf_vf_parse_hw_config(hw, adapter->vf_res);The memcpy of the PF-supplied payload into adapter->vf_res runs unconditionally, but the new num_vsis clamp is only invoked when err is zero.
iavf_poll_virtchnl_msg() returns virtchnl_status_to_errno(v_retval), so a PF response carrying a non-success v_retval together with an attacker-controlled msg_buf would still populate adapter->vf_res with the raw num_vsis value and then skip the clamp.
iavf_vf_parse_hw_config() runs unconditionally after that and iterates based on the unclamped u16 num_vsis:
for (i = 0; i < msg->num_vsis; i++) {
if (vsi_res->vsi_type == VIRTCHNL_VSI_SRIOV) {
ether_addr_copy(hw->mac.perm_addr,
vsi_res->default_mac_addr);
ether_addr_copy(hw->mac.addr,
vsi_res->default_mac_addr);
}
vsi_res++;
}vsi_res[] is a fixed-size array of IAVF_MAX_VF_VSI (3) entries in the adapter->vf_res allocation, so num_vsis up to 65535 would walk far past that buffer, and any OOB slot whose vsi_type happens to equal VIRTCHNL_VSI_SRIOV would additionally copy six bytes of adjacent heap memory into hw->mac.perm_addr and hw->mac.addr.
Would it make sense to either apply the num_vsis clamp unconditionally, or gate the memcpy and iavf_vf_parse_hw_config() behind the same if (!err) as the validation, so that the error path cannot reintroduce the out-of-bounds access this patch is meant to close?
This series was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Fri, 17 Jul 2026 11:53:22 -0700 you wrote:
For ice:
Vincent Chen fixes issue preventing VF creation when switchdev is not enabled in the configuration.Michal fixes issue with checksum advertisement and handling with extension headers.
[...]
Here is the summary with links:
- [net,01/13] ice: allow creating VFs when !CONFIG_ICE_SWITCHDEV
https://git.kernel.org/netdev/net/c/99d0f42b0e5c - [net,02/13] ice: remove redundant switchdev check in ice_eswitch_attach_vf() (no matching commit) - [net,03/13] ice: pass the return value of skb_checksum_help() https://git.kernel.org/netdev/net/c/2d19302f6288 - [net,04/13] ice: always do GCS if hardware supports it (no matching commit) - [net,05/13] ice: use NETIF_F_HW_CSUM instead of IP/IPV6 (no matching commit) - [net,06/13] ice: fix LAG recipe to profile association https://git.kernel.org/netdev/net/c/d6da9b7d4859 - [net,07/13] ice: support SBQ posted writes with non-posted support for CGU (no matching commit) - [net,08/13] ice: use READ_ONCE() to access cached PHC time https://git.kernel.org/netdev/net/c/2915681b89f8 - [net,09/13] ice: fix PTP Call Trace during PTP release https://git.kernel.org/netdev/net/c/f6a7e00b81e3 - [net,10/13] ice: prevent tstamp ring allocation for non-PF VSI types https://git.kernel.org/netdev/net/c/144539bbfd3c - [net,11/13] ice: reject out-of-range ptype in ice_parser_profile_init https://git.kernel.org/netdev/net/c/59abb87159c5 - [net,12/13] idpf: fix max_vport related crash on allocation error during init https://git.kernel.org/netdev/net/c/237f1f7653b8
- [net,13/13] iavf: validate num_vsis in VIRTCHNL_OP_GET_VF_RESOURCES response (no matching commit)
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html