From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.4 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7C9F2C33CB1 for ; Tue, 14 Jan 2020 12:51:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 45B63207E0 for ; Tue, 14 Jan 2020 12:51:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="H8ogLJT4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727556AbgANMvP (ORCPT ); Tue, 14 Jan 2020 07:51:15 -0500 Received: from mail-ot1-f65.google.com ([209.85.210.65]:41090 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726878AbgANMvO (ORCPT ); Tue, 14 Jan 2020 07:51:14 -0500 Received: by mail-ot1-f65.google.com with SMTP id r27so12452872otc.8 for ; Tue, 14 Jan 2020 04:51:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=W+Q9dUTyz/K5v7vEopmSX1VV9yqJ2uEeGg7eL1QYRZQ=; b=H8ogLJT4KSppaj5v6wRd8cfh2U1RCnvS92Q/nL6sSdEKzYtxsF2axbVarPObfNgzHB KV0k8nT+ZtNnpeuC2hbj+BgpTHl8vNoEEuBgtnhWDEHEu1SKsXP4JgGNA83bXKIUdB59 U6MboMqkQgaxVY84AdrSkvEsg1kBypKHrSFlv4QXpas64S1l9uxYKl9s0wRKtuuvoale I74WCTj3x2pCk479W3tLKKW3p5TfuhpDNJ8Mk0N82YX/wt8ZPwJcKIOeelgg9vihOEkx +YgeIrPu6icVC2A1thr//KRAx/mwDzZbANgDFTF4zW/rNZXmRtipvEziT7jz/spm41cN hVzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=W+Q9dUTyz/K5v7vEopmSX1VV9yqJ2uEeGg7eL1QYRZQ=; b=IER/xNBQqTHNfByZsNcOSrHFRbT/9nyPHzGXzC3R1LhfDrCAjeCMtc+gcxSGGA3r5N aLB/VxaR9mZj6WxtTzMIPjroTmyiP8Prwa13lcgo6o0yQ0IpBNo8VgRrzBC8pmuaDIAK nEZvpjv17eoz19mKqUhEHT+m3M624TH8uv+Vbif2TU7RyfAjnuawjBWP1+fwRzeUm1qJ UE4aUYqCgjvMgYFf6ZStwdihyOy9/kpBL8yBxyOn5Gn8Cr9nVdeOw+ZmIx9e6ilKcU32 4aUHlyIJPCH3lzWJXd0h3+ly6/ouX7EjfXIv9WA8JVK4LNvuTPx+SxhKU6zEuJuDoF5b 8YNw== X-Gm-Message-State: APjAAAV6jfZlJGT4mw2Gpy3odJzZ1cdRxxln7HAc6TqlqlBPMR54SbzV dwP7IG1v0ZoRQbD7m1E6mptqxeXUy7htCMtPOhxqZg== X-Google-Smtp-Source: APXvYqylNPgxJbf6k9XLiMRwipsE+quarg452EJku62GGvY7X+XxjzhfC+1cwAX2swh6rwtuKCrMh49rOEIbTPnfTtE= X-Received: by 2002:a9d:588c:: with SMTP id x12mr16233506otg.2.1579006273570; Tue, 14 Jan 2020 04:51:13 -0800 (PST) MIME-Version: 1.0 References: <53F6B915-AC53-41BB-BF32-33732515B3A0@lca.pw> In-Reply-To: <53F6B915-AC53-41BB-BF32-33732515B3A0@lca.pw> From: Marco Elver Date: Tue, 14 Jan 2020 13:51:01 +0100 Message-ID: Subject: Re: [PATCH v4 01/10] kcsan: Add Kernel Concurrency Sanitizer infrastructure To: Qian Cai Cc: LKMM Maintainers -- Akira Yokosawa , Alan Stern , Alexander Potapenko , Andrea Parri , Andrey Konovalov , Andy Lutomirski , Ard Biesheuvel , Arnd Bergmann , Boqun Feng , Borislav Petkov , Daniel Axtens , Daniel Lustig , Dave Hansen , David Howells , Dmitry Vyukov , "H. Peter Anvin" , Ingo Molnar , Jade Alglave , Joel Fernandes , Jonathan Corbet , Josh Poimboeuf , Luc Maranget , Mark Rutland , Nicholas Piggin , "Paul E. McKenney" , Peter Zijlstra , Thomas Gleixner , Will Deacon , Eric Dumazet , kasan-dev , linux-arch , "open list:DOCUMENTATION" , linux-efi@vger.kernel.org, Linux Kbuild mailing list , LKML , Linux Memory Management List , "the arch/x86 maintainers" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-doc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-doc@vger.kernel.org On Tue, 14 Jan 2020 at 12:08, Qian Cai wrote: > > > > > On Jan 6, 2020, at 7:47 AM, Marco Elver wrote: > > > > Thanks, I'll look into KCSAN + lockdep compatibility. It's probably > > missing some KCSAN_SANITIZE :=3D n in some Makefile. > > Can I have a update on fixing this? It looks like more of a problem that = kcsan_setup_watchpoint() will disable IRQs and then dive into the page allo= cator where it would complain because it might sleep. KCSAN does *not* keep IRQs disabled (we have a clear irqsave / restore pair kcsan_setup_watchpoint). If you look closer at the warning you sent in this thread, the warning is not generated because IRQs are off when it wants to sleep, but rather because IRQs are enabled but IRQ tracing state is inconsistent: "DEBUG_LOCKS_WARN_ON(!current->hardirqs_enabled)" in lockdep checks that if IRQs are enabled, the trace state matches. These are only checked with LOCKDEP_DEBUG and TRACE_IRQFLAGS. In other words, IRQ trace flags got corrupted somewhere. AFAIK, this problem here is only relevant with TRACE_IRQFLAGS -- again, it is clear that IRQs are enabled but the IRQ tracing logic somehow ended up corrupting hardirqs_enabled (TRACE_IRQFLAGS). I believe this patch will take care of this issue: http://lkml.kernel.org/r/20200114124919.11891-1-elver@google.com Thanks, -- Marco > BTW, I saw Paul sent a pull request for 5.6 but it is ugly to have everyb= ody could trigger a deadlock (sleep function called in atomic context) like= this during boot once this hits the mainline not to mention about only rec= ently it is possible to test this feature (thanks to warning ratelimit) wit= h the existing debugging options because it was unable to boot due to the b= rokenness with debug_pagealloc as mentioned in this thread, so this does so= unds like it needs more soak time for the mainline to me. > > 0000000000000400 > [ 13.416814][ T1] Call Trace: > [ 13.416814][ T1] lock_is_held_type+0x66/0x160 > [ 13.416814][ T1] ___might_sleep+0xc1/0x1d0 > [ 13.416814][ T1] __might_sleep+0x5b/0xa0 > [ 13.416814][ T1] slab_pre_alloc_hook+0x7b/0xa0 > [ 13.416814][ T1] __kmalloc_node+0x60/0x300 > [ 13.416814 T1] ? alloc_cpumask_var_node+0x44/0x70 > [ 13.416814][ T1] ? topology_phys_to_logical_die+0x7e/0x180 > [ 13.416814][ T1] alloc_cpumask_var_node+0x44/0x70 > [ 13.416814][ T1] zalloc_cpumask_var+0x2a/0x40 > [ 13.416814][ T1] native_smp_prepare_cpus+0x246/0x425 > [ 13.416814][ T1] kernel_init_freeable+0x1b8/0x496 > [ 13.416814][ T1] ? rest_init+0x381/0x381 > [ 13.416814][ T1] kernel_init+0x18/0x17f > [ 13.416814][ T1] ? rest_init+0x381/0x381 > [ 13.416814][ T1] ret_from_fork+0x3a/0x50 > [ 13.416814][ T1] irq event stamp: 910 > [ 13.416814][ T1] hardirqs last enabled at (909): [] _raw_write_unlock_irqrestore+0x53/0x57 > [ 13.416814][ T1] hardirqs last disabled at (910): [] kcsan_setup_watchpoint+0x96/0x460 > [ 13.416814][ T1] softirqs last enabled at (0): [= ] copy_process+0x11fa/0x34f0 > [ 13.416814][ T1] softirqs last disabled at (0): [<0000000000000000>= ] 0x0 > [ 13.416814][ T1] ---[ end trace 7d1df66da055aa92 ]--- > [ 13.416814][ T1] possible reason: unannotated irqs-on. > [ 13.416814][ent stamp: 910 > [ 13.416814][ T1] hardirqs last enabled at (909): [] _raw_write_unlock_irqrestore+0x53/0x57 > [ 13.416814][ T1] hardirqs last disabled at (910): [] kcsan_setup_watchpoint+0x96/0x460 > [ 13.416814][ T1] softirqs last enabled at (0): [= ] copy_process+0x11fa/0x34f0 > [ 13.416814][ T1] softirqs last disabled at (0): [<0000000000000000>= ] 0x0