bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* KASAN: slab-out-of-bounds Read in cgroup_file_notify
@ 2020-03-10 15:55 syzbot
  2020-03-12 18:28 ` Tejun Heo
  0 siblings, 1 reply; 4+ messages in thread
From: syzbot @ 2020-03-10 15:55 UTC (permalink / raw)
  To: akpm, almasrymina, andriin, ast, bpf, cgroups, christian, daniel,
	hannes, kafai, linux-kernel, lizefan, netdev, sfr,
	songliubraving, syzkaller-bugs, tj, yhs

Hello,

syzbot found the following crash on:

HEAD commit:    c99b17ac Add linux-next specific files for 20200225
git tree:       linux-next
console output: https://syzkaller.appspot.com/x/log.txt?x=1610d70de00000
kernel config:  https://syzkaller.appspot.com/x/.config?x=6b7ebe4bd0931c45
dashboard link: https://syzkaller.appspot.com/bug?extid=cac0c4e204952cf449b1
compiler:       gcc (GCC) 9.0.0 20181231 (experimental)
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=1242e1fde00000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=1110d70de00000

The bug was bisected to:

commit 6863de00e5400b534cd4e3869ffbc8f94da41dfc
Author: Mina Almasry <almasrymina@google.com>
Date:   Thu Feb 20 03:55:30 2020 +0000

    hugetlb_cgroup: add accounting for shared mappings

bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=12a17f0de00000
final crash:    https://syzkaller.appspot.com/x/report.txt?x=11a17f0de00000
console output: https://syzkaller.appspot.com/x/log.txt?x=16a17f0de00000

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+cac0c4e204952cf449b1@syzkaller.appspotmail.com
Fixes: 6863de00e540 ("hugetlb_cgroup: add accounting for shared mappings")

==================================================================
BUG: KASAN: slab-out-of-bounds in cgroup_file_notify+0x16a/0x1b0 kernel/cgroup/cgroup.c:4084
Read of size 8 at addr ffff88821b77c4c8 by task syz-executor540/9589

CPU: 0 PID: 9589 Comm: syz-executor540 Not tainted 5.6.0-rc3-next-20200225-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+0x197/0x210 lib/dump_stack.c:118
 print_address_description.constprop.0.cold+0xd4/0x30b mm/kasan/report.c:374
 __kasan_report.cold+0x1b/0x32 mm/kasan/report.c:506
 kasan_report+0x12/0x20 mm/kasan/common.c:641
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/generic_report.c:135
 cgroup_file_notify+0x16a/0x1b0 kernel/cgroup/cgroup.c:4084
 hugetlb_event mm/hugetlb_cgroup.c:224 [inline]
 __hugetlb_cgroup_charge_cgroup+0x88c/0xf10 mm/hugetlb_cgroup.c:262
 hugetlb_cgroup_charge_cgroup_rsvd+0x2b/0x40 mm/hugetlb_cgroup.c:286
 hugetlb_reserve_pages+0x2c2/0xce0 mm/hugetlb.c:4891
 hugetlb_file_setup+0x26a/0x671 fs/hugetlbfs/inode.c:1423
 newseg+0x4a3/0xf40 ipc/shm.c:652
 ipcget_new ipc/util.c:344 [inline]
 ipcget+0x105/0xd40 ipc/util.c:643
 ksys_shmget ipc/shm.c:742 [inline]
 __do_sys_shmget ipc/shm.c:747 [inline]
 __se_sys_shmget ipc/shm.c:745 [inline]
 __x64_sys_shmget+0x146/0x1d0 ipc/shm.c:745
 do_syscall_64+0xfa/0x790 arch/x86/entry/common.c:295
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x440119
Code: 18 89 d0 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 00 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 fb 13 fc ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007ffd5e1db3e8 EFLAGS: 00000246 ORIG_RAX: 000000000000001d
RAX: ffffffffffffffda RBX: 00000000004002c8 RCX: 0000000000440119
RDX: 0000000000004800 RSI: fffffffffeffffff RDI: 0000000000000000
RBP: 00000000006ca018 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000020ffc000 R11: 0000000000000246 R12: 00000000004019a0
R13: 0000000000401a30 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 0:
 save_stack+0x23/0x90 mm/kasan/common.c:72
 set_track mm/kasan/common.c:80 [inline]
 __kasan_kmalloc mm/kasan/common.c:515 [inline]
 __kasan_kmalloc.constprop.0+0xcf/0xe0 mm/kasan/common.c:488
 kasan_kmalloc+0x9/0x10 mm/kasan/common.c:529
 kmem_cache_alloc_trace+0x158/0x790 mm/slab.c:3551
 kmalloc include/linux/slab.h:555 [inline]
 kzalloc include/linux/slab.h:669 [inline]
 hugetlb_cgroup_css_alloc+0x4f/0x320 mm/hugetlb_cgroup.c:138
 cgroup_init_subsys+0x1d9/0x4a7 kernel/cgroup/cgroup.c:5582
 cgroup_init+0x34a/0xa4c kernel/cgroup/cgroup.c:5708
 start_kernel+0xe2d/0xe8f init/main.c:987
 x86_64_start_reservations+0x29/0x2b arch/x86/kernel/head64.c:490
 x86_64_start_kernel+0x77/0x7b arch/x86/kernel/head64.c:471
 secondary_startup_64+0xa4/0xb0 arch/x86/kernel/head_64.S:242

Freed by task 0:
(stack is not available)

The buggy address belongs to the object at ffff88821b77c000
 which belongs to the cache kmalloc-2k of size 2048
The buggy address is located 1224 bytes inside of
 2048-byte region [ffff88821b77c000, ffff88821b77c800)
The buggy address belongs to the page:
page:ffffea00086ddf00 refcount:1 mapcount:0 mapping:000000005a8512d0 index:0x0
flags: 0x57ffe0000000200(slab)
raw: 057ffe0000000200 ffffea00086dde48 ffffea00086ddf88 ffff8880aa400e00
raw: 0000000000000000 ffff88821b77c000 0000000100000001 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff88821b77c380: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff88821b77c400: 00 00 00 00 00 00 00 00 00 00 fc fc fc fc fc fc
>ffff88821b77c480: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
                                              ^
 ffff88821b77c500: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff88821b77c580: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================


---
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: slab-out-of-bounds Read in cgroup_file_notify
  2020-03-10 15:55 KASAN: slab-out-of-bounds Read in cgroup_file_notify syzbot
@ 2020-03-12 18:28 ` Tejun Heo
  2020-03-12 21:06   ` Mina Almasry
  0 siblings, 1 reply; 4+ messages in thread
From: Tejun Heo @ 2020-03-12 18:28 UTC (permalink / raw)
  To: almasrymina, syzbot
  Cc: akpm, andriin, ast, bpf, cgroups, christian, daniel, hannes,
	kafai, linux-kernel, lizefan, netdev, sfr, songliubraving,
	syzkaller-bugs, yhs

On Tue, Mar 10, 2020 at 08:55:14AM -0700, syzbot wrote:
> Hello,
> 
> syzbot found the following crash on:
> 
> HEAD commit:    c99b17ac Add linux-next specific files for 20200225
> git tree:       linux-next
> console output: https://syzkaller.appspot.com/x/log.txt?x=1610d70de00000
> kernel config:  https://syzkaller.appspot.com/x/.config?x=6b7ebe4bd0931c45
> dashboard link: https://syzkaller.appspot.com/bug?extid=cac0c4e204952cf449b1
> compiler:       gcc (GCC) 9.0.0 20181231 (experimental)
> syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=1242e1fde00000
> C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=1110d70de00000
> 
> The bug was bisected to:
> 
> commit 6863de00e5400b534cd4e3869ffbc8f94da41dfc
> Author: Mina Almasry <almasrymina@google.com>
> Date:   Thu Feb 20 03:55:30 2020 +0000
> 
>     hugetlb_cgroup: add accounting for shared mappings

Mina, can you please take a look at this?

Thanks.

-- 
tejun

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

* Re: KASAN: slab-out-of-bounds Read in cgroup_file_notify
  2020-03-12 18:28 ` Tejun Heo
@ 2020-03-12 21:06   ` Mina Almasry
  2020-03-13 22:43     ` Mina Almasry
  0 siblings, 1 reply; 4+ messages in thread
From: Mina Almasry @ 2020-03-12 21:06 UTC (permalink / raw)
  To: Tejun Heo
  Cc: syzbot, Andrew Morton, andriin, ast, bpf, cgroups, christian,
	daniel, Johannes Weiner, kafai, open list, Li Zefan, netdev, sfr,
	songliubraving, syzkaller-bugs, yhs

On Thu, Mar 12, 2020 at 11:28 AM Tejun Heo <tj@kernel.org> wrote:
>
> On Tue, Mar 10, 2020 at 08:55:14AM -0700, syzbot wrote:
> > Hello,
> >
> > syzbot found the following crash on:
> >
> > HEAD commit:    c99b17ac Add linux-next specific files for 20200225
> > git tree:       linux-next
> > console output: https://syzkaller.appspot.com/x/log.txt?x=1610d70de00000
> > kernel config:  https://syzkaller.appspot.com/x/.config?x=6b7ebe4bd0931c45
> > dashboard link: https://syzkaller.appspot.com/bug?extid=cac0c4e204952cf449b1
> > compiler:       gcc (GCC) 9.0.0 20181231 (experimental)
> > syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=1242e1fde00000
> > C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=1110d70de00000
> >
> > The bug was bisected to:
> >
> > commit 6863de00e5400b534cd4e3869ffbc8f94da41dfc
> > Author: Mina Almasry <almasrymina@google.com>
> > Date:   Thu Feb 20 03:55:30 2020 +0000
> >
> >     hugetlb_cgroup: add accounting for shared mappings
>
> Mina, can you please take a look at this?
>

Gah, I missed the original syzbot email but I just saw this. I'll take a look.

> Thanks.

>
> --
> tejun

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

* Re: KASAN: slab-out-of-bounds Read in cgroup_file_notify
  2020-03-12 21:06   ` Mina Almasry
@ 2020-03-13 22:43     ` Mina Almasry
  0 siblings, 0 replies; 4+ messages in thread
From: Mina Almasry @ 2020-03-13 22:43 UTC (permalink / raw)
  To: Tejun Heo, Giuseppe Scrivano
  Cc: syzbot, Andrew Morton, andriin, ast, bpf, cgroups, christian,
	daniel, Johannes Weiner, kafai, open list, Li Zefan, netdev, sfr,
	songliubraving, syzkaller-bugs, yhs

On Thu, Mar 12, 2020 at 2:06 PM Mina Almasry <almasrymina@google.com> wrote:
>
> On Thu, Mar 12, 2020 at 11:28 AM Tejun Heo <tj@kernel.org> wrote:
> >
> > On Tue, Mar 10, 2020 at 08:55:14AM -0700, syzbot wrote:
> > > Hello,
> > >
> > > syzbot found the following crash on:
> > >
> > > HEAD commit:    c99b17ac Add linux-next specific files for 20200225
> > > git tree:       linux-next
> > > console output: https://syzkaller.appspot.com/x/log.txt?x=1610d70de00000
> > > kernel config:  https://syzkaller.appspot.com/x/.config?x=6b7ebe4bd0931c45
> > > dashboard link: https://syzkaller.appspot.com/bug?extid=cac0c4e204952cf449b1
> > > compiler:       gcc (GCC) 9.0.0 20181231 (experimental)
> > > syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=1242e1fde00000
> > > C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=1110d70de00000
> > >
> > > The bug was bisected to:
> > >
> > > commit 6863de00e5400b534cd4e3869ffbc8f94da41dfc
> > > Author: Mina Almasry <almasrymina@google.com>
> > > Date:   Thu Feb 20 03:55:30 2020 +0000
> > >
> > >     hugetlb_cgroup: add accounting for shared mappings
> >
> > Mina, can you please take a look at this?
> >
>
> Gah, I missed the original syzbot email but I just saw this. I'll take a look.
>

This was easy enough to track down, I just sent out a fix:
https://lore.kernel.org/linux-mm/20200313223920.124230-1-almasrymina@google.com

BTW, even though this was bisected to my patch, the root cause seems
to be a mistake in commit faced7e0806cf ("mm: hugetlb controller for
cgroups v2"), which is not only in linux-next but also in linus's tree
(I did not check if it's in stable). If my fix is reviewed, the patch
should be sent there as well. I'll make the same comment on the above
thread as well.

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

end of thread, other threads:[~2020-03-13 22:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-10 15:55 KASAN: slab-out-of-bounds Read in cgroup_file_notify syzbot
2020-03-12 18:28 ` Tejun Heo
2020-03-12 21:06   ` Mina Almasry
2020-03-13 22:43     ` Mina Almasry

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