Re: KASAN: slab-out-of-bounds Read in suffix_kstrtoint

From: Al Viro
Date: Fri Feb 07 2020 - 00:07:27 EST


On Thu, Feb 06, 2020 at 07:48:17PM -0800, syzbot wrote:
> Hello,
>
> syzbot found the following crash on:
>
> HEAD commit: a0c61bf1 Add linux-next specific files for 20200206
> git tree: linux-next
> console output: https://syzkaller.appspot.com/x/log.txt?x=13925e6ee00000
> kernel config: https://syzkaller.appspot.com/x/.config?x=7d320d6d9afdaecd
> dashboard link: https://syzkaller.appspot.com/bug?extid=c23efa0cc68e79d551fc
> compiler: gcc (GCC) 9.0.0 20181231 (experimental)
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1725bad9e00000
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=15ac3c5ee00000
>
> The bug was bisected to:
>
> commit 61dff92158775e70c0183f4f52c3a5a071dbc24b
> Author: Al Viro <viro@xxxxxxxxxxxxxxxxxx>
> Date: Tue Dec 17 19:15:04 2019 +0000
>
> Pass consistent param->type to fs_parse()
>
> bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=11fa020de00000
> final crash: https://syzkaller.appspot.com/x/report.txt?x=13fa020de00000
> console output: https://syzkaller.appspot.com/x/log.txt?x=15fa020de00000
>
> IMPORTANT: if you fix the bug, please add the following tag to the commit:
> Reported-by: syzbot+c23efa0cc68e79d551fc@xxxxxxxxxxxxxxxxxxxxxxxxx
> Fixes: 61dff9215877 ("Pass consistent param->type to fs_parse()")

Argh... OK, I see what's going on.

commit 296713d91a7df022b0edf20d55f83554b4f95ba1
Author: Al Viro <viro@xxxxxxxxxxxxxxxxxx>
Date: Fri Feb 7 00:02:11 2020 -0500

do not accept empty strings for fsparam_string()

Reported-by: syzbot+c23efa0cc68e79d551fc@xxxxxxxxxxxxxxxxxxxxxxxxx
Fixes: 61dff9215877 ("Pass consistent param->type to fs_parse()")

diff --git a/fs/fs_parser.c b/fs/fs_parser.c
index fdc047b804b2..7e6fb43f9541 100644
--- a/fs/fs_parser.c
+++ b/fs/fs_parser.c
@@ -256,7 +256,7 @@ EXPORT_SYMBOL(fs_param_is_enum);
int fs_param_is_string(struct p_log *log, const struct fs_parameter_spec *p,
struct fs_parameter *param, struct fs_parse_result *result)
{
- if (param->type != fs_value_is_string)
+ if (param->type != fs_value_is_string || !*param->string)
return fs_param_bad_value(log, param);
return 0;
}