linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Yury Norov <yury.norov@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: syzbot <syzbot+08ca1fa706a22cc17efe@syzkaller.appspotmail.com>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	linux-next@vger.kernel.org, sfr@canb.auug.org.au,
	syzkaller-bugs@googlegroups.com,
	Andrey Ryabinin <ryabinin.a.a@gmail.com>,
	Alexander Potapenko <glider@google.com>,
	Andrey Konovalov <andreyknvl@gmail.com>,
	Dmitry Vyukov <dvyukov@google.com>,
	Vincenzo Frascino <vincenzo.frascino@arm.com>
Subject: Re: [syzbot] linux-next boot error: KASAN: slab-out-of-bounds Read in _find_next_bit
Date: Tue, 6 Sep 2022 17:45:07 -0700	[thread overview]
Message-ID: <YxfpkzZhJ7GfRuKd@yury-laptop> (raw)
In-Reply-To: <20220906173154.6f2664c8fc6b83470c5dfea1@linux-foundation.org>

On Tue, Sep 06, 2022 at 05:31:54PM -0700, Andrew Morton wrote:
> (cc Yury and KASAN developers)
> 
> On Tue, 06 Sep 2022 06:21:39 -0700 syzbot <syzbot+08ca1fa706a22cc17efe@syzkaller.appspotmail.com> wrote:
> 
> > Hello,
> > 
> > syzbot found the following issue on:
> > 
> > HEAD commit:    840126e36e8f Add linux-next specific files for 20220906
> > git tree:       linux-next
> > console output: https://syzkaller.appspot.com/x/log.txt?x=1216969b080000
> > kernel config:  https://syzkaller.appspot.com/x/.config?x=239c4c4e44185526
> > dashboard link: https://syzkaller.appspot.com/bug?extid=08ca1fa706a22cc17efe
> > compiler:       gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
> > 
> > Downloadable assets:
> > disk image: https://storage.googleapis.com/syzbot-assets/1b9017e387a8/disk-840126e3.raw.xz
> > vmlinux: https://storage.googleapis.com/syzbot-assets/12182558f88d/vmlinux-840126e3.xz
> > 
> > IMPORTANT: if you fix the issue, please add the following tag to the commit:
> > Reported-by: syzbot+08ca1fa706a22cc17efe@syzkaller.appspotmail.com
> > 
> > ==================================================================
> > BUG: KASAN: slab-out-of-bounds in _find_next_bit+0x143/0x160 lib/find_bit.c:109
> 
> Presumably the for_each_clear_bitrange() in pcpu_balance_populated().
> 
> > Read of size 8 at addr ffff8880175766b8 by task kworker/1:1/26
> 
> An eight byte read...
> 
> > CPU: 1 PID: 26 Comm: kworker/1:1 Not tainted 6.0.0-rc4-next-20220906-syzkaller #0
> > Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/26/2022
> > Workqueue: events pcpu_balance_workfn
> > Call Trace:
> >  <TASK>
> >  __dump_stack lib/dump_stack.c:88 [inline]
> >  dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
> >  print_address_description mm/kasan/report.c:287 [inline]
> >  print_report+0x164/0x463 mm/kasan/report.c:398
> >  kasan_report+0xbb/0x1f0 mm/kasan/report.c:486
> >  _find_next_bit+0x143/0x160 lib/find_bit.c:109
> >  find_next_bit include/linux/find.h:55 [inline]
> >  pcpu_balance_populated mm/percpu.c:2086 [inline]
> >  pcpu_balance_workfn+0x6c0/0xea0 mm/percpu.c:2246
> >  process_one_work+0x991/0x1610 kernel/workqueue.c:2289
> >  worker_thread+0x665/0x1080 kernel/workqueue.c:2436
> >  kthread+0x2e4/0x3a0 kernel/kthread.c:376
> >  ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306
> >  </TASK>
> > 
> > Allocated by task 26:
> >  kasan_save_stack+0x1e/0x40 mm/kasan/common.c:45
> >  kasan_set_track+0x21/0x30 mm/kasan/common.c:52
> >  ____kasan_kmalloc mm/kasan/common.c:371 [inline]
> >  ____kasan_kmalloc mm/kasan/common.c:330 [inline]
> >  __kasan_kmalloc+0xa1/0xb0 mm/kasan/common.c:380
> >  kasan_kmalloc include/linux/kasan.h:211 [inline]
> >  __do_kmalloc_node mm/slab_common.c:931 [inline]
> >  __kmalloc+0x54/0xc0 mm/slab_common.c:944
> >  kmalloc include/linux/slab.h:565 [inline]
> >  kzalloc include/linux/slab.h:696 [inline]
> >  pcpu_mem_zalloc+0x70/0xa0 mm/percpu.c:514
> >  pcpu_alloc_chunk mm/percpu.c:1446 [inline]
> >  pcpu_create_chunk+0x23/0x930 mm/percpu-vm.c:338
> >  pcpu_balance_populated mm/percpu.c:2108 [inline]
> >  pcpu_balance_workfn+0xc4e/0xea0 mm/percpu.c:2246
> >  process_one_work+0x991/0x1610 kernel/workqueue.c:2289
> >  worker_thread+0x665/0x1080 kernel/workqueue.c:2436
> >  kthread+0x2e4/0x3a0 kernel/kthread.c:376
> >  ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306
> > 
> > The buggy address belongs to the object at ffff888017576600
> >  which belongs to the cache kmalloc-192 of size 192
> > The buggy address is located 184 bytes inside of
> >  192-byte region [ffff888017576600, ffff8880175766c0)
> 
> At offset 184 of a 192-byte region.
> 
> So what's wrong with doing that?  Does KASAN have an off-by-one?

Hi Andrew, all,

This is a bug in FIND_NEXT_BIT(). It should be 
  if (idx >= sz / BITS_PER_LONG)                                   \
          goto out;                                                \

instead of 
  if (idx > sz / BITS_PER_LONG)                                    \
          goto out;                                                \

The fix is in bitmap-for-next, expected to be in -next by tomorrow.
Sorry for the noise.

Thanks,
Yury


  reply	other threads:[~2022-09-07  0:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-06 13:21 [syzbot] linux-next boot error: KASAN: slab-out-of-bounds Read in _find_next_bit syzbot
2022-09-07  0:31 ` Andrew Morton
2022-09-07  0:45   ` Yury Norov [this message]
2022-09-07  5:53     ` Andrew Morton
2022-09-07  7:17       ` Dmitry Vyukov

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=YxfpkzZhJ7GfRuKd@yury-laptop \
    --to=yury.norov@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=andreyknvl@gmail.com \
    --cc=dvyukov@google.com \
    --cc=glider@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-next@vger.kernel.org \
    --cc=ryabinin.a.a@gmail.com \
    --cc=sfr@canb.auug.org.au \
    --cc=syzbot+08ca1fa706a22cc17efe@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    --cc=vincenzo.frascino@arm.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).