lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <ae81b620-e9c8-563a-8c54-2235164624dc@bytedance.com>
Date:   Thu, 13 Oct 2022 10:27:29 +0800
From:   Chengming Zhou <zhouchengming@...edance.com>
To:     Martin KaFai Lau <martin.lau@...ux.dev>
Cc:     bpf@...r.kernel.org, linux-kernel@...r.kernel.org, ast@...nel.org,
        daniel@...earbox.net, andrii@...nel.org, song@...nel.org,
        yhs@...com, john.fastabend@...il.com, kpsingh@...nel.org,
        sdf@...gle.com, haoluo@...gle.com, jolsa@...nel.org
Subject: Re: [PATCH] bpf/btf: Fix is_int_ptr()

On 2022/10/13 08:50, Martin KaFai Lau wrote:
> On 10/12/22 5:58 AM, Chengming Zhou wrote:
>> When tracing a kernel function with arg type is u32*, btf_ctx_access()
>> would report error: arg2 type INT is not a struct.
>>
>> The commit bb6728d75611 ("bpf: Allow access to int pointer arguments
>> in tracing programs") added support for int pointer, but don't skip
>> modifiers before checking it's type. This patch fixes it.
> 
> A selftest is needed.  You can refer to the selftest added in the patch set [0] of the commit bb6728d75611.
> 
> This belongs to bpf-next.  Please tag it as bpf-next and also v2 in the next revision:
> Documentation/bpf/bpf_devel_QA.rst  (Q: How do I indicate which tree....)
> 
> [0]: https://lore.kernel.org/bpf/20211208193245.172141-2-jolsa@kernel.org/

Thanks for these helpful references, will do.

> 
>>
>> Fixes: bb6728d75611 ("bpf: Allow access to int pointer arguments in tracing programs")
>> Signed-off-by: Chengming Zhou <zhouchengming@...edance.com>
>> ---
>>   kernel/bpf/btf.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
>> index eba603cec2c5..2b343c42ed10 100644
>> --- a/kernel/bpf/btf.c
>> +++ b/kernel/bpf/btf.c
>> @@ -5316,8 +5316,8 @@ static bool is_int_ptr(struct btf *btf, const struct btf_type *t)
>>       /* t comes in already as a pointer */
>>       t = btf_type_by_id(btf, t->type);
>>   -    /* allow const */
>> -    if (BTF_INFO_KIND(t->info) == BTF_KIND_CONST)
>> +    /* skip modifiers */
>> +    while (btf_type_is_modifier(t))
> 
> There is btf_type_skip_modifiers() that should be useful here.

Ok, will change to use this.

> 
>>           t = btf_type_by_id(btf, t->type);
>>         return btf_type_is_int(t);
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ