Netdev List
 help / color / mirror / Atom feed
From: Przemek Kitszel <przemyslaw.kitszel@intel.com>
To: Minseok Kim <kor8821@gmail.com>, <intel-wired-lan@lists.osuosl.org>
Cc: <netdev@vger.kernel.org>, <aleksander.lobakin@intel.com>,
	<stable@vger.kernel.org>,
	"Czapnik, Lukasz" <lukasz.czapnik@intel.com>
Subject: Re: [PATCH iwl-net v2] ice: bound the CEE DCBX priority-group id before using it as a traffic-class index
Date: Wed, 25 Nov 2026 12:20:29 +0100	[thread overview]
Message-ID: <3178394c-6649-496d-9064-3fa8f5133760@intel.com> (raw)
In-Reply-To: <20261124112631.43172-1-kor8821@gmail.com>

On 11/24/26 12:26 PM, Minseok Kim wrote:
> 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: stable@vger.kernel.org
> Signed-off-by: Minseok Kim <kor8821@gmail.com>
> ---
> v2: resend in plain text only.  v1 (Message-ID
>      <CABBEkySNmAHTuoiC3jZqvAS31AdzMb2bHe3x0EAKQGibf0xi9g@mail.gmail.com>)
>      was sent with a web mail client that word-wrapped the diff and added an
>      HTML part, so it does not apply and netdev@ rejected it outright.  No
>      code or commit-message changes.
> 
>      Resent from kor8821@gmail.com; v1 came from for8821@g.skku.edu.
>      Same author, switching to an address that will not expire.
>      Signed-off-by updated to match the From line.

thank you for plain-texting
next time please send each revision/series as a new/stand-alone, instead
of in-reply-to the previous one (adding an URL to the prev one is much
welcomed though)

please also take a look at sashiko.dev report:
https://sashiko.dev/#/patchset/20261124112631.43172-1-kor8821%40gmail.com


> diff --git a/drivers/net/ethernet/intel/ice/ice_dcb.c b/drivers/net/ethernet/intel/ice/ice_dcb.c
> index abea84f14658..a36458b01fc2 100644
> --- a/drivers/net/ethernet/intel/ice/ice_dcb.c
> +++ b/drivers/net/ethernet/intel/ice/ice_dcb.c
> @@ -407,6 +407,15 @@ ice_parse_cee_pgcfg_tlv(struct ice_cee_feat_tlv *tlv,
>   			dcbcfg->etscfg.tsatable[i] = ICE_IEEE_TSA_STRICT;
>   		else
>   			dcbcfg->etscfg.tsatable[i] = ICE_IEEE_TSA_ETS;
> +
> +		/* The CEE PGID is a four-bit wire field, so a peer can name a
> +		 * priority group this driver has no traffic class for.  Several
> +		 * consumers use the value to index ICE_MAX_TRAFFIC_CLASS-sized
> +		 * objects, so clamp it here, after the strict-priority sentinel
> +		 * above has been consumed.
> +		 */
> +		if (etscfg->prio_table[i] >= ICE_MAX_TRAFFIC_CLASS)
> +			etscfg->prio_table[i] = 0;

instead of clamping bad requests we should reject

doing it at the TLV parsing level is good level of abstraction for the
logic, such fixes are much appreciated

>   	}
>   
>   	/* Number of TCs supported (1 octet) */
> @@ -805,6 +814,10 @@ ice_cee_to_dcb_cfg(struct ice_aqc_get_cee_dcb_cfg_resp *cee_cfg,

I believe here we should have no changes, please move it to tlv parsing
(would be fine to add limits in multiple places of the parsing).

>   			/* 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;
>   		}
> 


      reply	other threads:[~2026-11-25 11:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CABBEkySNmAHTuoiC3jZqvAS31AdzMb2bHe3x0EAKQGibf0xi9g@mail.gmail.com>
2026-11-24 11:26 ` [PATCH iwl-net v2] ice: bound the CEE DCBX priority-group id before using it as a traffic-class index Minseok Kim
2026-11-25 11:20   ` Przemek Kitszel [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3178394c-6649-496d-9064-3fa8f5133760@intel.com \
    --to=przemyslaw.kitszel@intel.com \
    --cc=aleksander.lobakin@intel.com \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=kor8821@gmail.com \
    --cc=lukasz.czapnik@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox