Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752100AbcDPUaY (ORCPT ); Sat, 16 Apr 2016 16:30:24 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:55637 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751711AbcDPUaX (ORCPT ); Sat, 16 Apr 2016 16:30:23 -0400 From: Arnd Bergmann To: "David S . Miller" Cc: netdev@vger.kernel.org, Arnd Bergmann , Steven Rostedt , Ingo Molnar , Alexei Starovoitov , Daniel Borkmann , linux-kernel@vger.kernel.org Subject: [PATCH] bpf: avoid warning for wrong pointer cast Date: Sat, 16 Apr 2016 22:29:33 +0200 Message-Id: <1460838585-1248139-1-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 X-Provags-ID: V03:K0:O8LoxBVIaNCfd/z2KZjqBjOuKy/hUiYRW7HDwMHkFyR7gwRCON4 RoGdqviEN9WLRCnv/2pKD6FCkX8LXB9uIw3bLGRg5WMOnF7ok+cGTN2Pf3R7fWpSA8/RkMS /6J/9vuWaZ+qUOIw1Mv1xK7zi8rthE7oKRPYljqAVrEnIjj7fEc1kr0PLzJ4zm6UUofnWGx MZ8Kpgn7O9aYK5crAdJwQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:LMEhJhLVZ48=:5stw17G8NvnCdSl3BLcjxO wciS3iHrfN+ZRqyKilGpctgIb6DpzzSI0EMu9ug9UkSf96gMSs3Xdy7XsME7tkXY/LcVmo4Gx vrLbY085a7K/Z5rw/VcRk5zDMfV2LweARSelKr+CK5v2sI07Xlhu9DPGAblKWU1qeJtCg1n9v dfvA3+egYXDDN2dk2A/TD3CGKDWb1usRp3lKAJPlIFMTDnkOmEnujZLZrmscD7t28+A1bEycj foBXtQx5YkNqhXPYzqJNC4/KOaBYQ1MtsrqVfmo0hY5z2dCQsKJyVUjTNI4L59KpsMuzWI9Dg nPRV6uZggAYtjpu9UEK8+xHrgLrxKPgQCSZHtnj5VOn51GbA2UEJkGpRMS0UqZZF8sUQLfLiT ur+TFTjiONYKx/mOPzVxweQlnkYuh3yxYEoIWpbPSt30s1JI+E0AWDUSmLNH7GcrbIXIKfOlT qnW42OsNTAyLlE60h4wXa+XFnTVEQTVNuMQfw4Ua/IYmE6G9woBBk5jOAKvP+2/ug7Yjbk9ja Spkv9HMD0i5NaqnhQ+Yv3Rff7Hyr70F2isbhJ1tDBmMp4FMOGxdDi6oc30liP/RE7fWyDLcgj z92vrf3OWPxI6eQ1dDdbfqjbTXy/1gU0o2SL+kkjWx+y5+h2iuoXXh2rD4SMMDSDf7QLqBp0D vEAgKDdxI4yjh2LD/yYGvnRTGA4IuMccuBrukmNatCO6qnelXycrsPZohRMpfxwRt+u0= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1557 Lines: 41 Two new functions in bpf contain a cast from a 'u64' to a pointer. This works on 64-bit architectures but causes a warning on all 32-bit architectures: kernel/trace/bpf_trace.c: In function 'bpf_perf_event_output_tp': kernel/trace/bpf_trace.c:350:13: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast] u64 ctx = *(long *)r1; This changes the cast to first convert the u64 argument into a uintptr_t, which is guaranteed to be the same size as a pointer. Signed-off-by: Arnd Bergmann Fixes: 9940d67c93b5 ("bpf: support bpf_get_stackid() and bpf_perf_event_output() in tracepoint programs") --- kernel/trace/bpf_trace.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c index 413ec5614180..c082313a523a 100644 --- a/kernel/trace/bpf_trace.c +++ b/kernel/trace/bpf_trace.c @@ -347,7 +347,7 @@ static u64 bpf_perf_event_output_tp(u64 r1, u64 r2, u64 index, u64 r4, u64 size) * from bpf program and contain a pointer to 'struct pt_regs'. Fetch it * from there and call the same bpf_perf_event_output() helper */ - u64 ctx = *(long *)r1; + u64 ctx = *(long *)(uintptr_t)r1; return bpf_perf_event_output(ctx, r2, index, r4, size); } @@ -365,7 +365,7 @@ static const struct bpf_func_proto bpf_perf_event_output_proto_tp = { static u64 bpf_get_stackid_tp(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5) { - u64 ctx = *(long *)r1; + u64 ctx = *(long *)(uintptr_t)r1; return bpf_get_stackid(ctx, r2, r3, r4, r5); } -- 2.7.0