All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Alexander Usyskin" <alexander.usyskin@intel.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 1/2] mtd: mtd_intel_dg: add survivability partition
Date: Wed, 15 Jul 2026 14:19:51 +0000	[thread overview]
Message-ID: <20260715141951.963351F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260715-cri_surviv-v1-1-61763a6f1076@intel.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Unsigned integer underflow in bounds checks allows out-of-bounds hardware memory accesses when survivability mode is enabled.
--

--- Patch [1]: [PATCH 1/2] mtd: mtd_intel_dg: add survivability partition ---
commit 9f27e4e8d4c741d1106f13ea61bac2daf3838cad
Author: Alexander Usyskin <alexander.usyskin@intel.com>

mtd: mtd_intel_dg: add survivability partition

This commit adds an option to expose a fixed-sized survivability partition
starting from the beginning of storage. This can be used when the firmware
or hardware detects a failure involving a corrupted partition table,
allowing a full storage re-write.

> diff --git a/drivers/mtd/devices/mtd_intel_dg.c b/drivers/mtd/devices/mtd_intel_dg.c
> index f2fa8f68d1905..d11ddc687c4ac 100644
> --- a/drivers/mtd/devices/mtd_intel_dg.c
> +++ b/drivers/mtd/devices/mtd_intel_dg.c
[ ... ]
> @@ -205,6 +206,13 @@ static unsigned int idg_nvm_get_region(const struct intel_dg_nvm *nvm, loff_t fr
>  {
>  	unsigned int i;
>  
> +	/*
> +	 * When survivability region is enabled it positioned on index 0 and has region_id = 0
> +	 * Region 0 is special, via this region whole device memory can be accessed.
> +	 */
> +	if (nvm->survivability_enabled)
> +		return 0;
> +

[Severity: High]
Does this unconditional return of 0 create an underflow risk in the read,
write, and erase paths?

When survivability is enabled, idg_nvm_get_region() will always return
index 0. If nvm->size was inflated during initialization by parsing limits
from a corrupted partition table, a request could arrive with an offset
larger than nvm->regions[0].size.

In drivers/mtd/devices/mtd_intel_dg.c:intel_dg_mtd_read(), the bounds check
subtracts the offset from the region size:

    idx = idg_nvm_get_region(nvm, from);
    
    if (len > nvm->regions[idx].size - from)
        len = nvm->regions[idx].size - from;

If the from offset exceeds nvm->regions[0].size, the unsigned subtraction
will underflow, resulting in a very large value. This bypasses the length
truncation and allows out-of-bounds hardware memory accesses.

Could the same underflow occur in the bounds checks in intel_dg_mtd_write()
and intel_dg_mtd_erase()?

>  	for (i = 0; i < nvm->nregions; i++) {
>  		if ((nvm->regions[i].offset + nvm->regions[i].size - 1) >= from &&

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260715-cri_surviv-v1-0-61763a6f1076@intel.com?part=1

  reply	other threads:[~2026-07-15 14:19 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-15 13:45 [PATCH 0/2] drm/xe/nvm: add survivabilty partiton Alexander Usyskin
2026-07-15 13:45 ` Alexander Usyskin
2026-07-15 13:45 ` [PATCH 1/2] mtd: mtd_intel_dg: add survivability partition Alexander Usyskin
2026-07-15 13:45   ` Alexander Usyskin
2026-07-15 14:19   ` sashiko-bot [this message]
2026-07-15 13:45 ` [PATCH 2/2] drm/xe/nvm: define survivabilty partition Alexander Usyskin
2026-07-15 13:45   ` Alexander Usyskin
2026-07-15 14:32   ` sashiko-bot
2026-07-15 14:53 ` ✓ CI.KUnit: success for drm/xe/nvm: add survivabilty partiton Patchwork
2026-07-15 15:33 ` ✓ Xe.CI.BAT: " Patchwork
2026-07-15 18:31 ` ✓ Xe.CI.FULL: " Patchwork

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=20260715141951.963351F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=alexander.usyskin@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.