From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 94B07ECAAA1 for ; Fri, 9 Sep 2022 10:13:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229544AbiIIKNQ (ORCPT ); Fri, 9 Sep 2022 06:13:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229596AbiIIKNP (ORCPT ); Fri, 9 Sep 2022 06:13:15 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC4D674BA8 for ; Fri, 9 Sep 2022 03:13:14 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 77A7F61F81 for ; Fri, 9 Sep 2022 10:13:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 469EFC433C1; Fri, 9 Sep 2022 10:13:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662718393; bh=2WnKXTXVQn0092eVlGqi0BKS7kLkBS0mXywwvISTgBY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aaQaCwJ/Lq9rDSYDA+3yjoNwPOnoSgf7X0jNUNwsqvg68TnK9tTPGIBw7aBcSRINt FQzndu4mbYZQQuvHU4BEArdWVbzDqemY2W3h0oZQ52VRdnffMvX9/8ZRSPJg6e3EFM yt02kajK/k8GDRGmJQmsgngQNqwk1tHVIEZE00YbTtU67bQYiUJLhablkrgC4W7Lb6 asQmqZ9dZlucZ+W7whwEw9xBpoaW0jbIFFxdxG+dHcNl0uUlh7lilDMUbg1X02wLEq uY9XQHu4Yf7q254YgeOha/ZlA2RNsZUKH08wBFpwcLZyRQL4yR2lq1KhlD+Ck0H8DF 1gafEFHFEXeXA== From: Jiri Olsa To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: Masami Hiramatsu , bpf@vger.kernel.org, Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Peter Zijlstra , Martynas Pumputis Subject: [PATCHv3 bpf-next 2/6] ftrace: Keep the resolved addr in kallsyms_callback Date: Fri, 9 Sep 2022 12:12:41 +0200 Message-Id: <20220909101245.347173-3-jolsa@kernel.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220909101245.347173-1-jolsa@kernel.org> References: <20220909101245.347173-1-jolsa@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org Keeping the resolved 'addr' in kallsyms_callback, instead of taking ftrace_location value, because we depend on symbol address in the cookie related code. With CONFIG_X86_KERNEL_IBT option the ftrace_location value differs from symbol address, which screwes the symbol address cookies matching. There are 2 users of this function: - bpf_kprobe_multi_link_attach for which this fix is for - get_ftrace_locations which is used by register_fprobe_syms this function needs to get symbols resolved to addresses, but does not need 'ftrace location addresses' at this point there's another ftrace location translation in the path done by ftrace_set_filter_ips call: register_fprobe_syms addrs = get_ftrace_locations register_fprobe_ips(addrs) ... ftrace_set_filter_ips ... __ftrace_match_addr ip = ftrace_location(ip); ... Reviewed-by: Masami Hiramatsu (Google) Signed-off-by: Jiri Olsa --- kernel/trace/ftrace.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 439e2ab6905e..447d2e2a8549 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -8265,8 +8265,7 @@ static int kallsyms_callback(void *data, const char *name, if (args->addrs[idx]) return 0; - addr = ftrace_location(addr); - if (!addr) + if (!ftrace_location(addr)) return 0; args->addrs[idx] = addr; -- 2.37.3