From: sashiko-bot@kernel.org
To: "Fang Xieyan" <fangxy@xiaopeng.com>,
miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com
Cc: linux-mtd@lists.infradead.org
Subject: Re: [PATCH] mtd: mtdpart: fix overflow check for partition offset and size
Date: Thu, 03 Dec 2026 08:22:35 +0000 [thread overview]
Message-ID: <sashiko-outbox-247349@kernel.org> (raw)
In-Reply-To: <20261203080547.15619-1-fangxy@xiaopeng.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] mtd: commit message omits parent_size change in
allocate_partition()
--
commit 7c4b08e85f36165da1faf0008f5c917a5c9096ce
Author: Fang Xieyan <fangxy@xiaopeng.com>
> mtd: mtdpart: fix overflow check for partition offset and size
>
> allocate_partition() checks whether a partition extends beyond its
> parent by adding the partition offset and size. Both values are u64,
> so the addition can overflow and wrap to a value smaller than the
> parent size. This allows an oversized partition to bypass the sanity
> check and be registered without truncation, potentially causing
> subsequent partitions to be placed at incorrect offsets.
>
> Partition definitions supplied by MTD partition parsers, such as the
> mtdparts= command line parser and device tree fixed-partitions, can
> provide values that trigger this overflow.
>
> Compare the partition size against the remaining space after its
> offset instead. The preceding check guarantees that the offset is
> less than parent_size, so the subtraction cannot underflow.
>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Cc: stable@vger.kernel.org
> Signed-off-by: Fang Xieyan <fangxy@xiaopeng.com>
[Severity: Low]
Should the commit message also mention that the check switches from
parent->size to parent_size?
For a parent partition with MTD_SLC_ON_MLC_EMULATION set,
add_mtd_device() scales parent->size down while parent->part.size keeps
the full physical size.
Commit 9e3307a16953 ("mtd: Add support for emulated SLC mode on MLC
NANDs") updated the other parent->size uses in allocate_partition() to
parent_size, but missed this check, allowing valid subpartitions
between parent->size and parent_size to be expanded on truncation.
Noting this secondary fix would give reviewers and stable maintainers
accurate context for the change.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203080547.15619-1-fangxy@xiaopeng.com?part=1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
next prev parent reply other threads:[~2026-12-03 8:22 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 8:05 [PATCH] mtd: mtdpart: fix overflow check for partition offset and size Fang Xieyan
2026-12-03 8:05 ` Fang Xieyan
2026-12-03 8:22 ` sashiko-bot [this message]
2026-12-03 10:00 ` Miquel Raynal
2026-12-03 10:00 ` Miquel Raynal
2026-12-03 23:53 ` Fang Xieyan
2026-12-03 23:53 ` Fang Xieyan
2026-12-04 10:38 ` Miquel Raynal
2026-12-04 10:38 ` Miquel Raynal
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=sashiko-outbox-247349@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=fangxy@xiaopeng.com \
--cc=linux-mtd@lists.infradead.org \
--cc=miquel.raynal@bootlin.com \
--cc=richard@nod.at \
--cc=sashiko-reviews@lists.linux.dev \
--cc=vigneshr@ti.com \
/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.