From: sashiko-bot@kernel.org
To: "Edward Adam Davis" <eadavis@sina.com>
Cc: joern@lazybastard.org, linux-mtd@lists.infradead.org,
miquel.raynal@bootlin.com, richard@nod.at,
syzbot+ee09ee2112d03c35f1f7@syzkaller.appspotmail.com,
syzkaller-bugs@googlegroups.com, vigneshr@ti.com
Subject: Re: [PATCH v2] mtd: Use I/O memory accessors when in an uncached
Date: Fri, 20 Nov 2026 05:35:32 +0000 [thread overview]
Message-ID: <sashiko-outbox-224492@kernel.org> (raw)
In-Reply-To: <20261120052434.101613-1-eadavis@sina.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] mtd: phram: uncached ioremap() pointer exposed via
phram_point()
- [Low] mtd: phram: inaccurate Fixes trailer and truncated commit
message
--
commit 54b14d07ef014deae72f6fbc65c025f6ac913af6
Author: Edward Adam Davis <eadavis@sina.com>
> mtd: Use I/O memory accessors when in an uncached
>
> When registering a phram device via module parameter or sysfs invokes
> register_device() with pdev = NULL, which causes new->cached to be false.
> As a result, phram_map() maps the physical memory region using ioremap()
> (mapped as PROT_DEVICE_nGnRE on arm64) and forces the pointer into mtd->
> priv, yet phram_read(), phram_write(), and phram_erase() access it using
> standard memcpy() and memset() instead of I/O memory accessors (like
> memcpy_fromio()). When scanning partition headers (e.g., ftl_add_mtd()
> reading a 68-byte header via mtd_read()), arm64's memcpy implementation
> issues pair-load (ldp) instructions at unaligned offsets, which triggers
> an alignment fault (FSC = 0x21) on Device memory and crashes the kernel.
>
> In phram_read/write/erase(), standard memory accessors are used when in
> a cached; otherwise, I/O memory accessors are used.
>
> Fixes: f3d45ac21e46 ("mtd: phram: Module parameters add writable permissions")
> Fixes: 285133040e6c ("arm64: Import latest memcpy()/memmove() implementation")
> Reported-by: syzbot+ee09ee2112d03c35f1f7@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=ee09ee2112d03c35f1f7
> Signed-off-by: Edward Adam Davis <eadavis@sina.com>
[Severity: Low]
Are the Fixes tags accurate here? Calling memcpy() on an __iomem pointer
from ioremap() is a phram bug rather than a bug in 285133040e6c ("arm64:
Import latest memcpy()/memmove() implementation"), and this patch branches on
phram->cached, which was added in 9401911f2d9f ("mtd: phram: Allow cached
mappings").
Also, the subject ("mtd: Use I/O memory accessors when in an uncached") and
body ("when in a cached") are missing the "mtd: phram:" prefix and the
trailing noun (such as "mapping").
> diff --git a/drivers/mtd/devices/phram.c b/drivers/mtd/devices/phram.c
> index b42cadcd76b11..802da960d840a 100644
> --- a/drivers/mtd/devices/phram.c
> +++ b/drivers/mtd/devices/phram.c
> @@ -43,8 +43,14 @@ static LIST_HEAD(phram_list);
> static int phram_erase(struct mtd_info *mtd, struct erase_info *instr)
> {
> u_char *start = mtd->priv;
> + struct phram_mtd_list *phram =
> + container_of(mtd, struct phram_mtd_list, mtd);
>
> - memset(start + instr->addr, 0xff, instr->len);
> + if (phram->cached)
> + memset(start + instr->addr, 0xff, instr->len);
> + else
> + memset_io((void __iomem *)start + instr->addr, 0xff,
> + instr->len);
>
> return 0;
> }
> @@ -66,8 +72,13 @@ static int phram_read(struct mtd_info *mtd, loff_t from, size_t len,
> size_t *retlen, u_char *buf)
> {
> u_char *start = mtd->priv;
> + struct phram_mtd_list *phram =
> + container_of(mtd, struct phram_mtd_list, mtd);
>
> - memcpy(buf, start + from, len);
> + if (phram->cached)
> + memcpy(buf, start + from, len);
> + else
> + memcpy_fromio(buf, (void __iomem *)start + from, len);
> *retlen = len;
> return 0;
> }
[Severity: High]
Does phram_point() still expose the uncached ioremap() pointer in mtd->priv
to callers that use normal memcpy() on it?
Between phram_erase() and phram_read(), phram_point() remains unchanged and
is unconditionally wired up in register_device():
drivers/mtd/devices/phram.c:phram_point() {
*virt = mtd->priv + from;
*retlen = len;
return 0;
}
Callers of mtd_point() expect normal direct-accessible memory and bypass
mtd_read(). For example, mounting cramfs or jffs2 on an uncached phram
device succeeds in mtd_point() and runs memcpy() directly on the returned
pointer (such as the 76-byte superblock read in cramfs_read_super()),
triggering the same alignment fault on arm64 Device memory. Should
_point and _unpoint only be registered (or phram_point() return
-EOPNOTSUPP) when phram->cached is false?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261120052434.101613-1-eadavis@sina.com?part=1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
prev parent reply other threads:[~2026-11-20 5:35 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 1:49 [syzbot] [mtd?] BUG: unable to handle kernel paging request in phram_read syzbot
2026-11-20 4:37 ` [PATCH] mtd: Use I/O memory accessors when in an uncached Edward Adam Davis
2026-11-20 4:47 ` sashiko-bot
2026-11-20 5:24 ` [PATCH v2] " Edward Adam Davis
2026-11-20 5:35 ` sashiko-bot [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=sashiko-outbox-224492@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=eadavis@sina.com \
--cc=joern@lazybastard.org \
--cc=linux-mtd@lists.infradead.org \
--cc=miquel.raynal@bootlin.com \
--cc=richard@nod.at \
--cc=sashiko-reviews@lists.linux.dev \
--cc=syzbot+ee09ee2112d03c35f1f7@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
--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