From patchwork Wed Jul 21 21:19:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 12392211 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-20.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 52CADC6377A for ; Wed, 21 Jul 2021 21:20:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2BA8B611C1 for ; Wed, 21 Jul 2021 21:20:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229481AbhGUUjg (ORCPT ); Wed, 21 Jul 2021 16:39:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:39240 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229463AbhGUUjg (ORCPT ); Wed, 21 Jul 2021 16:39:36 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 86E8D61001; Wed, 21 Jul 2021 21:20:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1626902412; bh=nY7Q2Gu53XreSpv2eK6K9Pj/0kb0Rlq6C4OieN5DwQk=; h=From:To:Cc:Subject:Date:From; b=LWKs+DgVJAeoupL65lsFCr9W/4KeKzZM6w1XYmJEJy3Yv2Z9MYKWFYKKMCvwHLwAf 37BiKFx71vtqGrKyvLRnX8unHnCHtrP2GesNagye3UcWw9b+vMvjw7z2X8Rq6hUge8 O+WW0wFYs1+5lmqhA1VTDce+kROdetBaEehU/o7wIYwKLYuBIKttU5X6h0+vu9xBiM knP3x2Y848olxZ6USAXysygTeU5ygRwcK0QqQbCohpH17cu+mu7EhEr+Xw05PM2+oX tWGSWEWXQRmAR4Kuto+GUgdYZee9MG+cXV7N0ELH0ebHseWQEXa01mvPGNWWfq7x6k yHAcczawcZKFw== From: Arnd Bergmann To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Masami Hiramatsu , Jiri Olsa Cc: Arnd Bergmann , Steven Rostedt , Ingo Molnar , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Florent Revest , Alan Maguire , netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next] bpf: fix pointer cast warning Date: Wed, 21 Jul 2021 23:19:45 +0200 Message-Id: <20210721212007.3876595-1-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Arnd Bergmann kp->addr is a pointer, so it cannot be cast directly to a 'u64' when it gets interpreted as an integer value: kernel/trace/bpf_trace.c: In function '____bpf_get_func_ip_kprobe': kernel/trace/bpf_trace.c:968:21: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast] 968 | return kp ? (u64) kp->addr : 0; Use the uintptr_t type instead. Fixes: 9ffd9f3ff719 ("bpf: Add bpf_get_func_ip helper for kprobe programs") Signed-off-by: Arnd Bergmann --- kernel/trace/bpf_trace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c index 0de09f068697..a428d1ef0085 100644 --- a/kernel/trace/bpf_trace.c +++ b/kernel/trace/bpf_trace.c @@ -965,7 +965,7 @@ BPF_CALL_1(bpf_get_func_ip_kprobe, struct pt_regs *, regs) { struct kprobe *kp = kprobe_running(); - return kp ? (u64) kp->addr : 0; + return kp ? (uintptr_t)kp->addr : 0; } static const struct bpf_func_proto bpf_get_func_ip_proto_kprobe = {