Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp105742imj; Wed, 13 Feb 2019 05:29:59 -0800 (PST) X-Google-Smtp-Source: AHgI3IbFJbPw8OSs2bo0wW3cn/P2/kEzvET7+Bs7tHB/1nABFMM42QCor2thTVfNhal16/hvYypu X-Received: by 2002:a62:170b:: with SMTP id 11mr515573pfx.47.1550064599502; Wed, 13 Feb 2019 05:29:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550064599; cv=none; d=google.com; s=arc-20160816; b=HRmT7j5WUd5mjIOqiycHxPbZsERlPoOQG1y/RisjicY0+IbXUZm2GbYN30BB4vERSK l6MabU57u9so0M7KmCqcgYjCzFun53P38SFu3e5FMMPqVpBZN/MRXfj92ZdOkc3/FYBw FlNUGGl/ghSal3fqkSluDr4jQZlp16sCw4DwQ3a11h0FkxhSxTIXZKrkpVaMCgTmf9tH /dnZAa70s9eWKcuJtwhkZW/X+9fVrSzxXVN5g7U7rfSIW4zCI+uM4KwLC+49W/zbDdrX yT8klCYuH1WGcDmKjUi9fdtKLtdj1lTn9c/6TcUPs2i3fVD9c1+JAltRK/LASFuvyOKs Ay7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date; bh=Exp7HL6rKigfEMr1e9pw1zF93s0rm58W/zt9WGcSi0M=; b=aRvW+nE4gXMSbU3PAdqJ1jGWCSPLPmGqlYTXOBxLIWFko+hwSpT25v5wC/c5f4KQy/ eC0dGdtAFayWoeghfyhv3/ECkSnYfQv0+2VOHmqzjsembO1MmmXC0PYYm490QhrpiqKK zaXbLy7Pq2mzvzQr+MkPyZ6QYP6GLj/+B3m6UMfMkxspQJl1myY7tNtiZfZslcJj6+dz Ds5PIU7RfRPLZfsNKEdWxtO7BG6lL099n43oTvfI6giipoNDQDrylUnlW4TNUex/kbbI AddlFFXUWnwesRyVwgz8MV7R96SXRUXYv2qvI9Yh/B4FNdDEjRoGzErofyC5TRpJVocX S1gQ== 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 d22si16383831plr.340.2019.02.13.05.29.41; Wed, 13 Feb 2019 05:29:59 -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; 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 S2391157AbfBMJCb (ORCPT + 99 others); Wed, 13 Feb 2019 04:02:31 -0500 Received: from terminus.zytor.com ([198.137.202.136]:57651 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729117AbfBMJCa (ORCPT ); Wed, 13 Feb 2019 04:02:30 -0500 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id x1D90l8o196091 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 13 Feb 2019 01:00:47 -0800 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id x1D90llS196088; Wed, 13 Feb 2019 01:00:47 -0800 Date: Wed, 13 Feb 2019 01:00:47 -0800 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Masami Hiramatsu Message-ID: Cc: mathieu.desnoyers@efficios.com, rostedt@goodmis.org, righi.andrea@gmail.com, mhiramat@kernel.org, mingo@kernel.org, hpa@zytor.com, linux-kernel@vger.kernel.org, acme@redhat.com, peterz@infradead.org, torvalds@linux-foundation.org, jolsa@redhat.com, alexander.shishkin@linux.intel.com, tglx@linutronix.de Reply-To: mhiramat@kernel.org, hpa@zytor.com, mingo@kernel.org, linux-kernel@vger.kernel.org, mathieu.desnoyers@efficios.com, rostedt@goodmis.org, righi.andrea@gmail.com, tglx@linutronix.de, acme@redhat.com, peterz@infradead.org, alexander.shishkin@linux.intel.com, jolsa@redhat.com, torvalds@linux-foundation.org In-Reply-To: <154998796400.31052.8406236614820687840.stgit@devbox> References: <154998796400.31052.8406236614820687840.stgit@devbox> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] x86/kprobes: Prohibit probing on IRQ handlers directly Git-Commit-ID: 0eae81dc9f026d899c70f3931bf3bca6d7aa6938 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-0.8 required=5.0 tests=ALL_TRUSTED,BAYES_00, FREEMAIL_FORGED_REPLYTO,T_DATE_IN_FUTURE_96_Q autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 0eae81dc9f026d899c70f3931bf3bca6d7aa6938 Gitweb: https://git.kernel.org/tip/0eae81dc9f026d899c70f3931bf3bca6d7aa6938 Author: Masami Hiramatsu AuthorDate: Wed, 13 Feb 2019 01:12:44 +0900 Committer: Ingo Molnar CommitDate: Wed, 13 Feb 2019 08:16:39 +0100 x86/kprobes: Prohibit probing on IRQ handlers directly Prohibit probing on IRQ handlers in irqentry_text because if it interrupts user mode, at that point we haven't changed to kernel space yet and which eventually leads a double fault. E.g. # echo p apic_timer_interrupt > kprobe_events # echo 1 > events/kprobes/enable PANIC: double fault, error_code: 0x0 CPU: 1 PID: 814 Comm: less Not tainted 4.20.0-rc3+ #30 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996) RIP: 0010:error_entry+0x12/0xf0 [snip] Call Trace: ? native_iret+0x7/0x7 ? async_page_fault+0x8/0x30 ? trace_hardirqs_on_thunk+0x1c/0x1c ? error_entry+0x7c/0xf0 ? async_page_fault+0x8/0x30 ? native_iret+0x7/0x7 ? int3+0xa/0x20 ? trace_hardirqs_on_thunk+0x1c/0x1c ? error_entry+0x7c/0xf0 ? int3+0xa/0x20 ? apic_timer_interrupt+0x1/0x20 Kernel panic - not syncing: Machine halted. Kernel Offset: disabled ---[ end Kernel panic - not syncing: Machine halted. ]--- Signed-off-by: Masami Hiramatsu Cc: Alexander Shishkin Cc: Andrea Righi Cc: Arnaldo Carvalho de Melo Cc: Jiri Olsa Cc: Linus Torvalds Cc: Mathieu Desnoyers Cc: Peter Zijlstra Cc: Steven Rostedt Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/154998796400.31052.8406236614820687840.stgit@devbox Signed-off-by: Ingo Molnar --- arch/x86/kernel/kprobes/core.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c index 4ba75afba527..a034cb808e7e 100644 --- a/arch/x86/kernel/kprobes/core.c +++ b/arch/x86/kernel/kprobes/core.c @@ -1028,6 +1028,13 @@ NOKPROBE_SYMBOL(kprobe_fault_handler); int __init arch_populate_kprobe_blacklist(void) { + int ret; + + ret = kprobe_add_area_blacklist((unsigned long)__irqentry_text_start, + (unsigned long)__irqentry_text_end); + if (ret) + return ret; + return kprobe_add_area_blacklist((unsigned long)__entry_text_start, (unsigned long)__entry_text_end); }