From: Rahul Kumar <rk0006818@gmail.com>
To: linux-mtd@lists.infradead.org
Cc: Joern Engel <joern@lazybastard.org>,
Miquel Raynal <miquel.raynal@bootlin.com>,
Richard Weinberger <richard@nod.at>,
Vignesh Raghavendra <vigneshr@ti.com>,
Vincent Whitchurch <vincent.whitchurch@axis.com>,
linux-kernel@vger.kernel.org,
syzbot+eaaabe90f486cb6f31b2@syzkaller.appspotmail.com,
syzbot+061cb4ee001379dbbfaf@syzkaller.appspotmail.com,
Rahul Kumar <rk0006818@gmail.com>
Subject: [PATCH] mtd: phram: reject non-RAM ranges for module parameters
Date: Wed, 21 Oct 2026 07:53:48 -0400 [thread overview]
Message-ID: <20261021115348.799538-1-rk0006818@gmail.com> (raw)
Writing a bogus address such as "p0,0x8000000000000000,0x1000" to
/sys/module/phram/parameters/phram reaches ioremap() and triggers
WARNING in __ioremap_caller on x86. On arm64 a non-RAM address can
map and later Oops in memcpy when FTL scans the device.
For module-parameter devices, require the range to be System RAM
before mapping. Also default that path to memremap(), matching DT
without "no-map".
Fixes: 9401911f2d9f ("mtd: phram: Allow cached mappings")
Reported-by: syzbot+eaaabe90f486cb6f31b2@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=eaaabe90f486cb6f31b2
Reported-by: syzbot+061cb4ee001379dbbfaf@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=061cb4ee001379dbbfaf
Signed-off-by: Rahul Kumar <rk0006818@gmail.com>
---
drivers/mtd/devices/phram.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/mtd/devices/phram.c b/drivers/mtd/devices/phram.c
index b42cadcd76b1..9747e7e58e6f 100644
--- a/drivers/mtd/devices/phram.c
+++ b/drivers/mtd/devices/phram.c
@@ -19,6 +19,7 @@
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/io.h>
+#include <linux/ioport.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/list.h>
@@ -126,10 +127,16 @@ static int register_device(struct platform_device *pdev, const char *name,
phys_addr_t start, size_t len, uint32_t erasesize)
{
struct device_node *np = pdev ? pdev->dev.of_node : NULL;
- bool cached = np ? !of_property_read_bool(np, "no-map") : false;
+ bool cached = np ? !of_property_read_bool(np, "no-map") : true;
struct phram_mtd_list *new;
int ret = -ENOMEM;
+ if (!np && region_intersects(start, len, IORESOURCE_SYSTEM_RAM,
+ IORES_DESC_NONE) != REGION_INTERSECTS) {
+ pr_err("start/len is not System RAM\n");
+ return -EINVAL;
+ }
+
new = kzalloc_obj(*new);
if (!new)
goto out0;
@@ -138,7 +145,7 @@ static int register_device(struct platform_device *pdev, const char *name,
ret = phram_map(new, start, len);
if (ret) {
- pr_err("ioremap failed\n");
+ pr_err("failed to map memory\n");
goto out1;
}
--
2.52.0
reply other threads:[~2026-10-21 11:55 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261021115348.799538-1-rk0006818@gmail.com \
--to=rk0006818@gmail.com \
--cc=joern@lazybastard.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=miquel.raynal@bootlin.com \
--cc=richard@nod.at \
--cc=syzbot+061cb4ee001379dbbfaf@syzkaller.appspotmail.com \
--cc=syzbot+eaaabe90f486cb6f31b2@syzkaller.appspotmail.com \
--cc=vigneshr@ti.com \
--cc=vincent.whitchurch@axis.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
all inboxes | Powered by JetHome®