Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] ice: unbounded prio_table in ice_cee_to_dcb_cfg() on ICE_CEE_PGID_STRICT - [Low] ice: Fixes trailer cites consumer commit instead of CEE DCB parser commits --
commit f657c73bb29d7266856c212fb6404876509d250c Author: Minseok Kim <[email protected]> > ice: bound the CEE DCBX priority-group id before using it as a traffic-class > index > > The CEE DCBX priority-group ID (PGID) is a four-bit wire field spanning > 0..15, whereas prio_table[] is sized to ICE_MAX_TRAFFIC_CLASS (8): > > #define ICE_CEE_PGID_PRIO_0_M (0xF << ICE_CEE_PGID_PRIO_0_S) > #define ICE_CEE_PGID_PRIO_1_M (0xF << ICE_CEE_PGID_PRIO_1_S) > > The IEEE ETS parser in ice_dcb.c masks the equivalent nibble field with > 0x7 (ICE_IEEE_ETS_PRIO_{0,1}_M) so it cannot exceed 7, whereas neither > CEE path bounds the value. > > In the wire LLDP TLV path, ice_parse_cee_pgcfg_tlv() extracts each > nibble into prio_table[i] and inspects it to select tsatable[i], but > never rewrites prio_table[i], leaving values 8..15 intact -- including > the defined sentinel ICE_CEE_PGID_STRICT (15). In the firmware AQ path, > ice_cee_to_dcb_cfg() remaps only ICE_CEE_PGID_STRICT to oper_num_tc - 1 > and lets values 8..14 fall through untouched. > > Downstream consumers then use prio_table[i] directly as a traffic-class > index: > > - ice_vc_get_qos_caps() (virt/virtchnl.c) indexes local array > u8 tc_prio[ICE_MAX_TRAFFIC_CLASS] via tc_prio[tc] |= BIT(i), writing > past the end of the stack array when tc >= 8. > - ice_dcb_tc_contig() (ice_dcb_lib.c) accumulates used_tc |= > BIT(prio_table[i]) into a u8; for values >= 8, BIT() is >= 0x100 and > truncates to zero, causing the contiguity check to pass silently. > - ice_vsi_cfg_netdev_tc() (ice_lib.c) indexes > vsi->tc_cfg.tc_info[ets_tc].netdev_tc with ets_tc = prio_table[i], > reading past the end of tc_info[]. > > The driver already enforces this invariant when writing prio_table[] in > ice_dcbnl_set_pg_tc_cfg_tx() and at the VF trust boundary in > ice_vc_cfg_q_bw(). Bounding the PGID at CEE ingest enforces the > invariant at a single boundary and prevents the u8 BIT() truncation in > ice_dcb_tc_contig() that per-array bounds checks would miss. > > Fixes: 015307754a19 ("ice: Support VF queue rate limit and quanta size > configuration") > Cc: [email protected] > Signed-off-by: Minseok Kim <[email protected]> [Severity: Low] 015307754a19 ("ice: Support VF queue rate limit and quanta size configuration") only added the ice_vc_get_qos_caps() consumer in v6.13. The unbounded CEE PGID parsing in ice_parse_cee_pgcfg_tlv() and ice_cee_to_dcb_cfg() goes back to 0ebd3ff13cca ("ice: Add code for DCB initialization part 2/4") and d24ef08a9d94 ("ice: Deduce TSA value from the priority value in the CEE mode"), and consumers such as ice_vsi_cfg_netdev_tc() and ice_dcb_tc_contig() predate 015307754a19 by several years. Should the Fixes: tag reference 0ebd3ff13cca ("ice: Add code for DCB initialization part 2/4") so older stable trees pick up the fix as well? > diff --git a/drivers/net/ethernet/intel/ice/ice_dcb.c > b/drivers/net/ethernet/intel/ice/ice_dcb.c > index abea84f146583..a36458b01fc21 100644 > --- a/drivers/net/ethernet/intel/ice/ice_dcb.c > +++ b/drivers/net/ethernet/intel/ice/ice_dcb.c [ ... ] > @@ -805,6 +814,10 @@ ice_cee_to_dcb_cfg(struct ice_aqc_get_cee_dcb_cfg_resp > *cee_cfg, > /* Map it to next empty TC */ > dcbcfg->etscfg.prio_table[i] = cee_cfg->oper_num_tc - 1; > dcbcfg->etscfg.tsatable[i] = ICE_IEEE_TSA_STRICT; > + } else if (dcbcfg->etscfg.prio_table[i] >= > + ICE_MAX_TRAFFIC_CLASS) { > + dcbcfg->etscfg.prio_table[i] = 0; > + dcbcfg->etscfg.tsatable[i] = ICE_IEEE_TSA_ETS; > } else { > dcbcfg->etscfg.tsatable[i] = ICE_IEEE_TSA_ETS; > } [Severity: Medium] Can dcbcfg->etscfg.prio_table[i] still exceed ICE_MAX_TRAFFIC_CLASS - 1 on the ICE_CEE_PGID_STRICT branch? When prio_table[i] is ICE_CEE_PGID_STRICT, it is set to cee_cfg->oper_num_tc - 1 and the new else-if bounds check is skipped. If cee_cfg->oper_num_tc is 0 (underflowing to 255) or greater than ICE_MAX_TRAFFIC_CLASS, prio_table[i] remains out of bounds for downstream consumers such as ice_vc_get_qos_caps() indexing tc_prio[ICE_MAX_TRAFFIC_CLASS] on the stack. Clamping prio_table[i] after the if/else block, as done in ice_parse_cee_pgcfg_tlv(), would cover both paths. -- Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
