All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "James Hilliard" <james.hilliard1@gmail.com>,
	"Miquel Raynal" <miquel.raynal@bootlin.com>,
	"Richard Weinberger" <richard@nod.at>,
	"Vignesh Raghavendra" <vigneshr@ti.com>,
	"Michał Kępień" <kernel@kempniu.pl>
Cc: linux-mtd@lists.infradead.org
Subject: Re: [PATCH v3 2/4] mtdchar: bound OOB reads to the data in intermediate chunks
Date: Fri, 04 Dec 2026 23:23:16 +0000	[thread overview]
Message-ID: <sashiko-outbox-250799@kernel.org> (raw)
In-Reply-To: <20261204-submit-mtdchar-page-chunking-v1-v3-2-2f36958a6e8d@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] mtdchar: mtdchar_read_ioctl() clamps ops.ooblen before bounds
  validation
--

commit a1e7568a6832dadbb9cdc28b11f43423f55e0bbb
Author: James Hilliard <james.hilliard1@gmail.com>

mtdchar: bound OOB reads to the data in intermediate chunks

This commit calls adjust_oob_length() on intermediate chunks in
mtdchar_read_ioctl() to limit ops.ooblen to the pages covered by each
chunk's data read, matching MEMWRITE and avoiding duplicate OOB reads.

> diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
> index 87ff071afc974..25c59cc7f0974 100644
> --- a/drivers/mtd/mtdchar.c
> +++ b/drivers/mtd/mtdchar.c
> @@ -769,6 +769,9 @@ mtdchar_read_ioctl(struct mtd_info *mtd, struct mtd_read_req __user *argp)
>  		if (ops.len == mtd->erasesize)
>  			ops.len -= mtd_mod_by_ws(req.start + ops.len, mtd);
>  
> +		if (ops.len < req.len)
> +			adjust_oob_length(mtd, req.start, &ops);
> +
>  		ret = mtd_read_oob(mtd, (loff_t)req.start, &ops);
>  
>  		req.ecc_stats.uncorrectable_errors +=

[Severity: Medium]
Can clamping ops.ooblen here hide an out-of-bounds req.ooblen from
mtd_check_oob_ops() during intermediate iterations?

mtdchar_read_ioctl() only checks req.start + req.len against mtd->size
upfront and relies on mtd_check_oob_ops() to reject ops.ooblen > maxooblen.
For a multi-eraseblock read near the end of a partition where maxooblen is
below min(req.ooblen, mtd->erasesize), clamping ops.ooblen lets it pass.

Before this patch, the first mtd_read_oob() call returned -EINVAL
immediately with no side effects.  With this change, the loop reads the
intermediate eraseblocks, copies partial data and OOB to userspace, and
updates req.start, req.len, req.ooblen, and req.ecc_stats before failing.

Validating req.ooblen against the remaining device OOB capacity before
entering the loop would preserve immediate -EINVAL rejection.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261204-submit-mtdchar-page-chunking-v1-v3-0-2f36958a6e8d@gmail.com?part=2

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

  reply	other threads:[~2026-12-04 23:23 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04 23:01 [PATCH v3 0/4] mtdchar: keep data and OOB aligned across ioctl chunks James Hilliard
2026-12-04 23:01 ` James Hilliard
2026-12-04 23:01 ` [PATCH v3 1/4] mtdchar: calculate OOB capacity from the starting column James Hilliard
2026-12-04 23:01   ` James Hilliard
2026-12-04 23:01 ` [PATCH v3 2/4] mtdchar: bound OOB reads to the data in intermediate chunks James Hilliard
2026-12-04 23:01   ` James Hilliard
2026-12-04 23:23   ` sashiko-bot [this message]
2026-12-04 23:02 ` [PATCH v3 3/4] mtdchar: keep OOB chunks aligned with their data pages James Hilliard
2026-12-04 23:02   ` James Hilliard
2026-12-04 23:20   ` sashiko-bot
2026-12-04 23:02 ` [PATCH v3 4/4] mtdchar: finish OOB transfers after the data runs out James Hilliard
2026-12-04 23:02   ` James Hilliard
2026-12-04 23:23   ` sashiko-bot

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-250799@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=james.hilliard1@gmail.com \
    --cc=kernel@kempniu.pl \
    --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.