public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
From: Kumar Kartikeya Dwivedi <memxor@gmail.com>
To: bpf@vger.kernel.org, Alexei Starovoitov <ast@kernel.org>
Cc: Matthieu Baerts <matthieu.baerts@tessares.net>
Subject: [PATCH bpf-next v2 2/3] bpf: Fix bpf_throw warning on 32-bit arch
Date: Mon, 18 Sep 2023 17:52:32 +0200	[thread overview]
Message-ID: <20230918155233.297024-3-memxor@gmail.com> (raw)
In-Reply-To: <20230918155233.297024-1-memxor@gmail.com>

On 32-bit architectures, the pointer width is 32-bit, while we try to
cast from a u64 down to it, the compiler complains on mismatch in
integer size. Fix this by first casting to long which should match
the pointer width on targets supported by Linux.

Fixes: ec5290a178b7 ("bpf: Prevent KASAN false positive with bpf_throw")
Reported-by: Matthieu Baerts <matthieu.baerts@tessares.net>
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
---
 kernel/bpf/helpers.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
index 7ff2a42f1996..dd1c69ee3375 100644
--- a/kernel/bpf/helpers.c
+++ b/kernel/bpf/helpers.c
@@ -2488,7 +2488,7 @@ __bpf_kfunc void bpf_throw(u64 cookie)
 	 * deeper stack depths than ctx.sp as we do not return from bpf_throw,
 	 * which skips compiler generated instrumentation to do the same.
 	 */
-	kasan_unpoison_task_stack_below((void *)ctx.sp);
+	kasan_unpoison_task_stack_below((void *)(long)ctx.sp);
 	ctx.aux->bpf_exception_cb(cookie, ctx.sp, ctx.bp);
 	WARN(1, "A call to BPF exception callback should never return\n");
 }
-- 
2.41.0


  parent reply	other threads:[~2023-09-18 15:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-18 15:52 [PATCH bpf-next v2 0/3] Fixes for Exceptions Kumar Kartikeya Dwivedi
2023-09-18 15:52 ` [PATCH bpf-next v2 1/3] selftests/bpf: Print log buffer for exceptions test only on failure Kumar Kartikeya Dwivedi
2023-09-18 15:52 ` Kumar Kartikeya Dwivedi [this message]
2023-09-18 17:09   ` [PATCH bpf-next v2 2/3] bpf: Fix bpf_throw warning on 32-bit arch Matthieu Baerts
2023-09-18 18:12     ` Kui-Feng Lee
2023-09-18 15:52 ` [PATCH bpf-next v2 3/3] bpf: Disable exceptions when CONFIG_UNWINDER_FRAME_POINTER=y Kumar Kartikeya Dwivedi
2023-09-18 16:00   ` Eric Dumazet
2023-09-18 20:50 ` [PATCH bpf-next v2 0/3] Fixes for Exceptions patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230918155233.297024-3-memxor@gmail.com \
    --to=memxor@gmail.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=matthieu.baerts@tessares.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox