On Thu, Apr 19, 2018 at 10:17:57AM +0800, Fengguang Wu wrote: >Hello, > >FYI this happens in mainline kernel 4.17.0-rc1. >It at least dates back to v4.15-rc1 . > >The regression was reported before > > https://lkml.org/lkml/2017/11/30/33 > >Where the last message from Dmitry mentions that use-after-scope has >known false positives with CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL=y >If so, what would be the best way to workaround such false positives >in boot testing? Disable the above config? > >0day bisects produce diverged results, with 2 of them converge to >commit d17a1d97dc ("x86/mm/kasan: don't use vmemmap_populate() to >initialize shadow") and 1 bisected to the earlier a4a3ede213 ("mm: >zero reserved and unavailable struct pages"). I'll send the bisect >reports in follow up emails. Here is the bisect report for commit d17a1d97dc208d664c91cc387ffb752c7f85dc61 Author: Andrey Ryabinin AuthorDate: Wed Nov 15 17:36:35 2017 -0800 Commit: Linus Torvalds CommitDate: Wed Nov 15 18:21:05 2017 -0800 x86/mm/kasan: don't use vmemmap_populate() to initialize shadow The kasan shadow is currently mapped using vmemmap_populate() since that provides a semi-convenient way to map pages into init_top_pgt. However, since that no longer zeroes the mapped pages, it is not suitable for kasan, which requires zeroed shadow memory. Add kasan_populate_shadow() interface and use it instead of vmemmap_populate(). Besides, this allows us to take advantage of gigantic pages and use them to populate the shadow, which should save us some memory wasted on page tables and reduce TLB pressure. Link: http://lkml.kernel.org/r/20171103185147.2688-2-pasha.tatashin@oracle.com Signed-off-by: Andrey Ryabinin Signed-off-by: Pavel Tatashin Cc: Steven Sistare Cc: Daniel Jordan Cc: Bob Picco Cc: Michal Hocko Cc: Alexander Potapenko Cc: Ard Biesheuvel Cc: Catalin Marinas Cc: Christian Borntraeger Cc: David S. Miller Cc: Dmitry Vyukov Cc: Heiko Carstens Cc: "H. Peter Anvin" Cc: Ingo Molnar Cc: Mark Rutland Cc: Matthew Wilcox Cc: Mel Gorman Cc: Michal Hocko Cc: Sam Ravnborg Cc: Thomas Gleixner Cc: Will Deacon Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds a4a3ede213 mm: zero reserved and unavailable struct pages d17a1d97dc x86/mm/kasan: don't use vmemmap_populate() to initialize shadow d6bbd51587 Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace 73005e1a35 Add linux-next specific files for 20180103 +--------------------------------+------------+------------+------------+---------------+ | | a4a3ede213 | d17a1d97dc | d6bbd51587 | next-20180103 | +--------------------------------+------------+------------+------------+---------------+ | boot_successes | 35 | 0 | 0 | 10 | | boot_failures | 0 | 15 | 17 | | | BUG:KASAN:use-after-scope_in_c | 0 | 15 | 17 | | +--------------------------------+------------+------------+------------+---------------+ [ 0.004000] Tasks RCU enabled. [ 0.004000] RCU: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=2 [ 0.004000] NR_IRQS: 4352, nr_irqs: 440, preallocated irqs: 16 [ 0.004000] Offload RCU callbacks from CPUs: . [ 0.004000] ================================================================== [ 0.004000] BUG: KASAN: use-after-scope in console_unlock+0x516/0x7bf [ 0.004000] Write of size 4 at addr ffffffffaf207aa0 by task swapper/0 [ 0.004000] [ 0.004000] CPU: 0 PID: 0 Comm: swapper Not tainted 4.14.0-04319-gd17a1d9 #2 [ 0.004000] Call Trace: [ 0.004000] ? dump_stack+0xd1/0x178 [ 0.004000] ? _atomic_dec_and_lock+0x11a/0x11a [ 0.004000] ? show_regs_print_info+0x51/0x51 [ 0.004000] ? do_raw_spin_unlock+0x223/0x247 [ 0.004000] ? print_address_description+0x94/0x2d9 [ 0.004000] ? console_unlock+0x516/0x7bf [ 0.004000] ? kasan_report+0x21e/0x244 [ 0.004000] ? console_unlock+0x516/0x7bf [ 0.004000] ? wake_up_klogd+0xe6/0xe6 [ 0.004000] ? vprintk_emit+0x3ee/0x426 [ 0.004000] ? __down_trylock_console_sem+0x5d/0x6c [ 0.004000] ? vprintk_emit+0x3f7/0x426 [ 0.004000] ? console_unlock+0x7bf/0x7bf [ 0.004000] ? memblock_virt_alloc_try_nid+0xd9/0x107 [ 0.004000] ? zero_pud_populate+0x7f1/0x8e8 [ 0.004000] ? printk+0x8f/0xab [ 0.004000] ? show_regs_print_info+0x51/0x51 [ 0.004000] ? native_flush_tlb_global+0x71/0x7d [ 0.004000] ? setup_arch+0x2427/0x2770 [ 0.004000] ? reserve_standard_io_resources+0x83/0x83 [ 0.004000] ? debug_check_no_locks_freed+0x20b/0x21a [ 0.004000] ? __lockdep_init_map+0x20f/0x4d5 [ 0.004000] ? printk+0x8f/0xab [ 0.004000] ? show_regs_print_info+0x51/0x51 [ 0.004000] ? cgroup_init_early+0xad/0x16e [ 0.004000] ? do_device_not_available+0x4f/0x4f [ 0.004000] ? start_kernel+0xe1/0x10ce [ 0.004000] ? early_idt_handler_common+0x3b/0x60 [ 0.004000] ? thread_stack_cache_init+0x2e/0x2e [ 0.004000] ? memcpy_orig+0x16/0x110 [ 0.004000] ? load_ucode_bsp+0x69/0x2fe [ 0.004000] ? secondary_startup_64+0xa5/0xb0 [ 0.004000] [ 0.004000] Memory state around the buggy address: [ 0.004000] ffffffffaf207980: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 0.004000] ffffffffaf207a00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 0.004000] >ffffffffaf207a80: f1 f1 f1 f1 f8 f2 f2 f2 f2 f2 f2 f2 00 f2 f2 f2 # HH:MM RESULT GOOD BAD GOOD_BUT_DIRTY DIRTY_NOT_BAD git bisect start 30a7acd573899fd8b8ac39236eff6468b195ac7d v4.14 -- git bisect bad 4fbd8d194f06c8a3fd2af1ce560ddb31f7ec8323 # 02:00 B 0 11 25 0 Linux 4.15-rc1 git bisect bad 93ea0eb7d77afab34657715630d692a78b8cea6a # 02:21 B 0 11 25 0 Merge tag 'leaks-4.15-rc1' of git://github.com/tcharding/linux git bisect good 32190f0afbf4f1c0a9142e5a886a078ee0b794fd # 02:39 G 11 0 0 0 Merge tag 'fscrypt-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/fscrypt git bisect good 37cb8e1f8e10c6e9bd2a1b95cdda0620a21b0551 # 02:52 G 11 0 0 0 Merge tag 'devicetree-for-4.15' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux git bisect good 6c4ba00c40d5acb17f32d4b7e02dbcd21f336d9f # 03:10 G 11 0 0 0 Merge tag 'hsi-for-4.15' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-hsi git bisect good 766ec76a27aa9dfdfee3a80f29ddc1f7539c71f9 # 03:30 G 11 0 0 0 Merge branch 'for-4.15' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/percpu git bisect good 1b6115fbe3b3db746d7baa11399dd617fc75e1c4 # 03:54 G 11 0 0 0 Merge tag 'pci-v4.15-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci git bisect good 6363b3f3ac5be096d08c8c504128befa0c033529 # 04:09 G 11 0 0 0 Merge tag 'ipmi-for-4.15' of git://github.com/cminyard/linux-ipmi git bisect bad 7c225c69f86c934e3be9be63ecde754e286838d7 # 04:25 B 0 1 15 0 Merge branch 'akpm' (patches from Andrew) git bisect good 4be90299a1693c2112edb20ca78d6cc9f2183326 # 04:47 G 11 0 0 0 ceph: use pagevec_lookup_range_nr_tag() git bisect bad 76253fbc8fbf6018401755fc5c07814a837cc832 # 05:07 B 0 2 16 0 mm: move accounting updates before page_cache_tree_delete() git bisect good 353b1e7b5859e98860f984d8894fa7ddc242a90e # 05:29 G 11 0 0 0 x86/mm: set fields in deferred pages git bisect bad 78c943662f4b1d53ddbfc515e427827915781377 # 05:51 B 0 3 17 0 sparc64: optimize struct page zeroing git bisect good a4a3ede2132ae0863e2d43e06f9b5697c51a7a3b # 06:16 G 11 0 0 0 mm: zero reserved and unavailable struct pages git bisect bad e17d8025f07e4fd9d73b137a8bcab04548126b83 # 06:29 B 0 10 24 0 arm64/mm/kasan: don't use vmemmap_populate() to initialize shadow git bisect bad d17a1d97dc208d664c91cc387ffb752c7f85dc61 # 06:42 B 0 5 19 0 x86/mm/kasan: don't use vmemmap_populate() to initialize shadow # first bad commit: [d17a1d97dc208d664c91cc387ffb752c7f85dc61] x86/mm/kasan: don't use vmemmap_populate() to initialize shadow git bisect good a4a3ede2132ae0863e2d43e06f9b5697c51a7a3b # 06:51 G 31 0 0 0 mm: zero reserved and unavailable struct pages # extra tests with debug options git bisect bad d17a1d97dc208d664c91cc387ffb752c7f85dc61 # 07:06 B 0 10 24 0 x86/mm/kasan: don't use vmemmap_populate() to initialize shadow # extra tests on HEAD of linux-devel/devel-hourly-2018010321 git bisect bad d23305f3c66383c30bc6a65b33dbdde7cabcf2e1 # 07:07 B 0 13 30 0 0day head guard for 'devel-hourly-2018010321' # extra tests on tree/branch linus/master git bisect bad d6bbd51587ecd173958453969964fb41140b1540 # 07:25 B 0 6 20 0 Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace # extra tests on tree/branch linux-next/master git bisect good 73005e1a35fd67c644b0645c9e4c1efabd0fe62c # 07:48 G 11 0 1 1 Add linux-next specific files for 20180103 --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/lkp Intel Corporation