From: Anmol Karn <anmol.karan123@gmail.com>
To: dwmw2@infradead.org, richard@nod.at, viro@zeniv.linux.org.uk,
sandeen@sandeen.net, dhowells@redhat.com
Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org,
linux-kernel-mentees@lists.linuxfoundation.org,
syzkaller-bugs@googlegroups.com, anmol.karan123@gmail.com,
syzbot+9765367bb86a19d38732@syzkaller.appspotmail.com
Subject: [Linux-kernel-mentees] [PATCH] fs: jffs2: super: Fix null pointer dereference in jffs2_parse_param()
Date: Sun, 4 Oct 2020 02:03:10 +0530 [thread overview]
Message-ID: <20201003203310.494524-1-anmol.karan123@gmail.com> (raw)
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
WARNING: multiple messages have this Message-ID (diff)
From: Anmol Karn <anmol.karan123@gmail.com>
To: dwmw2@infradead.org, richard@nod.at, viro@zeniv.linux.org.uk,
sandeen@sandeen.net, dhowells@redhat.com
Cc: anmol.karan123@gmail.com,
syzbot+9765367bb86a19d38732@syzkaller.appspotmail.com,
syzkaller-bugs@googlegroups.com, linux-kernel@vger.kernel.org,
linux-mtd@lists.infradead.org,
linux-kernel-mentees@lists.linuxfoundation.org
Subject: [Linux-kernel-mentees] [PATCH] fs: jffs2: super: Fix null pointer dereference in jffs2_parse_param()
Date: Sun, 4 Oct 2020 02:03:10 +0530 [thread overview]
Message-ID: <20201003203310.494524-1-anmol.karan123@gmail.com> (raw)
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/
WARNING: multiple messages have this Message-ID (diff)
From: Anmol Karn <anmol.karan123@gmail.com>
To: dwmw2@infradead.org, richard@nod.at, viro@zeniv.linux.org.uk,
sandeen@sandeen.net, dhowells@redhat.com
Cc: syzbot+9765367bb86a19d38732@syzkaller.appspotmail.com,
syzkaller-bugs@googlegroups.com, linux-kernel@vger.kernel.org,
linux-mtd@lists.infradead.org,
linux-kernel-mentees@lists.linuxfoundation.org
Subject: [Linux-kernel-mentees] [PATCH] fs: jffs2: super: Fix null pointer dereference in jffs2_parse_param()
Date: Sun, 4 Oct 2020 02:03:10 +0530 [thread overview]
Message-ID: <20201003203310.494524-1-anmol.karan123@gmail.com> (raw)
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-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
next reply other threads:[~2020-10-03 20:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-03 20:33 Anmol Karn [this message]
2020-10-03 20:33 ` [Linux-kernel-mentees] [PATCH] fs: jffs2: super: Fix null pointer dereference in jffs2_parse_param() Anmol Karn
2020-10-03 20:33 ` Anmol Karn
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=20201003203310.494524-1-anmol.karan123@gmail.com \
--to=anmol.karan123@gmail.com \
--cc=dhowells@redhat.com \
--cc=dwmw2@infradead.org \
--cc=linux-kernel-mentees@lists.linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=richard@nod.at \
--cc=sandeen@sandeen.net \
--cc=syzbot+9765367bb86a19d38732@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
--cc=viro@zeniv.linux.org.uk \
/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.