Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2796766ybk; Tue, 12 May 2020 08:21:12 -0700 (PDT) X-Google-Smtp-Source: APiQypLTaFR8mKTpZqVuGJSHPtIKjOpx1hzA8vMwzdEZ3BMLg+KGhzPGyg2mSYrSNVBmDmq6R6Fc X-Received: by 2002:a17:907:948d:: with SMTP id dm13mr19008610ejc.138.1589296872300; Tue, 12 May 2020 08:21:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589296872; cv=none; d=google.com; s=arc-20160816; b=Nfx0YcVAULILb4w5bHDq2iR5ooq3BQnOTE6eCmtuSSvo1SkKlg5UK+ObnJFuZjoc5q dE0BibA8Ph7IxOMz6JjQGIVAYAnZ6lDMCNXUXn+9/3rGZPMXlKNxjYzYGmM5nvY50sdy w28lOuMUTTB4tG3JFheqr0N78p5h2s7kzDeHN07zCsqmKA0N77jbZQhVQZQ9GMMpIqqQ osR9ui//y++CMU7WOgskeaUujpvW9Y0M4C3fqOdVdl6rkcKd7x2r31n6QuNilljegwun mtCZ5SdlQ8N8q8VDXnW64Q7fXMK3ha46yJj2A/Dgdn8om6EUk8ybxzW7w/KUHkjXPhXX qxDg== 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 :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=mizMmvjmUFGGrYBWOBBZ1Q1YkhbEEGNG9lV+i8VIoTY=; b=qckyLp/dWQ95AM+EMY3PzAWXNYbntLqh8p7PSa/Y8BCBeElJw/ZCSMisPu/5AI6bJO +QVs/jLlf8XOeGlyyYYKI42VZW0E5POyfocLmwWLU8D3+FenUPT3y96YXXJ4v7Ayg9EC MVqfCd7RvaVcXUNVrffCzp5q9zdwwTEUEG6mTxWPVv2K+Yy0iYrnWjokxXIybqzrVscy AF0JjpoG8pVh3H/z6v964nS93+IPkGrxAQjw3LLhZZctX+IEhMWMnOofxCxV7ZTCslE5 tbyyzftu8w8/hwBQLI53dC6uw6bQb5XxRmE/0/3e1SL8KHKESg8V8oQn0sQakSJWntvz QszQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w15si7557801edi.597.2020.05.12.08.20.48; Tue, 12 May 2020 08:21:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728008AbgELPTD (ORCPT + 99 others); Tue, 12 May 2020 11:19:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726055AbgELPTC (ORCPT ); Tue, 12 May 2020 11:19:02 -0400 Received: from Galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73B15C061A0E; Tue, 12 May 2020 08:19:02 -0700 (PDT) Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1jYWgN-0007Da-11; Tue, 12 May 2020 17:18:59 +0200 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id 8CA8D1C0475; Tue, 12 May 2020 17:18:58 +0200 (CEST) Date: Tue, 12 May 2020 15:18:58 -0000 From: "tip-bot2 for Masami Hiramatsu" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: core/kprobes] kprobes: Support NOKPROBE_SYMBOL() in modules Cc: Masami Hiramatsu , Thomas Gleixner , Alexandre Chartre , Peter Zijlstra , x86 , LKML In-Reply-To: <20200505134059.771170126@linutronix.de> References: <20200505134059.771170126@linutronix.de> MIME-Version: 1.0 Message-ID: <158929673850.390.3433747204484607858.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the core/kprobes branch of tip: Commit-ID: 16db6264c93d2d7df9eb8be5d9eb717ab30105fe Gitweb: https://git.kernel.org/tip/16db6264c93d2d7df9eb8be5d9eb717ab30105fe Author: Masami Hiramatsu AuthorDate: Thu, 26 Mar 2020 23:50:00 +09:00 Committer: Thomas Gleixner CommitterDate: Tue, 12 May 2020 17:15:32 +02:00 kprobes: Support NOKPROBE_SYMBOL() in modules Support NOKPROBE_SYMBOL() in modules. NOKPROBE_SYMBOL() records only symbol address in "_kprobe_blacklist" section in the module. Signed-off-by: Masami Hiramatsu Signed-off-by: Thomas Gleixner Reviewed-by: Alexandre Chartre Acked-by: Peter Zijlstra Link: https://lkml.kernel.org/r/20200505134059.771170126@linutronix.de --- include/linux/module.h | 2 ++ kernel/kprobes.c | 17 +++++++++++++++++ kernel/module.c | 3 +++ 3 files changed, 22 insertions(+) diff --git a/include/linux/module.h b/include/linux/module.h index 369c354..1192097 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -492,6 +492,8 @@ struct module { #ifdef CONFIG_KPROBES void *kprobes_text_start; unsigned int kprobes_text_size; + unsigned long *kprobe_blacklist; + unsigned int num_kprobe_blacklist; #endif #ifdef CONFIG_LIVEPATCH diff --git a/kernel/kprobes.c b/kernel/kprobes.c index b754999..9eb5acf 100644 --- a/kernel/kprobes.c +++ b/kernel/kprobes.c @@ -2192,6 +2192,11 @@ static void kprobe_remove_area_blacklist(unsigned long start, unsigned long end) } } +static void kprobe_remove_ksym_blacklist(unsigned long entry) +{ + kprobe_remove_area_blacklist(entry, entry + 1); +} + int __init __weak arch_populate_kprobe_blacklist(void) { return 0; @@ -2231,6 +2236,12 @@ static int __init populate_kprobe_blacklist(unsigned long *start, static void add_module_kprobe_blacklist(struct module *mod) { unsigned long start, end; + int i; + + if (mod->kprobe_blacklist) { + for (i = 0; i < mod->num_kprobe_blacklist; i++) + kprobe_add_ksym_blacklist(mod->kprobe_blacklist[i]); + } start = (unsigned long)mod->kprobes_text_start; if (start) { @@ -2242,6 +2253,12 @@ static void add_module_kprobe_blacklist(struct module *mod) static void remove_module_kprobe_blacklist(struct module *mod) { unsigned long start, end; + int i; + + if (mod->kprobe_blacklist) { + for (i = 0; i < mod->num_kprobe_blacklist; i++) + kprobe_remove_ksym_blacklist(mod->kprobe_blacklist[i]); + } start = (unsigned long)mod->kprobes_text_start; if (start) { diff --git a/kernel/module.c b/kernel/module.c index 978f3fa..faf7337 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -3197,6 +3197,9 @@ static int find_module_sections(struct module *mod, struct load_info *info) #ifdef CONFIG_KPROBES mod->kprobes_text_start = section_objs(info, ".kprobes.text", 1, &mod->kprobes_text_size); + mod->kprobe_blacklist = section_objs(info, "_kprobe_blacklist", + sizeof(unsigned long), + &mod->num_kprobe_blacklist); #endif mod->extable = section_objs(info, "__ex_table", sizeof(*mod->extable), &mod->num_exentries);