Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp2359677rwr; Fri, 21 Apr 2023 07:55:32 -0700 (PDT) X-Google-Smtp-Source: AKy350Zti4ejSMDDCQnE9ahczq6xnlibR4sY2WiFwzcHhXGtf8ObxeUSU02pHHmNqKqGzA/MyJpR X-Received: by 2002:a05:6a00:1c95:b0:5e4:f141:568b with SMTP id y21-20020a056a001c9500b005e4f141568bmr6044031pfw.3.1682088931576; Fri, 21 Apr 2023 07:55:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682088931; cv=none; d=google.com; s=arc-20160816; b=OPNe6W0R1haCuze0mWJ4dI4xH4Ik68pCz0sDsSumXePzoI7OXslF8T6wtcuR/w7gcz 4zFo3Uz9EUukiv82RhRK+u2V/WS/DN5uHwA/PdNGoCmi4zWJ2CSrnx/d6SnJG+RAjhZE au97UD14KgerV/URkpwAMpQZVjDDlPlYt7p2aFJ73ackl93Y2NLg/QMITkePv6OBzoyD DOz/HVUVhR2zHbtfMe8VhLB4jpOynZ3MRjfC4A4m1QwjTS4Ngp79iGyRWiI/y+XOshsp Y1i+OuUbG3Yf9locuhsbgt9vAkKaEnAOpnpQgDh4VplRAPNKMqfzJg2SNexxoySQzWwK GvBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=uE8L66mYi61Gg000YX9CaB4PguSbhnlIM05Rg2iq/GU=; b=Kdb83jlVA+ljQ1iY4jMI22ete4Tyx8OJb6ea3pd16g2pEweKSfqfUg3w6UneYMXlDD TCIQ4RLof+Bm2IXCmRfrfxOuY3qq0lP1L8JVlTmXvo/OphnDwVJSs0K+yXgj3xghGlqw wnhhQxwf6aHKzEemq1nsh4NcxjXHnD/9AbVE6Z4w2It6yhpiyjQyRhDZvhP6Tu8pNnV2 Pq5CoTZVnMC18HFY9S/I7s6NowQXLBLmmY1uAKuSEayEmXY4XXOL6+03bI+3wHM2eD/y y1pqS2N0p7FOxI1L4jUkMFFjzB2C1UxWHc0iju6FjyOtIbbPmvHZF35h8QGInL95096Q 9lIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=g3rmUy97; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c5-20020a6566c5000000b0051f8b655dfdsi4575938pgw.18.2023.04.21.07.55.19; Fri, 21 Apr 2023 07:55:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=g3rmUy97; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233048AbjDUOls (ORCPT + 99 others); Fri, 21 Apr 2023 10:41:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232955AbjDUOlc (ORCPT ); Fri, 21 Apr 2023 10:41:32 -0400 Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 091B115464 for ; Fri, 21 Apr 2023 07:40:39 -0700 (PDT) Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-4edc63e066fso7009e87.1 for ; Fri, 21 Apr 2023 07:40:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1682087938; x=1684679938; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=uE8L66mYi61Gg000YX9CaB4PguSbhnlIM05Rg2iq/GU=; b=g3rmUy97ewR5Qob/EIc0qirnHyGan7c3n7pweFBrjd4IKEX1NVaHijC/5eHO4MNEDW Ff3BUAQNyy0m/fGS9YWwhDtiFnB5bLlPAjjH6fTEFwOvUJbkRqH9u3P763jj6of+sfJV eh1paFZ6ywkGWJqWKXSSu3i6LkZ0rb1dLjXid+GjA3s3hyJwVUlPonXyw6Cz30d88pjH TLOU/sY30TqTHGlXm0/qbIZsfLkAThaztVPBD3OR4nmNuVPX6xNzmzb7bGHzouRJKy77 iQTEbiCwwv2DBX8+uESfd1BeUMHZ/N3avr3F3IScinfFcGzEoNS/DlIRNt1JSYsaTWTy mWzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682087938; x=1684679938; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=uE8L66mYi61Gg000YX9CaB4PguSbhnlIM05Rg2iq/GU=; b=TBx0w2igLl7WiV2UiaJp2A7idpVYduIJxcIidl2Smkb/P0aDc5m8csf8UBbPRyTcGT +RmbzVppMrVrv+Dp8NKXTKocrntF+WB7xMB5CaaNjKlZ1IDMOCH/RUSKDdtA/79v95L1 TlCtR1d7tLXDZ/lRtadnWcH2YiumZea9PUxcpKdogaEhbfkXludUrrhbc7rAtIaXcrTK d7F/o0ACl+13ilBxP5eNmbdbdcbo2h4dHUgBj/NJtGAsCL2+BwLF9OVUpn+eQ89mQHNv pUyi3aScGhJvhdaJNHXO/iw5DWF/DWt9S/mtEF0jO4yEZnLMPP820PItM2Mdpd/A2A8u 04YA== X-Gm-Message-State: AAQBX9da2B4/e1cg5e1lDfI+k02Ni35JdSqto+sTmHtw1d1LRO8Q94B9 eYnOxjVxy9SmZfoCEnLAvCAzPHc0vBy4bLrap8g3yQ== X-Received: by 2002:a05:6512:110a:b0:4ed:af48:f8bb with SMTP id l10-20020a056512110a00b004edaf48f8bbmr104792lfg.5.1682087938324; Fri, 21 Apr 2023 07:38:58 -0700 (PDT) MIME-Version: 1.0 References: <00000000000058b63f05f9d98811@google.com> In-Reply-To: <00000000000058b63f05f9d98811@google.com> From: Dmitry Vyukov Date: Fri, 21 Apr 2023 16:38:45 +0200 Message-ID: Subject: Re: [syzbot] [cgroups?] [mm?] KCSAN: data-race in drain_all_stock / drain_obj_stock (4) To: syzbot Cc: akpm@linux-foundation.org, bpf@vger.kernel.org, cgroups@vger.kernel.org, hannes@cmpxchg.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, mhocko@kernel.org, muchun.song@linux.dev, roman.gushchin@linux.dev, shakeelb@google.com, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-15.1 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SORTED_RECIPS,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED,USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 21 Apr 2023 at 16:33, syzbot wrote: > > Hello, > > syzbot found the following issue on: > > HEAD commit: 534293368afa Merge tag 'kbuild-fixes-v6.3' of git://git.ke.. > git tree: upstream > console output: https://syzkaller.appspot.com/x/log.txt?x=11a0c26ec80000 > kernel config: https://syzkaller.appspot.com/x/.config?x=85fa20c996a2e46d > dashboard link: https://syzkaller.appspot.com/bug?extid=774c29891415ab0fd29d > compiler: Debian clang version 15.0.7, GNU ld (GNU Binutils for Debian) 2.35.2 > > Unfortunately, I don't have any reproducer for this issue yet. > > Downloadable assets: > disk image: https://storage.googleapis.com/syzbot-assets/ec0e584af797/disk-53429336.raw.xz > vmlinux: https://storage.googleapis.com/syzbot-assets/423a67f52f94/vmlinux-53429336.xz > kernel image: https://storage.googleapis.com/syzbot-assets/8409b9716faa/bzImage-53429336.xz > > IMPORTANT: if you fix the issue, please add the following tag to the commit: > Reported-by: syzbot+774c29891415ab0fd29d@syzkaller.appspotmail.com Here this: stock->cached_objcg = NULL; runs concurrently with: if (stock->cached_objcg) { memcg = obj_cgroup_memcg(stock->cached_objcg); If I am reading this correctly, this can cause a NULL deref, if cached_objcg is reset between the check and the use. > ================================================================== > BUG: KCSAN: data-race in drain_all_stock / drain_obj_stock > > write to 0xffff888237c2a2f8 of 8 bytes by task 19625 on cpu 0: > drain_obj_stock+0x408/0x4e0 mm/memcontrol.c:3306 > refill_obj_stock+0x9c/0x1e0 mm/memcontrol.c:3340 > obj_cgroup_uncharge+0xe/0x10 mm/memcontrol.c:3408 > memcg_slab_free_hook mm/slab.h:587 [inline] > __cache_free mm/slab.c:3373 [inline] > __do_kmem_cache_free mm/slab.c:3577 [inline] > kmem_cache_free+0x105/0x280 mm/slab.c:3602 > __d_free fs/dcache.c:298 [inline] > dentry_free fs/dcache.c:375 [inline] > __dentry_kill+0x422/0x4a0 fs/dcache.c:621 > dentry_kill+0x8d/0x1e0 > dput+0x118/0x1f0 fs/dcache.c:913 > __fput+0x3bf/0x570 fs/file_table.c:329 > ____fput+0x15/0x20 fs/file_table.c:349 > task_work_run+0x123/0x160 kernel/task_work.c:179 > resume_user_mode_work include/linux/resume_user_mode.h:49 [inline] > exit_to_user_mode_loop+0xcf/0xe0 kernel/entry/common.c:171 > exit_to_user_mode_prepare+0x6a/0xa0 kernel/entry/common.c:203 > __syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline] > syscall_exit_to_user_mode+0x26/0x140 kernel/entry/common.c:296 > do_syscall_64+0x4d/0xc0 arch/x86/entry/common.c:86 > entry_SYSCALL_64_after_hwframe+0x63/0xcd > > read to 0xffff888237c2a2f8 of 8 bytes by task 19632 on cpu 1: > obj_stock_flush_required mm/memcontrol.c:3319 [inline] > drain_all_stock+0x174/0x2a0 mm/memcontrol.c:2361 > try_charge_memcg+0x6d0/0xd10 mm/memcontrol.c:2703 > try_charge mm/memcontrol.c:2837 [inline] > mem_cgroup_charge_skmem+0x51/0x140 mm/memcontrol.c:7290 > sock_reserve_memory+0xb1/0x390 net/core/sock.c:1025 > sk_setsockopt+0x800/0x1e70 net/core/sock.c:1525 > udp_lib_setsockopt+0x99/0x6c0 net/ipv4/udp.c:2692 > udp_setsockopt+0x73/0xa0 net/ipv4/udp.c:2817 > sock_common_setsockopt+0x61/0x70 net/core/sock.c:3668 > __sys_setsockopt+0x1c3/0x230 net/socket.c:2271 > __do_sys_setsockopt net/socket.c:2282 [inline] > __se_sys_setsockopt net/socket.c:2279 [inline] > __x64_sys_setsockopt+0x66/0x80 net/socket.c:2279 > do_syscall_x64 arch/x86/entry/common.c:50 [inline] > do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80 > entry_SYSCALL_64_after_hwframe+0x63/0xcd > > value changed: 0xffff8881382d52c0 -> 0xffff888138893740 > > Reported by Kernel Concurrency Sanitizer on: > CPU: 1 PID: 19632 Comm: syz-executor.0 Not tainted 6.3.0-rc2-syzkaller-00387-g534293368afa #0 > Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/02/2023 > ================================================================== > > > --- > 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. > > -- > You received this message because you are subscribed to the Google Groups "syzkaller-bugs" group. > To unsubscribe from this group and stop receiving emails from it, send an email to syzkaller-bugs+unsubscribe@googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/msgid/syzkaller-bugs/00000000000058b63f05f9d98811%40google.com.