linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] fs: fs_parser: avoid NULL param->string to kstrtouint
@ 2019-07-19 23:29 Yin Fengwei
  2019-08-16  2:46 ` Eric Biggers
  0 siblings, 1 reply; 4+ messages in thread
From: Yin Fengwei @ 2019-07-19 23:29 UTC (permalink / raw)
  To: dhowells, gregkh, linux-fsdevel, linux-kernel, syzkaller-bugs,
	miklos, viro, tglx, kstewart

syzbot reported general protection fault in kstrtouint:
https://lkml.org/lkml/2019/7/18/328

From the log, if the mount option is something like:
   fd,XXXXXXXXXXXXXXXXXXXX

The default parameter (which has NULL param->string) will be
passed to vfs_parse_fs_param. Finally, this NULL param->string
is passed to kstrtouint and trigger NULL pointer access.

Reported-by: syzbot+398343b7c1b1b989228d@syzkaller.appspotmail.com
Fixes: 71cbb7570a9a ("vfs: Move the subtype parameter into fuse")

Signed-off-by: Yin Fengwei <nh26223.lmm@gmail.com>
---
ChangeLog:
 v1 -> v2:
   - Fix typo in v1
   - Remove braces {} from single statement blocks

 fs/fs_parser.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/fs_parser.c b/fs/fs_parser.c
index 83b66c9e9a24..7498a44f18c0 100644
--- a/fs/fs_parser.c
+++ b/fs/fs_parser.c
@@ -206,6 +206,9 @@ int fs_parse(struct fs_context *fc,
 	case fs_param_is_fd: {
 		switch (param->type) {
 		case fs_value_is_string:
+			if (!result->has_value)
+				goto bad_value;
+
 			ret = kstrtouint(param->string, 0, &result->uint_32);
 			break;
 		case fs_value_is_file:
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] fs: fs_parser: avoid NULL param->string to kstrtouint
  2019-07-19 23:29 [PATCH v2] fs: fs_parser: avoid NULL param->string to kstrtouint Yin Fengwei
@ 2019-08-16  2:46 ` Eric Biggers
  2019-08-22  4:22   ` Eric Biggers
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Biggers @ 2019-08-16  2:46 UTC (permalink / raw)
  To: viro
  Cc: dhowells, gregkh, linux-fsdevel, linux-kernel, syzkaller-bugs,
	miklos, tglx, Yin Fengwei, kstewart

On Sat, Jul 20, 2019 at 07:29:49AM +0800, Yin Fengwei wrote:
> syzbot reported general protection fault in kstrtouint:
> https://lkml.org/lkml/2019/7/18/328
> 
> From the log, if the mount option is something like:
>    fd,XXXXXXXXXXXXXXXXXXXX
> 
> The default parameter (which has NULL param->string) will be
> passed to vfs_parse_fs_param. Finally, this NULL param->string
> is passed to kstrtouint and trigger NULL pointer access.
> 
> Reported-by: syzbot+398343b7c1b1b989228d@syzkaller.appspotmail.com
> Fixes: 71cbb7570a9a ("vfs: Move the subtype parameter into fuse")
> 
> Signed-off-by: Yin Fengwei <nh26223.lmm@gmail.com>
> ---
> ChangeLog:
>  v1 -> v2:
>    - Fix typo in v1
>    - Remove braces {} from single statement blocks
> 
>  fs/fs_parser.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/fs/fs_parser.c b/fs/fs_parser.c
> index 83b66c9e9a24..7498a44f18c0 100644
> --- a/fs/fs_parser.c
> +++ b/fs/fs_parser.c
> @@ -206,6 +206,9 @@ int fs_parse(struct fs_context *fc,
>  	case fs_param_is_fd: {
>  		switch (param->type) {
>  		case fs_value_is_string:
> +			if (!result->has_value)
> +				goto bad_value;
> +
>  			ret = kstrtouint(param->string, 0, &result->uint_32);
>  			break;
>  		case fs_value_is_file:
> -- 
> 2.17.1

Reviewed-by: Eric Biggers <ebiggers@kernel.org>

Al, can you please apply this patch?

- Eric

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] fs: fs_parser: avoid NULL param->string to kstrtouint
  2019-08-16  2:46 ` Eric Biggers
@ 2019-08-22  4:22   ` Eric Biggers
  2019-08-22  5:33     ` Al Viro
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Biggers @ 2019-08-22  4:22 UTC (permalink / raw)
  To: viro; +Cc: dhowells, linux-fsdevel, linux-kernel, syzkaller-bugs

[trimmed Cc list a bit]

On Thu, Aug 15, 2019 at 07:46:56PM -0700, Eric Biggers wrote:
> On Sat, Jul 20, 2019 at 07:29:49AM +0800, Yin Fengwei wrote:
> > syzbot reported general protection fault in kstrtouint:
> > https://lkml.org/lkml/2019/7/18/328
> > 
> > From the log, if the mount option is something like:
> >    fd,XXXXXXXXXXXXXXXXXXXX
> > 
> > The default parameter (which has NULL param->string) will be
> > passed to vfs_parse_fs_param. Finally, this NULL param->string
> > is passed to kstrtouint and trigger NULL pointer access.
> > 
> > Reported-by: syzbot+398343b7c1b1b989228d@syzkaller.appspotmail.com
> > Fixes: 71cbb7570a9a ("vfs: Move the subtype parameter into fuse")
> > 
> > Signed-off-by: Yin Fengwei <nh26223.lmm@gmail.com>
> > ---
> > ChangeLog:
> >  v1 -> v2:
> >    - Fix typo in v1
> >    - Remove braces {} from single statement blocks
> > 
> >  fs/fs_parser.c | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/fs/fs_parser.c b/fs/fs_parser.c
> > index 83b66c9e9a24..7498a44f18c0 100644
> > --- a/fs/fs_parser.c
> > +++ b/fs/fs_parser.c
> > @@ -206,6 +206,9 @@ int fs_parse(struct fs_context *fc,
> >  	case fs_param_is_fd: {
> >  		switch (param->type) {
> >  		case fs_value_is_string:
> > +			if (!result->has_value)
> > +				goto bad_value;
> > +
> >  			ret = kstrtouint(param->string, 0, &result->uint_32);
> >  			break;
> >  		case fs_value_is_file:
> > -- 
> > 2.17.1
> 
> Reviewed-by: Eric Biggers <ebiggers@kernel.org>
> 
> Al, can you please apply this patch?
> 
> - Eric

Ping.  Al, when are you going to apply this?

- Eric

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] fs: fs_parser: avoid NULL param->string to kstrtouint
  2019-08-22  4:22   ` Eric Biggers
@ 2019-08-22  5:33     ` Al Viro
  0 siblings, 0 replies; 4+ messages in thread
From: Al Viro @ 2019-08-22  5:33 UTC (permalink / raw)
  To: dhowells, linux-fsdevel, linux-kernel, syzkaller-bugs

On Wed, Aug 21, 2019 at 09:22:49PM -0700, Eric Biggers wrote:
> > > diff --git a/fs/fs_parser.c b/fs/fs_parser.c
> > > index 83b66c9e9a24..7498a44f18c0 100644
> > > --- a/fs/fs_parser.c
> > > +++ b/fs/fs_parser.c
> > > @@ -206,6 +206,9 @@ int fs_parse(struct fs_context *fc,
> > >  	case fs_param_is_fd: {
> > >  		switch (param->type) {
> > >  		case fs_value_is_string:
> > > +			if (!result->has_value)
> > > +				goto bad_value;
> > > +
> > >  			ret = kstrtouint(param->string, 0, &result->uint_32);
> > >  			break;
> > >  		case fs_value_is_file:
> > > -- 
> > > 2.17.1
> > 
> > Reviewed-by: Eric Biggers <ebiggers@kernel.org>
> > 
> > Al, can you please apply this patch?
> > 
> > - Eric
> 
> Ping.  Al, when are you going to apply this?

Sits in the local queue.  Sorry, got seriously sidetracked into
configfs mess lately, will update for-next tomorrow and push
it out.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-08-22  5:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-19 23:29 [PATCH v2] fs: fs_parser: avoid NULL param->string to kstrtouint Yin Fengwei
2019-08-16  2:46 ` Eric Biggers
2019-08-22  4:22   ` Eric Biggers
2019-08-22  5:33     ` Al Viro

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).