Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2508967imm; Mon, 24 Sep 2018 05:40:02 -0700 (PDT) X-Google-Smtp-Source: ACcGV63RLrRKcgkPoq5Vk96Kb0xpAbXAKahVYo5OexpecQlt/dktE0pCdFpJp+qlfedJ5KX5Foz1 X-Received: by 2002:a17:902:8c85:: with SMTP id t5-v6mr10684531plo.17.1537792802528; Mon, 24 Sep 2018 05:40:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537792802; cv=none; d=google.com; s=arc-20160816; b=gvoiw1yIzJZmZT5+iDUY+u/rH9oXQV9dM4MuecDsNIhfLRofZ/64o0GSraTqXSSX3Z JtIRZ8PMRrLgTeLSKbMnGE5M8+iZvvZqihnLazPQZpus3x2ky+PLo/lSWmPcp6CiQ3Cv +gWaILrMs4vmtPpYSQgGVJT1azqcdZyRg6reZRG3/MYxG8WNn5lcGX8sonZI8yXfw6sU 7cFX68XOy2C3Vdf2i/+9FosYMr7ACL3bF6l2qtpTMVIa/mSLDXRe3AAlnFIQZqXLJLNL /G8mfWN72f0n9YRKocI8cBRVgISfx3fCAaGelHcjEx0KSEYWJXNDJRvxSyn7RzSbr15w MsWg== 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; bh=d2PSVB3J3LpeEyNdN/uXJ5DIZiCu3qRKBcbT4lW2m4s=; b=MobUq+US/ENmsvb3qpaD0xU3eBprY8Lnzpi+ewsmbpONTg7wUT2mmHmorFDIJoHv0d DAZUy979dv6YkukAYZKLsGyXOE4/TxyCEJXbxBmXRgrYT76D0kNuah+peioKTUig/4c8 Tp4O2+VJ+bA5d9zDWfWeFOJoygdqSLalRlMh/Mwyykt89YDV2pFy6XAtnoYwOxnZzrQm ozSsTisZDHI6bGpUnTCxNPLIu5dMMnocKRWlf9cYLed5yCrh6qh0TJTTVSt4IyuFs+wz 4oCauLEjkuAO3SWaSsQ/NnJJ2goh82Lz5sGvq7i8eU2SINM/rd2anY7YLjLpNB6em1td cGiw== 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 m10-v6si30905523pgv.374.2018.09.24.05.39.46; Mon, 24 Sep 2018 05:40:02 -0700 (PDT) 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 S2388377AbeIXSkl (ORCPT + 99 others); Mon, 24 Sep 2018 14:40:41 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:58758 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388284AbeIXSkk (ORCPT ); Mon, 24 Sep 2018 14:40:40 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 0CBF31092; Mon, 24 Sep 2018 12:38:42 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= , Adrian Hunter , Jiri Olsa , Arnaldo Carvalho de Melo Subject: [PATCH 4.18 139/235] perf tools: Fix maps__find_symbol_by_name() Date: Mon, 24 Sep 2018 13:52:05 +0200 Message-Id: <20180924113119.586592620@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180924113103.999624566@linuxfoundation.org> References: <20180924113103.999624566@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Adrian Hunter commit 03db8b583d1c3c84963e08e2abf6c79081da5c31 upstream. Commit 1c5aae7710bb ("perf machine: Create maps for x86 PTI entry trampolines") revealed a problem with maps__find_symbol_by_name() that resulted in probes not being found e.g. $ sudo perf probe xsk_mmap xsk_mmap is out of .text, skip it. Probe point 'xsk_mmap' not found. Error: Failed to add events. maps__find_symbol_by_name() can optionally return the map of the found symbol. It can get the map wrong because, in fact, the symbol is found on the map's dso, not allowing for the possibility that the dso has more than one map. Fix by always checking the map contains the symbol. Reported-by: Björn Töpel Signed-off-by: Adrian Hunter Tested-by: Björn Töpel Cc: Jiri Olsa Cc: stable@vger.kernel.org Fixes: 1c5aae7710bb ("perf machine: Create maps for x86 PTI entry trampolines") Link: http://lkml.kernel.org/r/20180907085116.25782-1-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Greg Kroah-Hartman --- tools/perf/util/map.c | 11 +++++++++++ 1 file changed, 11 insertions(+) --- a/tools/perf/util/map.c +++ b/tools/perf/util/map.c @@ -590,6 +590,13 @@ struct symbol *map_groups__find_symbol(s return NULL; } +static bool map__contains_symbol(struct map *map, struct symbol *sym) +{ + u64 ip = map->unmap_ip(map, sym->start); + + return ip >= map->start && ip < map->end; +} + struct symbol *maps__find_symbol_by_name(struct maps *maps, const char *name, struct map **mapp) { @@ -605,6 +612,10 @@ struct symbol *maps__find_symbol_by_name if (sym == NULL) continue; + if (!map__contains_symbol(pos, sym)) { + sym = NULL; + continue; + } if (mapp != NULL) *mapp = pos; goto out;