From patchwork Fri Jun 3 03:26:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 9151599 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 478056074E for ; Fri, 3 Jun 2016 03:29:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 38CC827BFA for ; Fri, 3 Jun 2016 03:29:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2CAE22832B; Fri, 3 Jun 2016 03:29:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DFC7627BFA for ; Fri, 3 Jun 2016 03:29:02 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1b8flp-0001cL-10; Fri, 03 Jun 2016 03:27:37 +0000 Received: from mail-qk0-x232.google.com ([2607:f8b0:400d:c09::232]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1b8flD-0001Gb-Nh for linux-arm-kernel@lists.infradead.org; Fri, 03 Jun 2016 03:27:01 +0000 Received: by mail-qk0-x232.google.com with SMTP id u1so1350548qkh.2 for ; Thu, 02 Jun 2016 20:26:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vML5CpbfBRLugA2wE8FJBIQrv56oncsxLAAtmzhgK1Q=; b=ZtSYol9DkeRtTLXEmHDhaGJK+2lX2LCQlJgVryn5e5TiKtQ/QDRgw5S3nMx5kN65Hy kWp6IHJJ6aXauTi1pW0neYfaWDECU8e5/vg/KsRL919I5DV0yP7RT2kMBckiUF7vAPKD 3SEfwLyRbB9skMjvskzh3arG44zbWIVqOXmrA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=vML5CpbfBRLugA2wE8FJBIQrv56oncsxLAAtmzhgK1Q=; b=djfwWzaQeBZW0I7Ev3AyqPlW2W5/QU0eOdlF42B5UgUgTQOTyAeqrMF9EfixTF0I4w l0pfYrEKE1Q4TFiVlJB4MmmpvAyh36dXE9Q9RRtw/AGVWACnH/4FNqgTrqA3FpIAJzDD gTLqlN0WW+jyZTrD5h5yHQYN5xK0Y9tCAMkKG+j92RdNGaILUD+RJIixY/EtjNIpt0yP UuXyff43oUu4G5j1aBgwbIBOTXH2v6NcddwvXWYq95K/ij4/l9ZOy+G0QdlqmnRkXo0O Dys4L0xjsjSK0uNtOMOHinmFQcJp2vmTFRR2IehZmOPkwZ6ngSR0dhT4nuMhT7s97j4d RWwQ== X-Gm-Message-State: ALyK8tLyjwJ/HDd4Kh+fFQ1U1v/m+q7K0Ztr7HhfDwYYDtkL3K2KeefcE2n1LrgxyJjhSRcJ X-Received: by 10.55.160.211 with SMTP id j202mr1387143qke.0.1464924398666; Thu, 02 Jun 2016 20:26:38 -0700 (PDT) Received: from localhost.localdomain (pool-72-71-243-181.cncdnh.fast00.myfairpoint.net. [72.71.243.181]) by smtp.googlemail.com with ESMTPSA id 30sm359841qgx.19.2016.06.02.20.26.37 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 02 Jun 2016 20:26:38 -0700 (PDT) From: David Long To: Catalin Marinas , Huang Shijie , James Morse , Marc Zyngier , Pratyush Anand , Sandeepa Prabhu , Will Deacon , William Cohen , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Steve Capper , Masami Hiramatsu , Li Bin Subject: [PATCH v13 06/10] arm64: Treat all entry code as non-kprobe-able Date: Thu, 2 Jun 2016 23:26:20 -0400 Message-Id: <1464924384-15269-7-git-send-email-dave.long@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1464924384-15269-1-git-send-email-dave.long@linaro.org> References: <1464924384-15269-1-git-send-email-dave.long@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160602_202700_020831_A06AF434 X-CRM114-Status: GOOD ( 13.70 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jisheng Zhang , Mark Rutland , Daniel Thompson , Vladimir Murzin , Petr Mladek , Ard Biesheuvel , Jens Wiklander , Robin Murphy , Mark Brown , Suzuki K Poulose , Dave P Martin , Andrey Ryabinin , yalin wang , Yang Shi , Zi Shen Lim , John Blackwood , Andrew Morton , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Adam Buchbinder , Christoffer Dall MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Pratyush Anand Entry symbols are not kprobe safe. So blacklist them for kprobing. Signed-off-by: Pratyush Anand Signed-off-by: David A. Long Acked-by: Masami Hiramatsu --- arch/arm64/kernel/entry.S | 3 +++ arch/arm64/kernel/kprobes.c | 26 ++++++++++++++++++++++++++ arch/arm64/kernel/vmlinux.lds.S | 1 + 3 files changed, 30 insertions(+) diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index 12e8d2b..7d99bed 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -243,6 +243,7 @@ tsk .req x28 // current thread_info * Exception vectors. */ + .pushsection ".entry.text", "ax" .align 11 ENTRY(vectors) ventry el1_sync_invalid // Synchronous EL1t @@ -781,3 +782,5 @@ ENTRY(sys_rt_sigreturn_wrapper) mov x0, sp b sys_rt_sigreturn ENDPROC(sys_rt_sigreturn_wrapper) + + .popsection diff --git a/arch/arm64/kernel/kprobes.c b/arch/arm64/kernel/kprobes.c index 49b06cf..ba43623 100644 --- a/arch/arm64/kernel/kprobes.c +++ b/arch/arm64/kernel/kprobes.c @@ -30,6 +30,7 @@ #include #include #include +#include #include "kprobes-arm64.h" @@ -520,6 +521,31 @@ int __kprobes longjmp_break_handler(struct kprobe *p, struct pt_regs *regs) return 1; } +bool arch_within_kprobe_blacklist(unsigned long addr) +{ + extern char __idmap_text_start[], __idmap_text_end[]; + extern char __hyp_idmap_text_start[], __hyp_idmap_text_end[]; + + if ((addr >= (unsigned long)__kprobes_text_start && + addr < (unsigned long)__kprobes_text_end) || + (addr >= (unsigned long)__entry_text_start && + addr < (unsigned long)__entry_text_end) || + (addr >= (unsigned long)__idmap_text_start && + addr < (unsigned long)__idmap_text_end) || + !!search_exception_tables(addr)) + return true; + + if (!is_kernel_in_hyp_mode()) { + if ((addr >= (unsigned long)__hyp_text_start && + addr < (unsigned long)__hyp_text_end) || + (addr >= (unsigned long)__hyp_idmap_text_start && + addr < (unsigned long)__hyp_idmap_text_end)) + return true; + } + + return false; +} + int __init arch_init_kprobes(void) { return 0; diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S index 075ce32..9f59394 100644 --- a/arch/arm64/kernel/vmlinux.lds.S +++ b/arch/arm64/kernel/vmlinux.lds.S @@ -118,6 +118,7 @@ SECTIONS __exception_text_end = .; IRQENTRY_TEXT SOFTIRQENTRY_TEXT + ENTRY_TEXT TEXT_TEXT SCHED_TEXT LOCK_TEXT