Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp5176056ybl; Tue, 14 Jan 2020 04:53:21 -0800 (PST) X-Google-Smtp-Source: APXvYqwpRhM0lCdaQnB0eeA7wxmkPeGVIqczJKm47TPEPWQm3zpaXbvb+J9A0x6wxIDhfDvu8aPL X-Received: by 2002:aca:be56:: with SMTP id o83mr16894395oif.25.1579006401090; Tue, 14 Jan 2020 04:53:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579006401; cv=none; d=google.com; s=arc-20160816; b=0ymCiEOMN9KLTjyczbNh/Il5Ae7Hf2rFfYEBhaStgA+9LwTbAr1aJwh5YQttHG9Xil kLlQYn3c3Q/HvAHsSWir2gKmmNom/mzUmgePq+nq7XxRAl4tu1Qmp8iFjTVW1OlpvHKc A2uY/2G73FILEEdbnb8NyhHRMqh9gsVMC07PzcXvG2uFDoSOdEyc44yYRB0zMbl4ZdbW eCSUXw0lQMMpi1Zm/x6nHOU8HnyyDqr6UHGQgOiZC8dZwaVTzxewy2x/V3WkMrNN+Upx 9YO/xpBo8aAlURghY4vi47uX0ZBc4TSAiaDDTmPZAh0eAPTzHThLBrH/vw9kurPGdnbm kjtg== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=W+Q9dUTyz/K5v7vEopmSX1VV9yqJ2uEeGg7eL1QYRZQ=; b=t7Tm7h63gxd5DDltVqq9lpM2bjbfs/LUkmnilPNr0lV3QSdv5iWyOg9HkbLPs3lWZN YLKHQMN2CKQ7jhEu/D59CeQtrD1dJ6a2xh+IKtwqp1Ya6+mO2Pqfn1+QnPIuSfjeVusW w9+dEWmo08hG+MNqcOiohnVJeBgJIXbTLwHpanNDnXPBbdJ4sVgnaI+UB30wqGZvYSQJ 4FwZhv570JcmGjsPYR3fT13u4ihBWHDEP68G6S+nE5fK+AWt+9C79BhZ8kIPZCXzN+5K wq6e8HIOUHTWTNsLmpQDgJZZ/1BMGpJouIQQUlrlumLqKn/pdEE6sKc5/7kG9cadV2Kq XzGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=H8ogLJT4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s3si8415017otr.57.2020.01.14.04.53.10; Tue, 14 Jan 2020 04:53:21 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=H8ogLJT4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1728670AbgANMvP (ORCPT + 99 others); Tue, 14 Jan 2020 07:51:15 -0500 Received: from mail-ot1-f65.google.com ([209.85.210.65]:46120 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726265AbgANMvO (ORCPT ); Tue, 14 Jan 2020 07:51:14 -0500 Received: by mail-ot1-f65.google.com with SMTP id r9so12437543otp.13 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=gGAYS8TPE5UlZ8jJybUCHVg/ym72g1wz25AtqEKaG750GprqmGtfViyxYP6Z2tsUPD M7SftCwoem9EE7dUf/e4R5IGZRny89Gy4UdcTbz+VZqKpkeHo5x2ubf3dYIaP1kAhhZ0 kO1o74SQskGt12RCBwNdNowhAdHkNntsTqv8xWX3B4+pCWR0Xwb0VVv0JPsffm7v88cS hOMGu8IDd9lEfOAAhLy/eUxX7ETDaB9FxJBbniXwS8Cw7WYhOUuwvZguq4FCyS2uXQ5g zRArEKKOmhWkVwihMDGO/vlM7aEyQ1uKdOrr/PwdsKRsUwdbF2qcI6bBxinaAxHJ9tkr z5wQ== X-Gm-Message-State: APjAAAVaiuWT5nzP9UBCnvwJ5CgEVAB/FdwWjwxI56mOQ+Kk9gDSZwcc B+0aBdzwReKdekkJPlMBLDdC68SNfVJA+db+qNhq5Q== 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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