* KASAN: null-ptr-deref Write in get_block
@ 2020-03-21 10:10 syzbot
2020-03-22 12:06 ` Qiujun Huang
0 siblings, 1 reply; 4+ messages in thread
From: syzbot @ 2020-03-21 10:10 UTC (permalink / raw)
To: aeb, danarag, kstewart, linux-kernel, syzkaller-bugs, tglx, viro
Hello,
syzbot found the following crash on:
HEAD commit: fb33c651 Linux 5.6-rc6
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=157d4b45e00000
kernel config: https://syzkaller.appspot.com/x/.config?x=9f894bd92023de02
dashboard link: https://syzkaller.appspot.com/bug?extid=4a88b2b9dc280f47baf4
compiler: gcc (GCC) 9.0.0 20181231 (experimental)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=127acd55e00000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=15f82345e00000
Bisection is inconclusive: the bug happens on the oldest tested release.
bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=10e8d8d3e00000
final crash: https://syzkaller.appspot.com/x/report.txt?x=12e8d8d3e00000
console output: https://syzkaller.appspot.com/x/log.txt?x=14e8d8d3e00000
IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+4a88b2b9dc280f47baf4@syzkaller.appspotmail.com
==================================================================
BUG: KASAN: null-ptr-deref in test_and_set_bit_lock include/asm-generic/bitops/instrumented-lock.h:55 [inline]
BUG: KASAN: null-ptr-deref in trylock_buffer include/linux/buffer_head.h:359 [inline]
BUG: KASAN: null-ptr-deref in lock_buffer include/linux/buffer_head.h:365 [inline]
BUG: KASAN: null-ptr-deref in alloc_branch fs/minix/itree_common.c:88 [inline]
BUG: KASAN: null-ptr-deref in get_block+0x657/0x1380 fs/minix/itree_common.c:191
Write of size 8 at addr 0000000000000000 by task syz-executor110/9537
CPU: 0 PID: 9537 Comm: syz-executor110 Not tainted 5.6.0-rc6-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0x188/0x20d lib/dump_stack.c:118
__kasan_report.cold+0x5/0x32 mm/kasan/report.c:510
kasan_report+0xe/0x20 mm/kasan/common.c:641
check_memory_region_inline mm/kasan/generic.c:185 [inline]
check_memory_region+0x128/0x190 mm/kasan/generic.c:192
test_and_set_bit_lock include/asm-generic/bitops/instrumented-lock.h:55 [inline]
trylock_buffer include/linux/buffer_head.h:359 [inline]
lock_buffer include/linux/buffer_head.h:365 [inline]
alloc_branch fs/minix/itree_common.c:88 [inline]
get_block+0x657/0x1380 fs/minix/itree_common.c:191
minix_get_block+0xe5/0x110 fs/minix/inode.c:376
__block_write_begin_int+0x490/0x1b00 fs/buffer.c:2008
__block_write_begin fs/buffer.c:2058 [inline]
block_write_begin+0x58/0x2e0 fs/buffer.c:2117
minix_write_begin+0x35/0xe0 fs/minix/inode.c:412
generic_perform_write+0x20a/0x4e0 mm/filemap.c:3287
__generic_file_write_iter+0x24c/0x610 mm/filemap.c:3416
generic_file_write_iter+0x3f0/0x62d mm/filemap.c:3448
call_write_iter include/linux/fs.h:1902 [inline]
new_sync_write+0x49c/0x700 fs/read_write.c:483
__vfs_write+0xc9/0x100 fs/read_write.c:496
vfs_write+0x262/0x5c0 fs/read_write.c:558
ksys_write+0x127/0x250 fs/read_write.c:611
do_syscall_64+0xf6/0x7d0 arch/x86/entry/common.c:294
entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x44b389
Code: fd ca fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 cb ca fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007f4e9f99ace8 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00000000006ddc38 RCX: 000000000044b389
RDX: 000000000000fdef RSI: 00000000200004c0 RDI: 0000000000000005
RBP: 00000000006ddc30 R08: 0000000000000012 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00000000006ddc3c
R13: 00007ffcd0e441ef R14: 00007f4e9f99b9c0 R15: 0000000000000001
==================================================================
---
This bug is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzkaller@googlegroups.com.
syzbot will keep track of this bug report. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
For information about bisection process see: https://goo.gl/tpsmEJ#bisection
syzbot can test patches for this bug, for details see:
https://goo.gl/tpsmEJ#testing-patches
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: KASAN: null-ptr-deref Write in get_block
2020-03-21 10:10 KASAN: null-ptr-deref Write in get_block syzbot
@ 2020-03-22 12:06 ` Qiujun Huang
2020-03-23 11:42 ` Dan Carpenter
0 siblings, 1 reply; 4+ messages in thread
From: Qiujun Huang @ 2020-03-22 12:06 UTC (permalink / raw)
To: syzbot; +Cc: aeb, danarag, kstewart, linux-kernel, syzkaller-bugs, tglx, viro
Need to check the return value of sb_getblk.
Signed-off-by: Qiujun Huang <hqjagain@gmail.com>
---
fs/minix/itree_common.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/minix/itree_common.c b/fs/minix/itree_common.c
index 043c3fd..eedd79f 100644
--- a/fs/minix/itree_common.c
+++ b/fs/minix/itree_common.c
@@ -85,6 +85,8 @@ static int alloc_branch(struct inode *inode,
break;
branch[n].key = cpu_to_block(nr);
bh = sb_getblk(inode->i_sb, parent);
+ if (!bh)
+ break;
lock_buffer(bh);
memset(bh->b_data, 0, bh->b_size);
branch[n].bh = bh;
--
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: KASAN: null-ptr-deref Write in get_block
2020-03-22 12:06 ` Qiujun Huang
@ 2020-03-23 11:42 ` Dan Carpenter
2020-03-23 12:18 ` Qiujun Huang
0 siblings, 1 reply; 4+ messages in thread
From: Dan Carpenter @ 2020-03-23 11:42 UTC (permalink / raw)
To: Qiujun Huang
Cc: syzbot, aeb, danarag, kstewart, linux-kernel, syzkaller-bugs, tglx, viro
Fix the subject to [PATCH] minix: Fix NULL dereference in alloc_branch()
On Sun, Mar 22, 2020 at 08:06:48PM +0800, Qiujun Huang wrote:
> Need to check the return value of sb_getblk.
>
Add a Reported-by tag.
Reported-by: syzbot+4a88b2b9dc280f47baf4@syzkaller.appspotmail.com
> Signed-off-by: Qiujun Huang <hqjagain@gmail.com>
> ---
> fs/minix/itree_common.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/fs/minix/itree_common.c b/fs/minix/itree_common.c
> index 043c3fd..eedd79f 100644
> --- a/fs/minix/itree_common.c
> +++ b/fs/minix/itree_common.c
> @@ -85,6 +85,8 @@ static int alloc_branch(struct inode *inode,
> break;
> branch[n].key = cpu_to_block(nr);
> bh = sb_getblk(inode->i_sb, parent);
> + if (!bh)
> + break;
The patch is white space damaged and we need to do a bit of error
handling before the break as well.
bh = sb_getblk(inode->i_sb, parent);
+ if (!bh) {
+ minix_free_block(inode, block_to_cpu(branch[n].key));
+ break;
+ }
lock_buffer(bh);
Please fix those few things and resend.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: KASAN: null-ptr-deref Write in get_block
2020-03-23 11:42 ` Dan Carpenter
@ 2020-03-23 12:18 ` Qiujun Huang
0 siblings, 0 replies; 4+ messages in thread
From: Qiujun Huang @ 2020-03-23 12:18 UTC (permalink / raw)
To: Dan Carpenter
Cc: syzbot, aeb, danarag, kstewart, linux-kernel, syzkaller-bugs,
tglx, viro, Qiujun Huang
On Mon, Mar 23, 2020 at 7:42 PM Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> Fix the subject to [PATCH] minix: Fix NULL dereference in alloc_branch()
>
> On Sun, Mar 22, 2020 at 08:06:48PM +0800, Qiujun Huang wrote:
> > Need to check the return value of sb_getblk.
> >
>
> Add a Reported-by tag.
>
> Reported-by: syzbot+4a88b2b9dc280f47baf4@syzkaller.appspotmail.com
>
> > Signed-off-by: Qiujun Huang <hqjagain@gmail.com>
> > ---
> > fs/minix/itree_common.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/fs/minix/itree_common.c b/fs/minix/itree_common.c
> > index 043c3fd..eedd79f 100644
> > --- a/fs/minix/itree_common.c
> > +++ b/fs/minix/itree_common.c
> > @@ -85,6 +85,8 @@ static int alloc_branch(struct inode *inode,
> > break;
> > branch[n].key = cpu_to_block(nr);
> > bh = sb_getblk(inode->i_sb, parent);
> > + if (!bh)
> > + break;
>
> The patch is white space damaged and we need to do a bit of error
> handling before the break as well.
I get it, thanks.
>
> bh = sb_getblk(inode->i_sb, parent);
> + if (!bh) {
> + minix_free_block(inode, block_to_cpu(branch[n].key));
> + break;
> + }
> lock_buffer(bh);
>
> Please fix those few things and resend.
>
> regards,
> dan carpenter
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-03-23 12:18 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-21 10:10 KASAN: null-ptr-deref Write in get_block syzbot
2020-03-22 12:06 ` Qiujun Huang
2020-03-23 11:42 ` Dan Carpenter
2020-03-23 12:18 ` Qiujun Huang
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.