Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'fix-compiler-warnings-looking-for-suggestions'

Rafael Passos says:

====================
Fix compiler warnings, looking for suggestions

Hi,
This patchset has a few fixes to compiler warnings.
I am studying the BPF subsystem and wish to bring more tangible contributions.
I would appreciate receiving suggestions on things to investigate.
I also documented a bit in my blog. I could help with docs here, too.
https://rcpassos.me/post/linux-ebpf-understanding-kernel-level-mechanics
Thanks!

Changelog V1 -> V2:
- rebased all commits to updated for-next base
- removes new cases of the extra parameter for bpf_jit_binary_pack_finalize
- built and tested for ARM64
- sent the series for the test workflow:
https://github.com/kernel-patches/bpf/pull/7198
====================

Acked-by: Puranjay Mohan <puranjay@kernel.org>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Link: https://lore.kernel.org/r/20240615022641.210320-1-rafael@rcpassos.me
Signed-off-by: Alexei Starovoitov <ast@kernel.org>

+14 -21
+1 -2
arch/arm64/net/bpf_jit_comp.c
··· 1829 1829 prog->jited_len = 0; 1830 1830 goto out_free_hdr; 1831 1831 } 1832 - if (WARN_ON(bpf_jit_binary_pack_finalize(prog, ro_header, 1833 - header))) { 1832 + if (WARN_ON(bpf_jit_binary_pack_finalize(ro_header, header))) { 1834 1833 /* ro_header has been freed */ 1835 1834 ro_header = NULL; 1836 1835 prog = orig_prog;
+2 -2
arch/powerpc/net/bpf_jit_comp.c
··· 225 225 fp->jited_len = proglen + FUNCTION_DESCR_SIZE; 226 226 227 227 if (!fp->is_func || extra_pass) { 228 - if (bpf_jit_binary_pack_finalize(fp, fhdr, hdr)) { 228 + if (bpf_jit_binary_pack_finalize(fhdr, hdr)) { 229 229 fp = org_fp; 230 230 goto out_addrs; 231 231 } ··· 348 348 * before freeing it. 349 349 */ 350 350 if (jit_data) { 351 - bpf_jit_binary_pack_finalize(fp, jit_data->fhdr, jit_data->hdr); 351 + bpf_jit_binary_pack_finalize(jit_data->fhdr, jit_data->hdr); 352 352 kvfree(jit_data->addrs); 353 353 kfree(jit_data); 354 354 }
+2 -3
arch/riscv/net/bpf_jit_core.c
··· 178 178 prog->jited_len = prog_size - cfi_get_offset(); 179 179 180 180 if (!prog->is_func || extra_pass) { 181 - if (WARN_ON(bpf_jit_binary_pack_finalize(prog, jit_data->ro_header, 182 - jit_data->header))) { 181 + if (WARN_ON(bpf_jit_binary_pack_finalize(jit_data->ro_header, jit_data->header))) { 183 182 /* ro_header has been freed */ 184 183 jit_data->ro_header = NULL; 185 184 prog = orig_prog; ··· 257 258 * before freeing it. 258 259 */ 259 260 if (jit_data) { 260 - bpf_jit_binary_pack_finalize(prog, jit_data->ro_header, jit_data->header); 261 + bpf_jit_binary_pack_finalize(jit_data->ro_header, jit_data->header); 261 262 kfree(jit_data); 262 263 } 263 264 hdr = bpf_jit_binary_pack_hdr(prog);
+2 -2
arch/x86/net/bpf_jit_comp.c
··· 3356 3356 * 3357 3357 * Both cases are serious bugs and justify WARN_ON. 3358 3358 */ 3359 - if (WARN_ON(bpf_jit_binary_pack_finalize(prog, header, rw_header))) { 3359 + if (WARN_ON(bpf_jit_binary_pack_finalize(header, rw_header))) { 3360 3360 /* header has been freed */ 3361 3361 header = NULL; 3362 3362 goto out_image; ··· 3435 3435 * before freeing it. 3436 3436 */ 3437 3437 if (jit_data) { 3438 - bpf_jit_binary_pack_finalize(prog, jit_data->header, 3438 + bpf_jit_binary_pack_finalize(jit_data->header, 3439 3439 jit_data->rw_header); 3440 3440 kvfree(jit_data->addrs); 3441 3441 kfree(jit_data);
+1 -2
include/linux/bpf.h
··· 2933 2933 return ret; 2934 2934 } 2935 2935 2936 - void __bpf_free_used_btfs(struct bpf_prog_aux *aux, 2937 - struct btf_mod_pair *used_btfs, u32 len); 2936 + void __bpf_free_used_btfs(struct btf_mod_pair *used_btfs, u32 len); 2938 2937 2939 2938 static inline struct bpf_prog *bpf_prog_get_type(u32 ufd, 2940 2939 enum bpf_prog_type type)
+1 -2
include/linux/filter.h
··· 1129 1129 struct bpf_binary_header **rw_hdr, 1130 1130 u8 **rw_image, 1131 1131 bpf_jit_fill_hole_t bpf_fill_ill_insns); 1132 - int bpf_jit_binary_pack_finalize(struct bpf_prog *prog, 1133 - struct bpf_binary_header *ro_header, 1132 + int bpf_jit_binary_pack_finalize(struct bpf_binary_header *ro_header, 1134 1133 struct bpf_binary_header *rw_header); 1135 1134 void bpf_jit_binary_pack_free(struct bpf_binary_header *ro_header, 1136 1135 struct bpf_binary_header *rw_header);
+3 -5
kernel/bpf/core.c
··· 1174 1174 } 1175 1175 1176 1176 /* Copy JITed text from rw_header to its final location, the ro_header. */ 1177 - int bpf_jit_binary_pack_finalize(struct bpf_prog *prog, 1178 - struct bpf_binary_header *ro_header, 1177 + int bpf_jit_binary_pack_finalize(struct bpf_binary_header *ro_header, 1179 1178 struct bpf_binary_header *rw_header) 1180 1179 { 1181 1180 void *ptr; ··· 2742 2743 kfree(aux->used_maps); 2743 2744 } 2744 2745 2745 - void __bpf_free_used_btfs(struct bpf_prog_aux *aux, 2746 - struct btf_mod_pair *used_btfs, u32 len) 2746 + void __bpf_free_used_btfs(struct btf_mod_pair *used_btfs, u32 len) 2747 2747 { 2748 2748 #ifdef CONFIG_BPF_SYSCALL 2749 2749 struct btf_mod_pair *btf_mod; ··· 2759 2761 2760 2762 static void bpf_free_used_btfs(struct bpf_prog_aux *aux) 2761 2763 { 2762 - __bpf_free_used_btfs(aux, aux->used_btfs, aux->used_btf_cnt); 2764 + __bpf_free_used_btfs(aux->used_btfs, aux->used_btf_cnt); 2763 2765 kfree(aux->used_btfs); 2764 2766 } 2765 2767
+1 -1
kernel/bpf/log.c
··· 91 91 goto fail; 92 92 } else { 93 93 u64 new_end, new_start; 94 - u32 buf_start, buf_end, new_n; 94 + u32 buf_start, buf_end; 95 95 96 96 new_end = log->end_pos + n; 97 97 if (new_end - log->start_pos >= log->len_total)
+1 -2
kernel/bpf/verifier.c
··· 18694 18694 /* drop refcnt of maps used by the rejected program */ 18695 18695 static void release_btfs(struct bpf_verifier_env *env) 18696 18696 { 18697 - __bpf_free_used_btfs(env->prog->aux, env->used_btfs, 18698 - env->used_btf_cnt); 18697 + __bpf_free_used_btfs(env->used_btfs, env->used_btf_cnt); 18699 18698 } 18700 18699 18701 18700 /* convert pseudo BPF_LD_IMM64 into generic BPF_LD_IMM64 */