Re: [PATCH v3 bpf-next 1/5] bpf: Let callers of btf_parse_kptr() track life cycle of prog btf

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 8/9/24 4:06 PM, Martin KaFai Lau wrote:
On 8/8/24 5:51 PM, Amery Hung wrote:
btf_parse_kptr() and btf_record_free() do btf_get() and btf_put()
respectively when working on btf_record in program and map if there are
kptr fields. If the kptr is from program BTF, since both callers has
already tracked the life cycle of program BTF, it is safe to remove the
btf_get() and btf_put().

This change prevents memory leak of program BTF later when we start
searching for kptr fields when building btf_record for program. It can
happen when the btf fd is closed. The btf_put() corresponding to the
btf_get() in btf_parse_kptr() was supposed to be called by
btf_record_free() in btf_free_struct_meta_tab() in btf_free(). However,
it will never happen since the invocation of btf_free() depends on the
refcount of the btf to become 0 in the first place.

Signed-off-by: Amery Hung <amery.hung@xxxxxxxxxxxxx>

Acked-by: Martin KaFai Lau <martin.lau@xxxxxxxxxx>

Need to fix the checkpatch warning though:

WARNING: From:/Signed-off-by: email address mismatch: 'From: Amery Hung <ameryhung@xxxxxxxxx>' != 'Signed-off-by: Amery Hung <amery.hung@xxxxxxxxxxxxx>'


There is a veristat failure also:

https://github.com/kernel-patches/bpf/actions/runs/10311824065/job/28546213338

|File                  |Program                         |Verdict                |States Diff (%)|
|----------------------|--------------------------------|-----------------------|---------------|
|local_kptr_stash.bpf.o|refcount_acquire_without_unstash|success -> failure (!!)|-100.00 %      |
|local_kptr_stash.bpf.o|stash_local_with_root           |success -> failure (!!)|-100.00 %      |
|local_kptr_stash.bpf.o|stash_plain                     |success -> failure (!!)|-100.00 %      |
|local_kptr_stash.bpf.o|stash_rb_nodes                  |success -> failure (!!)|-100.00 %      |
|local_kptr_stash.bpf.o|stash_refcounted_node           |success -> failure (!!)|-100.00 %      |
|local_kptr_stash.bpf.o|stash_test_ref_kfunc            |success -> failure (!!)|-100.00 %      |
|local_kptr_stash.bpf.o|unstash_rb_node                 |success -> failure (!!)|-100.00 %      |




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux