Linux-mtd Archive on 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 3/4] mtdchar: keep OOB chunks aligned with their data pages
Date: Fri, 04 Dec 2026 23:20:37 +0000	[thread overview]
Message-ID: <sashiko-outbox-250797@kernel.org> (raw)
In-Reply-To: <20261204-submit-mtdchar-page-chunking-v1-v3-3-2f36958a6e8d@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] mtdchar: mtdchar_read_ioctl() mutates req.start returned to
  userspace
--

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

mtdchar: keep OOB chunks aligned with their data pages

This commit advances the flash offset in OOB-only MEMREAD and MEMWRITE
requests by the number of pages transferred, rounds intermediate OOB
chunks down to whole pages, and caps data chunks when OOB is the
limiting buffer.

> diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
> index 25c59cc7f0974..454ec3ec0c982 100644
> --- a/drivers/mtd/mtdchar.c
> +++ b/drivers/mtd/mtdchar.c

[ ... ]

> @@ -789,7 +826,11 @@ mtdchar_read_ioctl(struct mtd_info *mtd, struct mtd_read_req __user *argp)
>  			break;
>  		}
>  
> -		req.start += ops.retlen;
> +		if (usr_data)
> +			req.start += ops.retlen;
> +		else
> +			req.start += (u64)(ops.oobretlen / mtd_oobavail(mtd, &ops)) *
> +				     mtd->writesize;

[Severity: Medium]
Does updating req.start directly here change the MEMREAD UAPI for
OOB-only calls?

Unlike mtdchar_write_ioctl(), mtdchar_read_ioctl() copies req back to
userspace before returning.  Previously, OOB-only reads had
ops.retlen == 0 and left req.start unchanged; now any OOB-only read of
at least one page of OOB overwrites req.start in userspace.

Callers that reuse struct mtd_read_req across calls (such as reading OOB
and then data from the same offset) will see an altered offset, and
partial-page OOB reads advance req.start inconsistently.  Tracking the
cursor in a local variable would keep req.start unchanged.

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

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

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

Thread overview: 8+ 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 ` [PATCH v3 1/4] mtdchar: calculate OOB capacity from the starting column 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:23   ` sashiko-bot
2026-12-04 23:02 ` [PATCH v3 3/4] mtdchar: keep OOB chunks aligned with their data pages James Hilliard
2026-12-04 23:20   ` sashiko-bot [this message]
2026-12-04 23:02 ` [PATCH v3 4/4] mtdchar: finish OOB transfers after the data runs out 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-250797@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox