Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2514039imm; Thu, 7 Jun 2018 11:57:37 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLQyal2TMJGTIIXlbd7e7oDJQ11H++jU1RcDEH20OCQPaB8UlMJHX81yOHEkU/RCRX+ow4U X-Received: by 2002:a65:46cb:: with SMTP id n11-v6mr2471497pgr.193.1528397857441; Thu, 07 Jun 2018 11:57:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528397857; cv=none; d=google.com; s=arc-20160816; b=gNj77sXeRXJm0fLKDDSk75WKE/8H0UZwCXMLbyeaOrCwcjlth1VGLkeUxVw4dHLlxe dZxxYKN2/xJ8Za62RU7buV0IiqAaynbcKSwStJw7gAUWocJ2l7JpJWWYMvU/G97L/7mE Q0YJD5bpZ5PtBf0giGUGiczMOQ4dCxAy8peqgzPhNFXbIrfN7YgiL9EyLUB/cZoPAQSH JpsPFTbjvUFCohz4CjWaywfqoOL+nNTKsjjpn0nIOfCZB7btD5MYCF341Ja0DjVTawtz E7sfphz7ymcUH4UzqqSoFZSqDJTzhwBrxSosBCB4ZZd7p3rGthLe8zodQ+1Hju0LQ8gM 3QlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=rN0JbrqJTcjSryfFLXqLm2Ob25h8IlHAyIu+9bamz6k=; b=Oc+z9Qh6ujE+41/RbjXAoANUf2WLJn6oeEG0ivk5YNsVzl2priZQXAELoyL7SKjTSI YpxX2vd3NYuazgYqm56fE0l4H1VG8p3X2CqFhV+SiiAk/M2PbPjSu68DGAaDN8supsfU 9nhasgttaeQ2+b15K+OzgcI8Jg8r1LAdONQGyPZApJjw+//FwUhD1QeZv+IBN0d0sgCz jOdtQU3ZcxaJdVbZ653olMRtEwAzeyWe/vj5t9KulLhIfPdo2klzVV730z3J/KdLXKGo vUF1t94gZGpc1WFMnXRZWWh05dWIw/HARr2J3Kaf2/pOd8AW0EkFyJgxC6wqlYVw/aPQ jcgA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u59-v6si54444708plb.253.2018.06.07.11.57.23; Thu, 07 Jun 2018 11:57:37 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934874AbeFGQML (ORCPT + 99 others); Thu, 7 Jun 2018 12:12:11 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:39168 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932970AbeFGOJB (ORCPT ); Thu, 7 Jun 2018 10:09:01 -0400 Received: from [148.252.241.226] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1fQvb1-0005a0-Gb; Thu, 07 Jun 2018 15:08:59 +0100 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1fQvay-0002ir-82; Thu, 07 Jun 2018 15:08:56 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Thomas Gleixner" , "Linus Torvalds" , "Andy Lutomirski" Date: Thu, 07 Jun 2018 15:05:21 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 034/410] x86/entry/64: Don't use IST entry for #BP stack In-Reply-To: X-SA-Exim-Connect-IP: 148.252.241.226 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.57-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Andy Lutomirski commit d8ba61ba58c88d5207c1ba2f7d9a2280e7d03be9 upstream. There's nothing IST-worthy about #BP/int3. We don't allow kprobes in the small handful of places in the kernel that run at CPL0 with an invalid stack, and 32-bit kernels have used normal interrupt gates for #BP forever. Furthermore, we don't allow kprobes in places that have usergs while in kernel mode, so "paranoid" is also unnecessary. Signed-off-by: Andy Lutomirski Signed-off-by: Linus Torvalds Signed-off-by: Thomas Gleixner [carnil: Backport to 3.16: - Adjust finename change: arch/x86/kernel/entry_64.S - Context changes ] [bwh: Rebase on top of "x86/traps: Enable DEBUG_STACK after cpu_init() for TRAP_DB/BP", and restore change in trap_init() instead of early_trap_init()] Signed-off-by: Ben Hutchings --- --- a/arch/x86/kernel/entry_64.S +++ b/arch/x86/kernel/entry_64.S @@ -1322,7 +1322,7 @@ apicinterrupt3 HYPERVISOR_CALLBACK_VECTO #endif /* CONFIG_HYPERV */ idtentry debug do_debug has_error_code=0 paranoid=1 shift_ist=DEBUG_STACK -idtentry int3 do_int3 has_error_code=0 paranoid=1 shift_ist=DEBUG_STACK +idtentry int3 do_int3 has_error_code=0 idtentry stack_segment do_stack_segment has_error_code=1 #ifdef CONFIG_XEN idtentry xen_debug do_debug has_error_code=0 --- a/arch/x86/kernel/traps.c +++ b/arch/x86/kernel/traps.c @@ -334,7 +334,6 @@ exit: } NOKPROBE_SYMBOL(do_general_protection); -/* May run on IST stack. */ dotraplinkage void notrace do_int3(struct pt_regs *regs, long error_code) { enum ctx_state prev_state; @@ -367,15 +366,9 @@ dotraplinkage void notrace do_int3(struc SIGTRAP) == NOTIFY_STOP) goto exit; - /* - * Let others (NMI) know that the debug stack is in use - * as we may switch to the interrupt stack. - */ - debug_stack_usage_inc(); preempt_conditional_sti(regs); do_trap(X86_TRAP_BP, SIGTRAP, "int3", regs, error_code, NULL); preempt_conditional_cli(regs); - debug_stack_usage_dec(); exit: exception_exit(prev_state); } @@ -862,19 +855,16 @@ void __init trap_init(void) cpu_init(); /* - * X86_TRAP_DB and X86_TRAP_BP have been set - * in early_trap_init(). However, DEBUG_STACK works only after - * cpu_init() loads TSS. See comments in early_trap_init(). + * X86_TRAP_DB was installed in early_trap_init(). However, + * DEBUG_STACK works only after cpu_init() loads TSS. See comments + * in early_trap_init(). */ set_intr_gate_ist(X86_TRAP_DB, &debug, DEBUG_STACK); - /* int3 can be called from all */ - set_system_intr_gate_ist(X86_TRAP_BP, &int3, DEBUG_STACK); x86_init.irqs.trap_init(); #ifdef CONFIG_X86_64 memcpy(&debug_idt_table, &idt_table, IDT_ENTRIES * 16); set_nmi_gate(X86_TRAP_DB, &debug); - set_nmi_gate(X86_TRAP_BP, &int3); #endif }