Re: [PATCH] bpftool: fix potential NULL pointer dereferencing in prog_dump()

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

 



2024-11-15 15:15 UTC+0330 ~ Amir Mohammadi <amirmohammadi1999.am@xxxxxxxxx>
> A NULL pointer dereference could occur if ksyms
> is not properly checked before usage in the prog_dump() function.
> 
> Signed-off-by: Amir Mohammadi <amiremohamadi@xxxxxxxxx>
> ---
>  tools/bpf/bpftool/prog.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c
> index 2ff949ea8..8b5300103 100644
> --- a/tools/bpf/bpftool/prog.c
> +++ b/tools/bpf/bpftool/prog.c
> @@ -822,11 +822,12 @@ prog_dump(struct bpf_prog_info *info, enum dump_mode mode,
>  					printf("%s:\n", sym_name);
>  				}
>  
> -				if (disasm_print_insn(img, lens[i], opcodes,
> -						      name, disasm_opt, btf,
> -						      prog_linfo, ksyms[i], i,
> -						      linum))
> -					goto exit_free;
> +				if (ksyms)
> +					if (disasm_print_insn(img, lens[i], opcodes,
> +							      name, disasm_opt, btf,
> +							      prog_linfo, ksyms[i], i,
> +							      linum))
> +						goto exit_free;
>  
>  				img += lens[i];
>  


Thanks! But we don't want to skip dumping the instruction silently if we
don't have ksyms. So we'd need an 'else' block that does the same as if
no JITed functions are found I think, something calling:

	disasm_print_insn(img, lens[i], opcodes, name, disasm_opt, btf,
			  NULL, 0, 0, false)

Fixes: b053b439b72a ("bpf: libbpf: bpftool: Print bpf_line_info during prog dump")

Quentin




[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