Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp4004524imj; Tue, 12 Feb 2019 08:13:58 -0800 (PST) X-Google-Smtp-Source: AHgI3IYUT/onXvrrUyff/fVfpqKnN5O8mfLUfLbiIA7gQIXBHIoqqSaRCS0Dc+wnDBrxth5U+uCq X-Received: by 2002:a17:902:b690:: with SMTP id c16mr4852787pls.230.1549988038571; Tue, 12 Feb 2019 08:13:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549988038; cv=none; d=google.com; s=arc-20160816; b=SvmKe/DZCywFbT8Bf4DxjbLa9kp++1nwkrqPnriDpCTL6KO3j2FUsCqiuUfQLw2gfm O60quizD6uaJqR596XO+UwNks2IwoQJNHWNKJaLwvGl911bVkkPHQSZbiwK1wxeb59dy 3xaIzZ/uNbRNUi4WwtzFQmDWqsdWiZZHs3NKF3rOkWEYcHCuuI4LVYmpVLONX1ntIQab HN/xSEIjmgi/qiAnRtOWy/2ilgJFxsigp8sTxTOuh+Fev09AK+QR+7XctFV9JmpT8r5I +/adXIVWfavv9Krnq/l8+jHlSHaacqShZIn1H0Cmnud2Sc4d2lfMPLJ9s6ytMg98Pnj5 lFLQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=itoW90FtLhL9r+IW8sFDXe2z7aEJ/l6So9ccJyzQ9Mo=; b=Q9Dpkkq8G9regmv9wIsZgcwr8CX4lZmNCxTIwQ7tbAtH72+3NHCJcra1ZGrBYA5YpZ IgKbfht+Av7wKCNN4elhl3ANjMV0Ldmyi+HwesyMeoUD5ESStW/HbUbK4EeYEOyoM9WX LeGhrQLs8dnNASVKb9i+UWCIYCtXrGIVLQ8zdkUi9NHrYq+ZlfWtMnR56d/XRqXWyqyu UhrQCeHpiZAZJee6yCD1ADMMtHhIbZfXVqAZpBhce1pXOdUM1RyorsPdlmN5J/dZaNR3 DcfiTUC8HinPYOrP1Q2MCa3+qAdJ1tt7yMVnEA1FxUc38IEuM5j3oZ0MTX10JgJPp3Jt X2ZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=l5Ssxplz; 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 l7si12835552pgk.169.2019.02.12.08.13.42; Tue, 12 Feb 2019 08:13:58 -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=l5Ssxplz; 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 S1730917AbfBLQNI (ORCPT + 99 others); Tue, 12 Feb 2019 11:13:08 -0500 Received: from mail.kernel.org ([198.145.29.99]:41716 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728585AbfBLQNH (ORCPT ); Tue, 12 Feb 2019 11:13:07 -0500 Received: from localhost.localdomain (NE2965lan1.rev.em-net.ne.jp [210.141.244.193]) (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 EDE7F217D9; Tue, 12 Feb 2019 16:13:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549987987; bh=kzavcezCbKBHZ9idEgPliuBsrGnUcbV3KzcyJwVlSGQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l5Ssxplz/C+ydomM5LG0M+w9OPxqtK/1hRGNKRYLU/NCDkzV2ohRNlIHRqQygB92J 4K2yUmxbIlpZ3agAOVAdcyHl8YvEKmoyHsXmQ5gxCBgovlUIz6uzTsz4oRHxBg9IiO xqpwZDa18fSlEh8KbMtZTxzb+kfj1jbqR+DJr6JE= From: Masami Hiramatsu To: Ingo Molnar Cc: Masami Hiramatsu , peterz@infradead.org, Mathieu Desnoyers , linux-kernel , Andrea Righi , Steven Rostedt Subject: [PATCH -tip v3 04/10] x86/kprobes: Prohibit probing on IRQ handlers directly Date: Wed, 13 Feb 2019 01:12:44 +0900 Message-Id: <154998796400.31052.8406236614820687840.stgit@devbox> X-Mailer: git-send-email 2.13.6 In-Reply-To: <154998785011.31052.1475728497912659748.stgit@devbox> References: <154998785011.31052.1475728497912659748.stgit@devbox> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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); }