Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp92819pxa; Tue, 18 Aug 2020 17:05:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzeoX5SSLvPhGaqdmZY37ntMBdF5VVBmyPq1BRZ2JBKp5Z64g5ojZASHDvszuxnoqmqZEMu X-Received: by 2002:a17:906:2e86:: with SMTP id o6mr23523091eji.380.1597795525730; Tue, 18 Aug 2020 17:05:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597795525; cv=none; d=google.com; s=arc-20160816; b=lialauhhMuwE7uMssvOjOEuopD7RNiOEbV80ZedfU+wYbpNkk07zOVgA4x8K72VMCy AUFN2IY3Kt7C8RWv7t2UUQvhMgcm8KzdPswdpGFAf8oGfist16o5CctpU55wXhUxJWfc Vz/pB1zPzoOmTPx6V81cSCo836tRvEv4ECkbcVuwD2WL35B6YBLet1/Cb01ogrmVG+lw feM7w397YGOR3oONPhx/146U7Wb20DDndDzVfkLG2CqCVp7N219JiIDomOpLE4OsHgr5 yvRugTvGoLIM8IxbKfi1Gm9Buqw6M4BjFdjePJp7X4kWAEby/ndnRwBOF0xenY7mP0sp Atqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=C1HlQlbe82km06uFdCT/8yoL0tXy/gGN/wv7buOl/fk=; b=1J2TIlHJMs5rL+c/45aXfBXzPIVhqizWKhEb4q7I6vnHNYwin+oFgTEA7fCelFMzi1 YrT2wB6BiOrLZDyUy7NBIjPBzsGfRgD9miWCJIDYFc0hQMHzFMXqvEP1yoOod58zEnZT JFeCcMBpRmt4r+VO1z+G8XC0HVoeUFGuS8RrHkNNIw3NZk+C0tl0MeaSakcIZW7AHq+M 8bLn/T1rl/6wjIYCntTZ5VXE02meKNUj4WzC2jlR+hDucit7PuEgE0MDMZRoXEO85BDu n8JvZRq8TDK6NrlTU4M6s7kLG+VViWnmRr5XEbrRnqhPTFrIHFBTRk2s3/iGOHRAksuL cS8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GlNQS6xP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e17si14090417ejx.211.2020.08.18.17.04.58; Tue, 18 Aug 2020 17:05:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GlNQS6xP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726934AbgHRXS6 (ORCPT + 99 others); Tue, 18 Aug 2020 19:18:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:42680 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725554AbgHRXS6 (ORCPT ); Tue, 18 Aug 2020 19:18:58 -0400 Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E8F2620772; Tue, 18 Aug 2020 23:18:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597792737; bh=NvMRY2SO7jZz4Dg47GpkDTTV8NX9Vqc1LIgNUrQe3Ws=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=GlNQS6xP34KpFb3TPrqMJ5Ri9jHXJPpVuSDrj2BT5fMhiVHuKDSgbSITKE63NZJyT 2lqasTaDh3BAKfkys1gYTaFFWdMI2EWCKOMaHZolhhkbkvJisfXF0+Yle8pbvYSUY1 u8qs6fikAlOhLN48SnF9F+IpmaJmbjvzIhz2K/Xk= Date: Tue, 18 Aug 2020 16:18:56 -0700 From: Andrew Morton To: syzbot Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, syzkaller-bugs@googlegroups.com, Johannes Weiner , Michal Hocko Subject: Re: KASAN: use-after-free Write in page_counter_uncharge Message-Id: <20200818161856.d18df24b5d10fc727ead846f@linux-foundation.org> In-Reply-To: <00000000000014822b05ad2802a7@google.com> References: <00000000000014822b05ad2802a7@google.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 18 Aug 2020 07:50:28 -0700 syzbot wrote: > Hello, > > syzbot found the following issue on: > > HEAD commit: a1d21081 Merge git://git.kernel.org/pub/scm/linux/kernel/g.. > git tree: upstream > console output: https://syzkaller.appspot.com/x/log.txt?x=17ceb0ce900000 > kernel config: https://syzkaller.appspot.com/x/.config?x=21f0d1d2df6d5fc > dashboard link: https://syzkaller.appspot.com/bug?extid=b305848212deec86eabe > compiler: clang version 10.0.0 (https://github.com/llvm/llvm-project/ c2443155a0fb245c8f17f2c1c72b6ea391e86e81) Presumably this is the same as http://lkml.kernel.org/r/00000000000011710f05ad27fe8a@google.com. > Unfortunately, I don't have any reproducer for this issue yet. > > IMPORTANT: if you fix the issue, please add the following tag to the commit: > Reported-by: syzbot+b305848212deec86eabe@syzkaller.appspotmail.com > > ================================================================== > BUG: KASAN: use-after-free in instrument_atomic_write include/linux/instrumented.h:71 [inline] > BUG: KASAN: use-after-free in atomic64_sub_return include/asm-generic/atomic-instrumented.h:970 [inline] > BUG: KASAN: use-after-free in atomic_long_sub_return include/asm-generic/atomic-long.h:113 [inline] > BUG: KASAN: use-after-free in page_counter_cancel mm/page_counter.c:54 [inline] > BUG: KASAN: use-after-free in page_counter_uncharge+0x3d/0xc0 mm/page_counter.c:155 > Write of size 8 at addr ffff8880371c0148 by task syz-executor.0/9304 > > CPU: 0 PID: 9304 Comm: syz-executor.0 Not tainted 5.8.0-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+0x1f0/0x31e lib/dump_stack.c:118 > print_address_description+0x66/0x620 mm/kasan/report.c:383 > __kasan_report mm/kasan/report.c:513 [inline] > kasan_report+0x132/0x1d0 mm/kasan/report.c:530 > check_memory_region_inline mm/kasan/generic.c:183 [inline] > check_memory_region+0x2b5/0x2f0 mm/kasan/generic.c:192 > instrument_atomic_write include/linux/instrumented.h:71 [inline] > atomic64_sub_return include/asm-generic/atomic-instrumented.h:970 [inline] > atomic_long_sub_return include/asm-generic/atomic-long.h:113 [inline] > page_counter_cancel mm/page_counter.c:54 [inline] > page_counter_uncharge+0x3d/0xc0 mm/page_counter.c:155 > uncharge_batch+0x6c/0x350 mm/memcontrol.c:6764 > uncharge_page+0x115/0x430 mm/memcontrol.c:6796 > uncharge_list mm/memcontrol.c:6835 [inline] > mem_cgroup_uncharge_list+0x70/0xe0 mm/memcontrol.c:6877 > release_pages+0x13a2/0x1550 mm/swap.c:911 > tlb_batch_pages_flush mm/mmu_gather.c:49 [inline] > tlb_flush_mmu_free mm/mmu_gather.c:242 [inline] > tlb_flush_mmu+0x780/0x910 mm/mmu_gather.c:249 > tlb_finish_mmu+0xcb/0x200 mm/mmu_gather.c:328 > exit_mmap+0x296/0x550 mm/mmap.c:3185 > __mmput+0x113/0x370 kernel/fork.c:1076 > exit_mm+0x4cd/0x550 kernel/exit.c:483 > do_exit+0x576/0x1f20 kernel/exit.c:793 > do_group_exit+0x161/0x2d0 kernel/exit.c:903 > get_signal+0x139b/0x1d30 kernel/signal.c:2743 > arch_do_signal+0x33/0x610 arch/x86/kernel/signal.c:811 > exit_to_user_mode_loop kernel/entry/common.c:135 [inline] > exit_to_user_mode_prepare+0x8d/0x1b0 kernel/entry/common.c:166 > syscall_exit_to_user_mode+0x5e/0x1a0 kernel/entry/common.c:241 > entry_SYSCALL_64_after_hwframe+0x44/0xa9 > RIP: 0033:0x45d239 > Code: Bad RIP value. > RSP: 002b:00007f3d8a21acf8 EFLAGS: 00000246 ORIG_RAX: 00000000000000ca > RAX: 0000000000000001 RBX: 000000000118cf48 RCX: 000000000045d239 > RDX: 00000000000f4240 RSI: 0000000000000081 RDI: 000000000118cf4c > RBP: 000000000118cf40 R08: 0000000000000009 R09: 0000000000000000 > R10: ffffffffffffffff R11: 0000000000000246 R12: 000000000118cf4c > R13: 00007fff2711787f R14: 00007f3d8a21b9c0 R15: 000000000118cf4c > > Allocated by task 9270: > kasan_save_stack mm/kasan/common.c:48 [inline] > kasan_set_track mm/kasan/common.c:56 [inline] > __kasan_kmalloc+0x100/0x130 mm/kasan/common.c:461 > __do_kmalloc mm/slab.c:3655 [inline] > __kmalloc+0x218/0x320 mm/slab.c:3664 > mem_cgroup_alloc mm/memcontrol.c:5210 [inline] > mem_cgroup_css_alloc+0x86/0x1590 mm/memcontrol.c:5278 > css_create kernel/cgroup/cgroup.c:5128 [inline] > cgroup_apply_control_enable+0x581/0x1200 kernel/cgroup/cgroup.c:3059 > cgroup_apply_control+0x37/0x6c0 kernel/cgroup/cgroup.c:3141 > cgroup_subtree_control_write+0x95b/0x10c0 kernel/cgroup/cgroup.c:3299 > cgroup_file_write+0x21e/0x5c0 kernel/cgroup/cgroup.c:3697 > kernfs_fop_write+0x3f4/0x4f0 fs/kernfs/file.c:315 > vfs_write+0x2d3/0xd10 fs/read_write.c:576 > ksys_write+0x11b/0x220 fs/read_write.c:631 > do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46 > entry_SYSCALL_64_after_hwframe+0x44/0xa9 > > Freed by task 8108: > kasan_save_stack mm/kasan/common.c:48 [inline] > kasan_set_track+0x3d/0x70 mm/kasan/common.c:56 > kasan_set_free_info+0x17/0x30 mm/kasan/generic.c:355 > __kasan_slab_free+0xdd/0x110 mm/kasan/common.c:422 > __cache_free mm/slab.c:3418 [inline] > kfree+0x10a/0x220 mm/slab.c:3756 > mem_cgroup_free+0x97f/0x9b0 mm/memcontrol.c:5196 > css_free_rwork_fn+0xe4/0x970 kernel/cgroup/cgroup.c:4941 > process_one_work+0x789/0xfc0 kernel/workqueue.c:2269 > worker_thread+0xaa4/0x1460 kernel/workqueue.c:2415 > kthread+0x37e/0x3a0 drivers/block/aoe/aoecmd.c:1234 > ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294 > > Last call_rcu(): > kasan_save_stack+0x27/0x50 mm/kasan/common.c:48 > kasan_record_aux_stack+0x7b/0xb0 mm/kasan/generic.c:346 > __call_rcu kernel/rcu/tree.c:2894 [inline] > call_rcu+0x139/0x840 kernel/rcu/tree.c:2968 > queue_rcu_work+0x74/0x90 kernel/workqueue.c:1747 > process_one_work+0x789/0xfc0 kernel/workqueue.c:2269 > worker_thread+0xaa4/0x1460 kernel/workqueue.c:2415 > kthread+0x37e/0x3a0 drivers/block/aoe/aoecmd.c:1234 > ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294 > > Second to last call_rcu(): > kasan_save_stack+0x27/0x50 mm/kasan/common.c:48 > kasan_record_aux_stack+0x7b/0xb0 mm/kasan/generic.c:346 > __call_rcu kernel/rcu/tree.c:2894 [inline] > call_rcu+0x139/0x840 kernel/rcu/tree.c:2968 > __percpu_ref_switch_to_atomic lib/percpu-refcount.c:192 [inline] > __percpu_ref_switch_mode+0x2c1/0x4f0 lib/percpu-refcount.c:237 > percpu_ref_kill_and_confirm+0x8f/0x130 lib/percpu-refcount.c:350 > cgroup_apply_control_disable kernel/cgroup/cgroup.c:3108 [inline] > cgroup_finalize_control+0x7c5/0xd60 kernel/cgroup/cgroup.c:3171 > cgroup_subtree_control_write+0x968/0x10c0 kernel/cgroup/cgroup.c:3300 > cgroup_file_write+0x21e/0x5c0 kernel/cgroup/cgroup.c:3697 > kernfs_fop_write+0x3f4/0x4f0 fs/kernfs/file.c:315 > vfs_write+0x2d3/0xd10 fs/read_write.c:576 > ksys_write+0x11b/0x220 fs/read_write.c:631 > do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46 > entry_SYSCALL_64_after_hwframe+0x44/0xa9 > > The buggy address belongs to the object at ffff8880371c0000 > which belongs to the cache kmalloc-4k of size 4096 > The buggy address is located 328 bytes inside of > 4096-byte region [ffff8880371c0000, ffff8880371c1000) > The buggy address belongs to the page: > page:00000000cea4402b refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x371c0 > head:00000000cea4402b order:1 compound_mapcount:0 > flags: 0xfffe0000010200(slab|head) > raw: 00fffe0000010200 ffffea0001337088 ffffea0000dc7088 ffff8880aa440900 > raw: 0000000000000000 ffff8880371c0000 0000000100000001 0000000000000000 > page dumped because: kasan: bad access detected > > Memory state around the buggy address: > ffff8880371c0000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb > ffff8880371c0080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb > >ffff8880371c0100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb > ^ > ffff8880371c0180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb > ffff8880371c0200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb > ================================================================== > > > --- > This report 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 issue. See: > https://goo.gl/tpsmEJ#status for how to communicate with syzbot.