From patchwork Mon Jun 27 03:06:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 9199839 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 B161C60752 for ; Mon, 27 Jun 2016 03:09:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A69EA28555 for ; Mon, 27 Jun 2016 03:09:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9B14A28564; Mon, 27 Jun 2016 03:09:36 +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 3799F28555 for ; Mon, 27 Jun 2016 03:09:36 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bHMuL-0001Po-Td; Mon, 27 Jun 2016 03:08:21 +0000 Received: from mail-qk0-x231.google.com ([2607:f8b0:400d:c09::231]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bHMtU-0000nx-B2 for linux-arm-kernel@lists.infradead.org; Mon, 27 Jun 2016 03:07:29 +0000 Received: by mail-qk0-x231.google.com with SMTP id t127so194010755qkf.1 for ; Sun, 26 Jun 2016 20:07:08 -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=3A3znK/U18NkpPL3JQ1lgikE2EENm3SqutSm4k8KiEA=; b=UcagyH2tc3e5hLv92jHmbqGkT9dDWCPXxHm9HveIYF6dtmn9dl3LXku1ZBpZkAkqcd 9blOGopMQqxWCpZJ0XXWtv157qoS9zDBPaPwSCzVDaP8qYKDyuGuKeTakm+B+rW1bZiG JESpN13vMfSYablU1L8ijRMy9Xy1GKeUL8SUU= 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=3A3znK/U18NkpPL3JQ1lgikE2EENm3SqutSm4k8KiEA=; b=GXr0bajd8Tkot1DYXnYFsWBX1jaoHUyJ7gWBN/gQtYqdBD03yijnP5GEoUpCp7/f4b ySXfjwFkmYkXM8pZNIRhTUzKimbHDtFKUXugOW6i/psz4TAMWcyXDgp2D/fHSnMYi+I4 hO7PkLiZH5CJZLcnkjzyjjZO78xz6SLBtaxKLlU5G5SNBUji/Vg6aTYI/mTU+9QwjKc3 2lviSv+j10rLYRVtIbfhCfmmgcew5duZPPNn8M4l0+8+3Ln322iRp+WIK8Nvbx+CrCGM TY/16sevyy4pE3bQrIn8QZrbY4fxTqYLoG2/Tzm2x5aFAopATS3qJh+jgkLbSYwfAnp7 IEeA== X-Gm-Message-State: ALyK8tK1LF2jhx0tyDWuqEiyGVdBxh/QTzHToPozSfF7DMp2h/QgU4kiC+JdcQG05u2fl3yk X-Received: by 10.55.43.81 with SMTP id r78mr21103621qkh.50.1466996827252; Sun, 26 Jun 2016 20:07:07 -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 e187sm262769qkf.35.2016.06.26.20.07.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 26 Jun 2016 20:07:06 -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 v14 06/10] arm64: Treat all entry code as non-kprobe-able Date: Sun, 26 Jun 2016 23:06:49 -0400 Message-Id: <1466996813-23295-7-git-send-email-dave.long@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1466996813-23295-1-git-send-email-dave.long@linaro.org> References: <1466996813-23295-1-git-send-email-dave.long@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160626_200728_596781_111E763A X-CRM114-Status: GOOD ( 13.91 ) 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/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/kprobes.c b/arch/arm64/kernel/kprobes/kprobes.c index 189b0d2..ca0c0c9 100644 --- a/arch/arm64/kernel/kprobes/kprobes.c +++ b/arch/arm64/kernel/kprobes/kprobes.c @@ -30,6 +30,7 @@ #include #include #include +#include #include "decode-insn.h" @@ -519,6 +520,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