From: Hawkins Jiawei <yin31149@gmail.com>
To: yin31149@gmail.com, Bob Peterson <rpeterso@redhat.com>,
Andreas Gruenbacher <agruenba@redhat.com>
Cc: 18801353760@163.com, linux-kernel@vger.kernel.org,
linux-fsdevel@vger.kernel.org,
syzbot+da97a57c5b742d05db51@syzkaller.appspotmail.com,
cluster-devel@redhat.com, syzkaller-bugs@googlegroups.com
Subject: [PATCH -next 4/5] gfs2: fix possible null-ptr-deref when parsing param
Date: Mon, 24 Oct 2022 00:39:49 +0800 [thread overview]
Message-ID: <20221023163945.39920-5-yin31149@gmail.com> (raw)
In-Reply-To: <20221023163945.39920-1-yin31149@gmail.com>
According to commit "vfs: parse: deal with zero length string value",
kernel will set the param->string to null pointer in vfs_parse_fs_string()
if fs string has zero length.
Yet the problem is that, gfs2_parse_param() will dereferences the
param->string, without checking whether it is a null pointer, which may
trigger a null-ptr-deref bug.
This patch solves it by adding sanity check on param->string
in gfs2_parse_param().
Reported-by: syzbot+da97a57c5b742d05db51@syzkaller.appspotmail.com
Tested-by: syzbot+da97a57c5b742d05db51@syzkaller.appspotmail.com
Cc: agruenba@redhat.com
Cc: cluster-devel@redhat.com
Cc: linux-kernel@vger.kernel.org
Cc: rpeterso@redhat.com
Cc: syzkaller-bugs@googlegroups.com
Signed-off-by: Hawkins Jiawei <yin31149@gmail.com>
---
fs/gfs2/ops_fstype.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
index c0cf1d2d0ef5..934746f18c25 100644
--- a/fs/gfs2/ops_fstype.c
+++ b/fs/gfs2/ops_fstype.c
@@ -1446,12 +1446,18 @@ static int gfs2_parse_param(struct fs_context *fc, struct fs_parameter *param)
switch (o) {
case Opt_lockproto:
+ if (!param->string)
+ goto bad_val;
strscpy(args->ar_lockproto, param->string, GFS2_LOCKNAME_LEN);
break;
case Opt_locktable:
+ if (!param->string)
+ goto bad_val;
strscpy(args->ar_locktable, param->string, GFS2_LOCKNAME_LEN);
break;
case Opt_hostdata:
+ if (!param->string)
+ goto bad_val;
strscpy(args->ar_hostdata, param->string, GFS2_LOCKNAME_LEN);
break;
case Opt_spectator:
@@ -1535,6 +1541,10 @@ static int gfs2_parse_param(struct fs_context *fc, struct fs_parameter *param)
return invalfc(fc, "invalid mount option: %s", param->key);
}
return 0;
+
+bad_val:
+ return invalfc(fc, "Bad value '%s' for mount option '%s'\n",
+ param->string, param->key);
}
static int gfs2_reconfigure(struct fs_context *fc)
--
2.25.1
next prev parent reply other threads:[~2022-10-23 16:43 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-23 16:39 [PATCH -next 0/5] fs: fix possible null-ptr-deref when parsing param Hawkins Jiawei
2022-10-23 16:39 ` [PATCH -next 1/5] smb3: " Hawkins Jiawei
2022-10-23 16:39 ` [PATCH -next 2/5] nfs: " Hawkins Jiawei
2022-10-24 10:53 ` Jeff Layton
2022-10-23 16:39 ` [PATCH -next 3/5] ceph: " Hawkins Jiawei
2022-10-24 0:38 ` Xiubo Li
2022-10-24 0:55 ` Xiubo Li
2022-10-24 2:04 ` Hawkins Jiawei
2022-10-24 2:17 ` Xiubo Li
2022-10-23 16:39 ` Hawkins Jiawei [this message]
2022-10-24 9:42 ` [PATCH -next 4/5] gfs2: " Andreas Grünbacher
2022-10-23 16:39 ` [PATCH -next 5/5] proc: " Hawkins Jiawei
2022-10-23 16:48 ` [PATCH -next 0/5] fs: " Al Viro
2022-10-24 0:42 ` Hawkins Jiawei
2022-10-24 3:34 ` Ian Kent
2022-10-31 11:28 ` Tetsuo Handa
2022-11-01 0:32 ` Ian Kent
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=20221023163945.39920-5-yin31149@gmail.com \
--to=yin31149@gmail.com \
--cc=18801353760@163.com \
--cc=agruenba@redhat.com \
--cc=cluster-devel@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rpeterso@redhat.com \
--cc=syzbot+da97a57c5b742d05db51@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.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;
as well as URLs for NNTP newsgroup(s).