[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0d09a543-b98c-4618-93e2-eef7bf8aec63@linux.dev>
Date: Thu, 19 Dec 2024 15:06:28 -0800
From: Martin KaFai Lau <martin.lau@...ux.dev>
To: Amery Hung <ameryhung@...il.com>
Cc: Amery Hung <amery.hung@...edance.com>, bpf@...r.kernel.org,
netdev@...r.kernel.org, daniel@...earbox.net, andrii@...nel.org,
alexei.starovoitov@...il.com, martin.lau@...nel.org, sinquersw@...il.com,
toke@...hat.com, jhs@...atatu.com, jiri@...nulli.us, stfomichev@...il.com,
ekarani.silvestre@....ufcg.edu.br, yangpeihao@...u.edu.cn,
xiyou.wangcong@...il.com, yepeilin.cs@...il.com
Subject: Re: [PATCH bpf-next v1 01/13] bpf: Support getting referenced kptr
from struct_ops argument
On 12/18/24 8:57 AM, Amery Hung wrote:
>> At the first glance, the ref_obj_id assignment looks racy because ctx_arg_info
>> is shared by different bpf progs that may be verified in parallel. After another
>> thought, this should be fine because it should always end up having the same
>> ref_obj_id for the same arg-no, right? Not sure if UBSAN can understand this
>> without using the READ/WRITE_ONCE. but adding READ/WRITE_ONCE when using
>> ref_obj_id will be quite puzzling when reading the verifier code. Any better idea?
>>
> It looks like ref_obj_id cannot be reused (id always comes from
> ++env->id_gen), and these will be the earliest references to acquire.
> So, maybe we can assume the ref_obj_id without needing to store it in
> ctx_arg_info? E.g., the first __ref argument's ref_obj_id is always 1.
That seems reasonable to me. Then ctx_arg_info can stay read-only after the very
first initialization during bpf_struct_ops_desc_init().
Powered by blists - more mailing lists