public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
From: Kui-Feng Lee <sinquersw@gmail.com>
To: Matthieu Baerts <matthieu.baerts@tessares.net>,
	Kumar Kartikeya Dwivedi <memxor@gmail.com>,
	bpf@vger.kernel.org, Alexei Starovoitov <ast@kernel.org>
Subject: Re: [PATCH bpf-next v2 2/3] bpf: Fix bpf_throw warning on 32-bit arch
Date: Mon, 18 Sep 2023 11:12:29 -0700	[thread overview]
Message-ID: <11fb1a32-ea91-d9af-0406-50f5f722014f@gmail.com> (raw)
In-Reply-To: <b74e5f1e-d054-42ea-ab69-91c92278a82a@tessares.net>



On 9/18/23 10:09, Matthieu Baerts wrote:
> Hi Kumar,
> 
> On 18/09/2023 17:52, Kumar Kartikeya Dwivedi wrote:
>> 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.
> 
> Thank you for the patch, it fixes the issue on our side!
> 
> (Not sure you need a tested by tag but just in case: )
> 
> Tested-by: Matthieu Baerts <matthieu.baerts@tessares.net>
> 
>> 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);
> I never know what's the recommended way to fix such issues: casting it
> to 'long' or 'unsigned long'? But it looks like both are used in the
> kernel and 'long' is more often used than the other one so all good I
> suppose.

Shouldn't we have a macro to do this kind of casting if there is not?
Without any comment, it is difficult to know why this extra casting
is here.

> 
>>   	ctx.aux->bpf_exception_cb(cookie, ctx.sp, ctx.bp);
>>   	WARN(1, "A call to BPF exception callback should never return\n");
>>   }
> 
> Cheers,
> Matt

  reply	other threads:[~2023-09-18 18:12 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 ` [PATCH bpf-next v2 2/3] bpf: Fix bpf_throw warning on 32-bit arch Kumar Kartikeya Dwivedi
2023-09-18 17:09   ` Matthieu Baerts
2023-09-18 18:12     ` Kui-Feng Lee [this message]
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=11fb1a32-ea91-d9af-0406-50f5f722014f@gmail.com \
    --to=sinquersw@gmail.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=matthieu.baerts@tessares.net \
    --cc=memxor@gmail.com \
    /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