Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5583604img; Wed, 27 Mar 2019 11:08:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqzzqTdkNfFyg4WnNcpFaa2zSPhQM2k/h56iKRrxz8jlItAtH0vcqii39T04bhpK6vUvJ+vP X-Received: by 2002:a62:174c:: with SMTP id 73mr36740271pfx.33.1553710110119; Wed, 27 Mar 2019 11:08:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553710110; cv=none; d=google.com; s=arc-20160816; b=vg8sLdic79v6cjhfcQZMEtbdW7fi57FVyWlMNtcGbDViji2mvLL9weHLnCa6e2DMnY N+orukm3KHnESviG/Lzzv3cqvZfAZmSjwGPQZ540porcCSo/2OR9s8TyJN5RJ/dxnUTX +R9axd1QsCyAFKTOup7R4b+xve9yLOvSaW7ouBJBZCe+s2G4bIUPmbkgf4qouCySIS7E SFGSuq4SLXU/v7ho/gaMOr6xv/NOJcW2X1YhmsP8hDBHvE7mXErs7l7qEuoiDXOmuLZq OV6qx8g+lTPDQ4mLi9RzkTdKAAZ1716Nn84DylTc9g42yZOI+HtoZzoL57EibozehlSS +aIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=cDBH/uScFg0UyI3X+3tGQDVZ4gZYXNCQ1HBL/SPwTJM=; b=Wfx8e6leZH9FqdsJWrEuJ0DCUl2uA+Fsai18r6NSMoedXOLLXivAlIfeMBWjhN+Vkp AhK3ieedaLQV6WCwgc23+KVmThX/V1GjOBC7vJSZYaxfE2MoE1+JrOHkfpUZ+wV8CpOY 4Mi2veOT+09kgC7frswYtQBL7fye/3FmvbpwudJPQEjw1STsvk/77/pAEudxP9KQhUDy /IexOj7xjBn0FagCT0n74pFbNMtjktRasw1NeCy81v5CejcqeZkqETleI33bpTS6TACk Yc5MrnmBTUyW5IBM91d0qVZFmmQkZYm6mrnt5D/vWoDAZIYGznvL1136E50aeubRjvmn XAQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=eqn5Giw1; 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 d18si5302964pgo.525.2019.03.27.11.08.14; Wed, 27 Mar 2019 11:08:30 -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=eqn5Giw1; 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 S2387452AbfC0SGv (ORCPT + 99 others); Wed, 27 Mar 2019 14:06:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:48478 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388009AbfC0SGp (ORCPT ); Wed, 27 Mar 2019 14:06:45 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (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 D590421734; Wed, 27 Mar 2019 18:06:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553710004; bh=0zeaaPljIQNgHD4p47tYv9YtYYNS+0P6iJy7RfmHxoo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eqn5Giw1AiJL9OQtJDYnPekdvUQGejXuRz2ViIQwWmFEDTCbJCCYyIzuUvi969VM1 Pvlq4CGwvzUoImJkKGwcFgXletoCws63KF8vy5poBDs3ovea3b4a1Z4sTWKy1DF4nO HRTukyJuMHsGts29p3hBPxweNQ2BSuNbsTvk/z60= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Masami Hiramatsu , Alexander Shishkin , Andrea Righi , Arnaldo Carvalho de Melo , Jiri Olsa , Linus Torvalds , Mathieu Desnoyers , Peter Zijlstra , Steven Rostedt , Thomas Gleixner , Ingo Molnar , Sasha Levin Subject: [PATCH AUTOSEL 5.0 152/262] x86/kprobes: Prohibit probing on IRQ handlers directly Date: Wed, 27 Mar 2019 14:00:07 -0400 Message-Id: <20190327180158.10245-152-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327180158.10245-1-sashal@kernel.org> References: <20190327180158.10245-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Masami Hiramatsu [ Upstream commit 0eae81dc9f026d899c70f3931bf3bca6d7aa6938 ] 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 Signed-off-by: Sasha Levin --- 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); } -- 2.19.1