* [Linux-kernel-mentees] [PATCH] fs: jffs2: super: Fix null pointer dereference in jffs2_parse_param()
@ 2020-10-03 20:33 Anmol Karn
0 siblings, 0 replies; only message in thread
From: Anmol Karn @ 2020-10-03 20:33 UTC (permalink / raw)
To: dwmw2, richard, viro, sandeen, dhowells
Cc: anmol.karan123, syzbot+9765367bb86a19d38732, syzkaller-bugs,
linux-kernel, linux-mtd, linux-kernel-mentees
mtd is getting NULL dereferenced in jffs2_parse_param(), while checking condition
for pool size when, case: opt is Opt_rp_size hits.
- fs/jffs2/super.c
The bug seems to get triggered in this line:
if (opt > c->mtd->size)
return invalf(fc, "jffs2: Too large reserve pool specified, max is %llu KB",
c->mtd->size / 1024);
Fix this by adding a NULL check for 'c->mtd' device and return invalf(); which wraps
errorf() and returns -EINVAL for convenience, which allows userspace to collect them
directly.
Reported-and-tested-by: syzbot+9765367bb86a19d38732@syzkaller.appspotmail.com
Link: https://syzkaller.appspot.com/bug?extid=9765367bb86a19d38732
Signed-off-by: Anmol Karn <anmol.karan123@gmail.com>
---
fs/jffs2/super.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/fs/jffs2/super.c b/fs/jffs2/super.c
index 05d7878dfad1..f4ce67ac8486 100644
--- a/fs/jffs2/super.c
+++ b/fs/jffs2/super.c
@@ -203,6 +203,10 @@ static int jffs2_parse_param(struct fs_context *fc, struct fs_parameter *param)
if (result.uint_32 > UINT_MAX / 1024)
return invalf(fc, "jffs2: rp_size unrepresentable");
opt = result.uint_32 * 1024;
+
+ if (!c->mtd)
+ return invalf(fc, "jffs2: mtd device is NULL");
+
if (opt > c->mtd->size)
return invalf(fc, "jffs2: Too large reserve pool specified, max is %llu KB",
c->mtd->size / 1024);
--
2.28.0
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] only message in thread
only message in thread, back to index
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-03 20:33 [Linux-kernel-mentees] [PATCH] fs: jffs2: super: Fix null pointer dereference in jffs2_parse_param() Anmol Karn
Linux-mtd Archive on lore.kernel.org
Archives are clonable:
git clone --mirror https://lore.kernel.org/linux-mtd/0 linux-mtd/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 linux-mtd linux-mtd/ https://lore.kernel.org/linux-mtd \
linux-mtd@lists.infradead.org
public-inbox-index linux-mtd
Example config snippet for mirrors
Newsgroup available over NNTP:
nntp://nntp.lore.kernel.org/org.infradead.lists.linux-mtd
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git