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().