Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp1279824ybg; Wed, 23 Oct 2019 13:12:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqxSjQiBAkvdJ22hoCIsieokJk+JEKRwDYFvbN+uo17K8uZPKc2PhuhB83RgwEcqPoEsjt3a X-Received: by 2002:a17:906:24c9:: with SMTP id f9mr34700904ejb.201.1571861576191; Wed, 23 Oct 2019 13:12:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571861576; cv=none; d=google.com; s=arc-20160816; b=zqAcoq9kie7Xk1MhxK9NjGDytsiu2gZpNr9QHPieZSq6h+Nw1L2Jmgw0lEFe/fKB4k 8aBk0LI6Zb4QfWebyGjTKXcmIGw0uwix0xczNoHEqlGVirIYgBazM0PTCJwzNffaxHqB lrAnUAv1Ax0LP6RFP7KXnAIM9FyKomNXQYHP6Dz7iklYuTOgwrNKNpPmuMeOuoWGA3tV iLsRC+Fx9wu4ZvsO6XVAuFQh1gGJl8+x84ipbU81II4sSMxfzb0hMU/Bl8TWZCglXX1Q APkiPWsozwn4Y4Z1H3qcN8C976qf5NlZWndQNBLEs3UUJTYX/cV6fgGysKhEjUh3kD7d u5gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Wzxz1HRetKbtdZRIGFi+6T+sl+zIChdSBNVj624bN+w=; b=AbQgqBKLzPIcBWLuEyHRIwwV6BDmIuV87Wskbf9zs2RV0E3wcztyymSEhELj+f0N8B 6QG6KnNscCRDTXZmvE0iJw/o1NXQSVcnLl2yjm34IeUZPvv8b9QJKwVquP88JTGJ3T2g xfRSsWz2ovMXl53ZDj8cXRaeyw2Xbh6kha69Ct3Lgb2s7+mAd3MIVCnLRmTDBCYmA/ag b8s6hShpvLQ+U9/6B/AbE/2Y3YQ03hTTJkxfBXW8tpOGoA7UwnJq4DSSElVoi5/QECL9 fiBj6R3JHHyjvQonzdTSP1HDyYYHP4f0YzQ8IZQjczI9BZg2blkVgt6ioNYZxYmwixBR klpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=GCdeB54p; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g6si2345555eda.377.2019.10.23.13.12.31; Wed, 23 Oct 2019 13:12:56 -0700 (PDT) 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=@gmail.com header.s=20161025 header.b=GCdeB54p; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392022AbfJWNcL (ORCPT + 99 others); Wed, 23 Oct 2019 09:32:11 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:45304 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389224AbfJWNcK (ORCPT ); Wed, 23 Oct 2019 09:32:10 -0400 Received: by mail-lj1-f196.google.com with SMTP id q64so21114333ljb.12 for ; Wed, 23 Oct 2019 06:32:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Wzxz1HRetKbtdZRIGFi+6T+sl+zIChdSBNVj624bN+w=; b=GCdeB54p3XbpLOICpXtiiEJFuVt9MpKDpi6YvUWuKBbDAgN771qopihE72xllMiaD0 FOkJvk9HjcCoGYOX/YHNCZAa+pF94yMyAr8Q5iQTV2rq+q7dDZ/Zpvv2NwZFNYdV6tJN saw2Mthif5qLS0aZWjZthnwiS/3G+LEsm2uP/LKleo2jB+FeVIx/TjzV6xoCQeFt3mj0 1yOg8MZtZi0exfVi+bEliec8hcB2ylXCc0i9SvkfbdfbgCbkFEJv8JUqmN9aXmn3uaFm D47LHSzMbVu2O47X72DZElqi8pfy89VAEkAkWy0f+2ARricY+OMSb1Mca/RiAQ4vG5dS L9eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Wzxz1HRetKbtdZRIGFi+6T+sl+zIChdSBNVj624bN+w=; b=unhmWI0ILjwuXN6H8Pb/udR88KBMpRLB+9WIM1zcu4fJN7ZSfL/Ak9S5GWkj8+YpVK McVoHLHYpTwaX7VJVuStqY8fvSe8I4T3m6ShjwVV+prLU9DfUTGo9zwL5i0u48BFFHQa kSXxipU5q8EGy4cWU/V9NnNnSAvSy0yrTJWFhGeLKCQ7CFIbAYE7za8bMpPR8v5ve97o Ew4JwdA9ChgjgqonIubcFaSLswVMowvs/7VZYHPu/zRvay+kvmisRWTunHdVi04gzLJM jIwCrinyUmCHsZVIHO/ux3DQ3md2MXEQ968Xxw4EcuoK7D5cW7SSkn0NpHxrTxOSPgfb Ewpw== X-Gm-Message-State: APjAAAUUfW1t9PDib13fOln4not4WF8Cn1eg7AqcRtiNlhvC70x4oL3s laxUt8VQBFiBOj5okKIP/LtHexIB X-Received: by 2002:a2e:9058:: with SMTP id n24mr5556839ljg.114.1571837526825; Wed, 23 Oct 2019 06:32:06 -0700 (PDT) Received: from uranus.localdomain ([5.18.199.94]) by smtp.gmail.com with ESMTPSA id x13sm4461769ljb.92.2019.10.23.06.32.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2019 06:32:05 -0700 (PDT) Received: by uranus.localdomain (Postfix, from userid 1000) id A490D4610AC; Wed, 23 Oct 2019 16:32:04 +0300 (MSK) Date: Wed, 23 Oct 2019 16:32:04 +0300 From: Cyrill Gorcunov To: Thomas Gleixner Cc: LKML , Ingo Molnar , Peter Zijlstra , linux-mm@kvack.org, Catalin Marinas Subject: Re: [BUG -tip] kmemleak and stacktrace cause page faul Message-ID: <20191023133204.GH12121@uranus.lan> References: <20191019114421.GK9698@uranus.lan> <20191022142325.GD12121@uranus.lan> <20191022145619.GE12121@uranus.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 23, 2019 at 03:21:05PM +0200, Thomas Gleixner wrote: > On Tue, 22 Oct 2019, Cyrill Gorcunov wrote: > > On Tue, Oct 22, 2019 at 05:23:25PM +0300, Cyrill Gorcunov wrote: > > > > > > I presume the kmemleak tries to save stack trace too early when estack_pages are not > > > yet filled. > > > > Indeed, at this stage of boot the percpu_setup_exception_stacks has not been called > > yet and estack_pages full of crap > > > > [ 0.157502] stk 0x1008 k 1 begin 0x0 end 0xd000 estack_pages 0xffffffff82014880 ep 0xffffffff82014888 > > [ 0.159395] estack_pages[0] = 0x0 > > [ 0.160046] estack_pages[1] = 0x5100000001000 > > [ 0.160881] estack_pages[2] = 0x0 > > [ 0.161530] estack_pages[3] = 0x6100000003000 > > [ 0.162343] estack_pages[4] = 0x0 > > [ 0.162962] estack_pages[5] = 0x0 > > [ 0.163523] estack_pages[6] = 0x0 > > [ 0.164065] estack_pages[7] = 0x8100000007000 > > [ 0.164978] estack_pages[8] = 0x0 > > [ 0.165624] estack_pages[9] = 0x9100000009000 > > [ 0.166448] estack_pages[10] = 0x0 > > [ 0.167064] estack_pages[11] = 0xa10000000b000 > > [ 0.168055] estack_pages[12] = 0x0 > > Errm. estack_pages is statically initialized and it's an array of:. > > struct estack_pages { > u32 offs; > u16 size; > u16 type; > }; > > [0,2,4,5,6,8,10,12] are guard pages so 0 is not that crappy at all Wait, Thomas, I might be wrong, but per-cpu is initialized to the pointer, the memory for this estack_pages has not yet been allocated, no? > The rest looks completely valid if you actually decode it proper. The diff I made to fetch the values are diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c index 753b8cfe8b8a..bf0d755b6079 100644 --- a/arch/x86/kernel/dumpstack_64.c +++ b/arch/x86/kernel/dumpstack_64.c @@ -101,8 +101,18 @@ static bool in_exception_stack(unsigned long *stack, struct stack_info *info) /* Calc page offset from start of exception stacks */ k = (stk - begin) >> PAGE_SHIFT; + /* Lookup the page descriptor */ ep = &estack_pages[k]; + + printk("stk 0x%lx k %u begin 0x%lx end 0x%lx estack_pages 0x%lx ep 0x%lx\n", + stk, k, begin, end, (long)(void *)&estack_pages[0], (long)(void *)ep); + + for (k = 0; k < CEA_ESTACK_PAGES; k++) { + long v = *(long *)(void *)&estack_pages[k]; + printk("estack_pages[%d] = 0x%lx\n", k, v); + } + /* Guard page? */ if (!ep->size) return false; > > e.g. 0x51000 00001000 > > bit 0-31: 00001000 Offset 0x1000: 1 Page > bit 32-47: 1000 Size 0x1000: 1 Page > bit 48-63: 5 Type 5: STACK_TYPE_EXCEPTION + ESTACK_DF > > So, no. This is NOT the problem. I drop the left of your reply. True, I agreed with anything you said. You know I didn't manage to dive more into this problem yesterday but if time permits I'll continue today. It is easily triggering under kvm (the kernel I'm building is almost without modules so I simply upload bzImage into the guest). FWIW, the config I'm using is https://gist.github.com/cyrillos/7cd5d2510a99af8ea872f07ac6f9095b