Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1726223yba; Sat, 6 Apr 2019 21:59:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqw6n6ozBuuOWl/tLB7vSex1h2GQEBSLBylD6sagfZwJsTUdbAcCGHRMb/VEMFChGvZEmQxI X-Received: by 2002:a65:6148:: with SMTP id o8mr21539203pgv.153.1554613171543; Sat, 06 Apr 2019 21:59:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554613171; cv=none; d=google.com; s=arc-20160816; b=FeGJM7bL1LTxUS/XXdKrFAjzJTNb5M4nMYgSJMIEvKKiim52Sw6zCUp0sckti1u76J a4J6e5CYkQaZrnJ1H/9qMCSK7zYPI132Uk/TDIPX4UkQMCIm3YUr+8Pro57KidqUQXHd RshCzD5lIxZQRDH/pI9nSFDD0QSZbxMGmRTxcbvzkF4vhR+ErT/YRzSieCkuDdDWHAYU /MYRM0IQ1OtlGXFX0A4ymqXvJ/uSqfgHYu3KxiDKqdhdCAl37g05P1cDKD3rjoBxVrBG Ug85/ZzTbQl3A+8GLJ7AYp7rk+uz8lmL+0u80WRXJ+UPmY6sjpXLkiKW2LtNXUgWQltX lVfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=fACPxuGgKnpTTRVWKP8vcwe84dPQ8qijyglGl0RZFqE=; b=j78+PMPfICC4gGkm4p07r/HdlrL71YuD9vwxB/oC4GWTxWdjKHdqT+BVgsxH9Q/w3l bkdh+2PjKJuRiWDPel37UAya4mJEB3dA8CUYm0Eq5jzPBzf/E9I16JLmPV2JLlqepF6R 7PS38VCX9D9XYjxGnHTTwHOgrzs6E5PVpVzJKRgvq3eM6qKfg9ZDZcoKqGhrmn9a2YD6 JyJ9vA70mMhvGEngP9CWrq7dEiPEqLe2+Uj1jvTMy35Iuo3K05b7YBt8fL20w09qIr+A fA6NZ1l0QvHHaGG9PIll8qz1Z9FpfOXt2o0HJyoh07JZgjXH2tZs/vFsNzZ+UtNnne5I u5Ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vThHVxOV; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d35si23572696pla.48.2019.04.06.21.59.16; Sat, 06 Apr 2019 21:59:31 -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=@kernel.org header.s=default header.b=vThHVxOV; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726199AbfDGE4h (ORCPT + 99 others); Sun, 7 Apr 2019 00:56:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:38402 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725929AbfDGE4g (ORCPT ); Sun, 7 Apr 2019 00:56:36 -0400 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B9E6F214AE for ; Sun, 7 Apr 2019 04:56:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554612996; bh=tAQQkWe/CqPvVoPSyAZmFu3+ckaqFog69rqXI88Se/8=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=vThHVxOVXmxZ7xhfg2Ql5YdFAWM1VmLyP1Qlb1Ak3cUWvshBb89AlGUqaYJyorh5T NuvyCZNsYaCrkZsFYyhK6XrSBFxtWfoFZEyN/rW5Hkqe864115JbfsF6bLruF8yjjh pU3gCAI03rchelQMYECIc9uo7ietrhTYmEpZ4TEY= Received: by mail-wr1-f48.google.com with SMTP id r4so12413858wrq.8 for ; Sat, 06 Apr 2019 21:56:35 -0700 (PDT) X-Gm-Message-State: APjAAAUaoIIVsZzpf8F8rxxl3bfdmN8LQQPeidyNjIIEwciEeK7Y6t1b 9FpMQzlV67fLmLYAT2yab6CZzCq2s7QBsn/jjuTyNw== X-Received: by 2002:adf:efc1:: with SMTP id i1mr13780670wrp.199.1554612994300; Sat, 06 Apr 2019 21:56:34 -0700 (PDT) MIME-Version: 1.0 References: <20190405150658.237064784@linutronix.de> <20190405150930.967389183@linutronix.de> In-Reply-To: <20190405150930.967389183@linutronix.de> From: Andy Lutomirski Date: Sat, 6 Apr 2019 21:56:21 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [patch V2 28/29] x86/irq/64: Remap the IRQ stack with guard pages To: Thomas Gleixner Cc: LKML , X86 ML , Andy Lutomirski , Josh Poimboeuf , Sean Christopherson Content-Type: multipart/mixed; boundary="0000000000004a142e0585e98b79" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --0000000000004a142e0585e98b79 Content-Type: text/plain; charset="UTF-8" On Fri, Apr 5, 2019 at 8:11 AM Thomas Gleixner wrote: > > From: Andy Lutomirski > > The IRQ stack lives in percpu space, so an IRQ handler that overflows it > will overwrite other data structures. > > Use vmap() to remap the IRQ stack so that it will have the usual guard > pages that vmap/vmalloc allocations have. With this the kernel will panic > immediately on an IRQ stack overflow. The 0day bot noticed that this dies with DEBUG_PAGEALLOC on. This is because the store_stackinfo() function is utter garbage and this patch correctly detects just how broken it is. The attached patch "fixes" it. (It also contains a reliability improvement that should probably get folded in, but is otherwise unrelated.) A real fix would remove the generic kstack_end() function entirely along with __HAVE_ARCH_KSTACK_END and would optionally replace store_stackinfo() with something useful. Josh, do we have a generic API to do a little stack walk like this? Otherwise, I don't think it would be the end of the world to just remove the offending code. --Andy --0000000000004a142e0585e98b79 Content-Type: text/x-patch; charset="US-ASCII"; name="fix.diff" Content-Disposition: attachment; filename="fix.diff" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_ju6gfgc30 ZGlmZiAtLWdpdCBhL2FyY2gveDg2L2tlcm5lbC9jcHUvY29tbW9uLmMgYi9hcmNoL3g4Ni9rZXJu ZWwvY3B1L2NvbW1vbi5jCmluZGV4IDgwMWM2ZjA0MGZhYS4uZWI4OTM5ZDI4Zjk2IDEwMDY0NAot LS0gYS9hcmNoL3g4Ni9rZXJuZWwvY3B1L2NvbW1vbi5jCisrKyBiL2FyY2gveDg2L2tlcm5lbC9j cHUvY29tbW9uLmMKQEAgLTE1MTAsNiArMTUxMCwxMiBAQCBERUZJTkVfUEVSX0NQVShzdHJ1Y3Qg dGFza19zdHJ1Y3QgKiwgY3VycmVudF90YXNrKSBfX19fY2FjaGVsaW5lX2FsaWduZWQgPQogCSZp bml0X3Rhc2s7CiBFWFBPUlRfUEVSX0NQVV9TWU1CT0woY3VycmVudF90YXNrKTsKIAorLyoKKyAq IFRoZSBpbml0aWFsIGhhcmRpcnFfc3RhY2tfcHRyIHZhbHVlIG9mIE5VTEwgaXMgaW52YWxpZC4g IFRvIHByZXZlbnQgaXQKKyAqIGZyb20gYmVpbmcgdXNlZCBpZiBhbiBJUlEgaGFwcGVucyB0b28g ZWFybHksIHdlIGluaXRpYWxpemUgaXJxX2NvdW50IHRvIDEsCisgKiB3aGljaCBlZmZlY3RpdmVs eSBkaXNhYmxlcyBFTlRFUl9JUlFfU1RBQ0suICBUaGUgY29kZSB0aGF0IG1hcHMgdGhlIElSUQ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