Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4296212ybv; Tue, 25 Feb 2020 17:15:53 -0800 (PST) X-Google-Smtp-Source: APXvYqwVP9qDeWp7inGWr2quBOMkUvK/3Ld8eeXWyaV9DuF6krZ4hIE0FRquhcVePSI87LXwCtZK X-Received: by 2002:a54:4510:: with SMTP id l16mr1297815oil.70.1582679753098; Tue, 25 Feb 2020 17:15:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582679753; cv=none; d=google.com; s=arc-20160816; b=i2fVz6x0E72H6zBo8sEBDqPz8Y14cIR/pApq4Sdmv1i/Br2j02PHB3yre4uZb4ILKZ 0AIg5Na3TRBJSmLdQBzO1ElDtGLSAKcwlpPGVMq1JTwmKqV+2YkyE2tqm0+kazwlrnFa +t3uqpxpvc7FD09JQ09IOYaY8kPgcHrLXbjuVr9h3RCjTG7yfTKEDTZlVajsBX0eqBiS j9r4BaefCfNm1rmyES6LxWG6xsfzMQVrk8Du08kMs9EAfZes1Ub88Owu28cJgg5BgO/Y DTAXuNJImh4xwy4aQVX6yPbtsRAfn71RVyP9+49R3bGQtbR+EvZXFa0LrwiGumK1LZOP xAJg== 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=42L30YxEr0okfhkxSsoRvQ+uLPzr59bJ2glAQeta7ZE=; b=u3DTCTnf9BPF7p89hJIG2EgcCIjP8s15byk+I+y+HPzVGMWbQPNMXTwtWpsqIY/eYm BLV2X4YWSMltFbZCUYb3cjUf0mgkb4AGFp4uSGiHmcrDtVY/8EFWqvkJtj10Cr06KiNi bqCZ1WyKdn91w3qnGZeqEC51jLXzLo4mke+/retcrxZo4ZNgquJ7Rxzo/eRDS6C4k7Y5 CXiWT4SigsYYOkabPSZ1RvFRN2sZqASQ5sjEjzQzrwlGfJCs9GTSU9L9OIGSc2iZpi9l FINvZUy7rdsUmWmid76xecT/JrdvD0MNnIC69LmW9xApBQih2E5icHc6iRKrD4i6muPk LOKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JiEmf8Y8; 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 t26si301586otq.264.2020.02.25.17.15.41; Tue, 25 Feb 2020 17:15:53 -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=@kernel.org header.s=default header.b=JiEmf8Y8; 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 S1730251AbgBZBNz (ORCPT + 99 others); Tue, 25 Feb 2020 20:13:55 -0500 Received: from mail.kernel.org ([198.145.29.99]:41610 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730244AbgBZBNx (ORCPT ); Tue, 25 Feb 2020 20:13:53 -0500 Received: from localhost (lfbn-ncy-1-985-231.w90-101.abo.wanadoo.fr [90.101.63.231]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F027920732; Wed, 26 Feb 2020 01:13:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582679632; bh=sEMmi+uzoT7y/MrYSZEZWw7svvLIaxFFKL1gWKPsqB0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=JiEmf8Y8PytiydffpHTRP7LL2NAxtShYIBws4Wbr7rWQ6cB7eSHWoAVgwHhXdfyWt HcBv2B/KlpHXODCp3De9bztKkzk/YEF9BIW1itAAW8KlNqtj78yDWmyk8drzrdsoVh Rig2uBU1GRiIHMVPsV2CsE4pak2JclPo6wE2079g= Date: Wed, 26 Feb 2020 02:13:50 +0100 From: Frederic Weisbecker To: Thomas Gleixner Cc: LKML , x86@kernel.org, Steven Rostedt , Brian Gerst , Juergen Gross , Paolo Bonzini , Arnd Bergmann , Andy Lutomirski Subject: Re: [patch 02/10] x86/mce: Disable tracing and kprobes on do_machine_check() Message-ID: <20200226011349.GH9599@lenoir> References: <20200225213636.689276920@linutronix.de> <20200225220216.315548935@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200225220216.315548935@linutronix.de> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 25, 2020 at 10:36:38PM +0100, Thomas Gleixner wrote: > From: Andy Lutomirski > > do_machine_check() can be raised in almost any context including the most > fragile ones. Prevent kprobes and tracing. > > Signed-off-by: Andy Lutomirski > Signed-off-by: Thomas Gleixner > --- > arch/x86/include/asm/traps.h | 3 --- > arch/x86/kernel/cpu/mce/core.c | 12 ++++++++++-- > 2 files changed, 10 insertions(+), 5 deletions(-) > > --- a/arch/x86/include/asm/traps.h > +++ b/arch/x86/include/asm/traps.h > @@ -88,9 +88,6 @@ dotraplinkage void do_page_fault(struct > dotraplinkage void do_spurious_interrupt_bug(struct pt_regs *regs, long error_code); > dotraplinkage void do_coprocessor_error(struct pt_regs *regs, long error_code); > dotraplinkage void do_alignment_check(struct pt_regs *regs, long error_code); > -#ifdef CONFIG_X86_MCE > -dotraplinkage void do_machine_check(struct pt_regs *regs, long error_code); > -#endif > dotraplinkage void do_simd_coprocessor_error(struct pt_regs *regs, long error_code); > #ifdef CONFIG_X86_32 > dotraplinkage void do_iret_error(struct pt_regs *regs, long error_code); > --- a/arch/x86/kernel/cpu/mce/core.c > +++ b/arch/x86/kernel/cpu/mce/core.c > @@ -1213,8 +1213,14 @@ static void __mc_scan_banks(struct mce * > * On Intel systems this is entered on all CPUs in parallel through > * MCE broadcast. However some CPUs might be broken beyond repair, > * so be always careful when synchronizing with others. > + * > + * Tracing and kprobes are disabled: if we interrupted a kernel context > + * with IF=1, we need to minimize stack usage. There are also recursion > + * issues: if the machine check was due to a failure of the memory > + * backing the user stack, tracing that reads the user stack will cause > + * potentially infinite recursion. > */ > -void do_machine_check(struct pt_regs *regs, long error_code) > +void notrace do_machine_check(struct pt_regs *regs, long error_code) > { > DECLARE_BITMAP(valid_banks, MAX_NR_BANKS); > DECLARE_BITMAP(toclear, MAX_NR_BANKS); > @@ -1360,6 +1366,7 @@ void do_machine_check(struct pt_regs *re > ist_exit(regs); > } > EXPORT_SYMBOL_GPL(do_machine_check); > +NOKPROBE_SYMBOL(do_machine_check); That won't protect all the function called by do_machine_check(), right? There are lots of them.