mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Przemek Kitszel <przemyslaw.kitszel@intel.com>
To: Noah Weinberger <NoahWeinberger2003@proton.me>,
	"anthony.l.nguyen@intel.com" <anthony.l.nguyen@intel.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] ice: clamp package info count to the response buffer
Date: Mon, 9 Nov 2026 14:02:21 +0100	[thread overview]
Message-ID: <bb5d63fc-27a0-4f2e-9f2a-11835bb5b982@intel.com> (raw)
In-Reply-To: <sjs92jrAG9X58za0SnZA1OOA4Db3R79dv436O7U-AytolZQYhuWSppqWG-OobUCTshYLEhYP6LgQAlvVSGMJhdUj9DSi6of3Q6huctkjXQg=@proton.me>

On 11/9/26 12:55 AM, Noah Weinberger wrote:
> Hello,
> 
> ice_get_pkg_info() and the DDP-load compatibility check iterate
> over the count field of the admin-queue GET_PKG_INFO response, but
> the response buffer is a flexible array sized ICE_PKG_CNT (4):
> 
>      DEFINE_RAW_FLEX(struct ice_aqc_get_pkg_info_resp, pkg_info, pkg_info,
>                      ICE_PKG_CNT);
>      ...
>      for (i = 0; i < le32_to_cpu(pkg_info->count); i++) {
> 
> A device (or compromised firmware) that reports more than four
> entries makes both loops read past the stack buffer, and the
> 'active package' name/version handling then copies out-of-bounds
> stack data into hw->active_pkg_name. The patch clamps both loops to
> the buffer size.
> 
> Affected version/commit: mainline 8a65162514fbad21a2c58ffed65f42b27e92b163 (v7.4-rc2 window, 2026-11-08), drivers/net/ethernet/intel/ice/ice_ddp.c:1993-2015 (ice_get_pkg_info: DEFINE_RAW_FLEX(..., ICE_PKG_CNT = 4) then for (i = 0; i < le32_to_cpu(pkg_info->count); i++)), :2067-2077 (same pattern with pkg->count)
> Longstanding; converted to DEFINE_RAW_FLEX at some point without adding the clamp.
> 
> This was found during an assisted (AI-supported) static source review of
> mainline 8a65162514fbad21a2c58ffed65f42b27e92b163 (v7.4-rc2 window, 2026-11-08). The patch below has NOT been compiled and has
> NOT been runtime tested, and no reproducer was produced - the triggering
> conditions are described above instead. Please treat this as a report for
> verification rather than a battle-tested fix.
> 
> ---
> diff --git a/drivers/net/ethernet/intel/ice/ice_ddp.c b/drivers/net/ethernet/intel/ice/ice_ddp.c
> index 3b2d9c4369..bb037ee96b 100644
> --- a/drivers/net/ethernet/intel/ice/ice_ddp.c
> +++ b/drivers/net/ethernet/intel/ice/ice_ddp.c
> @@ -1998,7 +1998,7 @@ static enum ice_ddp_state ice_get_pkg_info(struct ice_hw *hw)
>   	if (ice_aq_get_pkg_info_list(hw, pkg_info, size, NULL))
>   		return ICE_DDP_PKG_ERR;
>   
> -	for (i = 0; i < le32_to_cpu(pkg_info->count); i++) {
> +	for (i = 0; i < le32_to_cpu(pkg_info->count) && i < ICE_PKG_CNT; i++) {

you basically report a "malicious FW" here
personally I would ignore

(same for the other of your patches)

>   #define ICE_PKG_FLAG_COUNT 4
>   		char flags[ICE_PKG_FLAG_COUNT + 1] = { 0 };
>   		u8 place = 0;
> @@ -2067,7 +2067,7 @@ static enum ice_ddp_state ice_chk_pkg_compat(struct ice_hw *hw,
>   	if (ice_aq_get_pkg_info_list(hw, pkg, size, NULL))
>   		return ICE_DDP_PKG_LOAD_ERROR;
>   
> -	for (i = 0; i < le32_to_cpu(pkg->count); i++) {
> +	for (i = 0; i < le32_to_cpu(pkg->count) && i < ICE_PKG_CNT; i++) {
>   		/* loop till we find the NVM package */
>   		if (!pkg->pkg_info[i].is_in_nvm)
>   			continue;
> 


      reply	other threads:[~2026-11-09 12:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-08 23:55 Noah Weinberger
2026-11-09 13:02 ` 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=bb5d63fc-27a0-4f2e-9f2a-11835bb5b982@intel.com \
    --to=przemyslaw.kitszel@intel.com \
    --cc=NoahWeinberger2003@proton.me \
    --cc=anthony.l.nguyen@intel.com \
    --cc=linux-kernel@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

all inboxes | Powered by JetHome®