Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp103914imj; Wed, 13 Feb 2019 05:28:14 -0800 (PST) X-Google-Smtp-Source: AHgI3IZ2MzaLsSTxMXQtYjzefIagcTyZt82ye0wtv9mmQBCWjQQDDWfheFmu0oZ7OhdfxSQC2UYH X-Received: by 2002:a62:2606:: with SMTP id m6mr490510pfm.133.1550064494737; Wed, 13 Feb 2019 05:28:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550064494; cv=none; d=google.com; s=arc-20160816; b=qHGJpkPE8AYJgwedWhnNRKp6AYxsyM5+8Yh50UsbFayYlHczeurVMGmpsp+XljLWuR k/V9oqmQxKkgCVzQ37h5bdEIAsCpJSiig8fNrSq4H8Bh2uFrHXgCu2zr0uX7Oj85nRr/ nyjfK4wmXS4fAeyQjs0Ipz7M5eid2LZKElE0N1DTMjoSl6IK9rV9kZ2oHRKZPaTxnDET 9IIW/w4JX6jDAcAMAU9HkzIhgw6OsZrQi9DCCiEEC8FoJBtEFDrGPmWuL2INhOXioBna Qc4EhVCO9+ol0zzzKAASpjtImmdyb4XpOLngKAlBstz4UlxXxxlACIP2ibeN05Fi0bh/ BBWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date; bh=gDunuSTpmw7FmAEP/BftQpd+Kr9dYohPpOmprQkXi/c=; b=aMBQ1DxbjDvTC8e4ohQwjcbDowCokqwItYXPthamGKdOJ0y1KENtKTXwx0eXqj5QgT y5G0ytD1iORoNEk2jdoh8DyomWz5K4QpzSnb4pfNfyYHkmeoOk7iPoJwvIzRvHI5xerF LmPYKfi7huciPbGZfJCPFQNC5drzubMdSgluxNRBN1hcQt2nlG4mh/AUoecscXyUo5iZ sOFz/sAtxP/H72yTFAtH8Fbuku7dqW4krZ9itxBERAs5oXbktBkI2XUnLr7Xc4lqlENx E4jDJEZeCi/VAz2zccHUPcpOTulN4e+INM8ti7brOUAGRX/S5YFuG9EbMKJ0mY8JyIdr jx8A== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y26si16400379pfd.25.2019.02.13.05.27.53; Wed, 13 Feb 2019 05:28:14 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391127AbfBMJCB (ORCPT + 99 others); Wed, 13 Feb 2019 04:02:01 -0500 Received: from terminus.zytor.com ([198.137.202.136]:52097 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731952AbfBMJCB (ORCPT ); Wed, 13 Feb 2019 04:02:01 -0500 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id x1D91O3N196166 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 13 Feb 2019 01:01:24 -0800 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id x1D91Oo6196163; Wed, 13 Feb 2019 01:01:24 -0800 Date: Wed, 13 Feb 2019 01:01:24 -0800 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Masami Hiramatsu Message-ID: Cc: mathieu.desnoyers@efficios.com, mhiramat@kernel.org, tglx@linutronix.de, linux-kernel@vger.kernel.org, acme@redhat.com, righi.andrea@gmail.com, torvalds@linux-foundation.org, peterz@infradead.org, rostedt@goodmis.org, mingo@kernel.org, hpa@zytor.com, jolsa@redhat.com, alexander.shishkin@linux.intel.com Reply-To: linux-kernel@vger.kernel.org, tglx@linutronix.de, acme@redhat.com, mhiramat@kernel.org, mathieu.desnoyers@efficios.com, peterz@infradead.org, rostedt@goodmis.org, alexander.shishkin@linux.intel.com, jolsa@redhat.com, hpa@zytor.com, mingo@kernel.org, righi.andrea@gmail.com, torvalds@linux-foundation.org In-Reply-To: <154998799234.31052.6136378903570418008.stgit@devbox> References: <154998799234.31052.6136378903570418008.stgit@devbox> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] kprobes: Search non-suffixed symbol in blacklist Git-Commit-ID: 6143c6fb1e8f9bde9c434038f7548a19d36b55e7 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-0.8 required=5.0 tests=ALL_TRUSTED,BAYES_00, FREEMAIL_FORGED_REPLYTO,T_DATE_IN_FUTURE_96_Q autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 6143c6fb1e8f9bde9c434038f7548a19d36b55e7 Gitweb: https://git.kernel.org/tip/6143c6fb1e8f9bde9c434038f7548a19d36b55e7 Author: Masami Hiramatsu AuthorDate: Wed, 13 Feb 2019 01:13:12 +0900 Committer: Ingo Molnar CommitDate: Wed, 13 Feb 2019 08:16:40 +0100 kprobes: Search non-suffixed symbol in blacklist Newer GCC versions can generate some different instances of a function with suffixed symbols if the function is optimized and only has a part of that. (e.g. .constprop, .part etc.) In this case, it is not enough to check the entry of kprobe blacklist because it only records non-suffixed symbol address. To fix this issue, search non-suffixed symbol in blacklist if given address is within a symbol which has a suffix. Note that this can cause false positive cases if a kprobe-safe function is optimized to suffixed instance and has same name symbol which is blacklisted. But I would like to chose a fail-safe design for this issue. Signed-off-by: Masami Hiramatsu Reviewed-by: Steven Rostedt (VMware) 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/154998799234.31052.6136378903570418008.stgit@devbox Signed-off-by: Ingo Molnar --- kernel/kprobes.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/kernel/kprobes.c b/kernel/kprobes.c index f4ddfdd2d07e..c83e54727131 100644 --- a/kernel/kprobes.c +++ b/kernel/kprobes.c @@ -1396,7 +1396,7 @@ bool __weak arch_within_kprobe_blacklist(unsigned long addr) addr < (unsigned long)__kprobes_text_end; } -bool within_kprobe_blacklist(unsigned long addr) +static bool __within_kprobe_blacklist(unsigned long addr) { struct kprobe_blacklist_entry *ent; @@ -1410,7 +1410,26 @@ bool within_kprobe_blacklist(unsigned long addr) if (addr >= ent->start_addr && addr < ent->end_addr) return true; } + return false; +} +bool within_kprobe_blacklist(unsigned long addr) +{ + char symname[KSYM_NAME_LEN], *p; + + if (__within_kprobe_blacklist(addr)) + return true; + + /* Check if the address is on a suffixed-symbol */ + if (!lookup_symbol_name(addr, symname)) { + p = strchr(symname, '.'); + if (!p) + return false; + *p = '\0'; + addr = (unsigned long)kprobe_lookup_name(symname, 0); + if (addr) + return __within_kprobe_blacklist(addr); + } return false; }