Re: [PATCH bpf v2] libbpf: Perform map fd cleanup for gen_loader in case of error

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

 



On Sat, Nov 13, 2021 at 04:50:22AM +0530, Kumar Kartikeya Dwivedi wrote:
> 
> +	/* amount of stack actually used, only used to calculate iterations, not stack offset */
> +	nr_progs_sz = offsetof(struct loader_stack, prog_fd[nr_progs + 1]);

I think '+ 1' would be one too many.
When nr_progs == 1 the offsetof(struct loader_stack, prog_fd[1])
would cover btf_fd, inner_map_fd, and prog_fd[0].

>  	/* jump over cleanup code */
>  	emit(gen, BPF_JMP_IMM(BPF_JA, 0, 0,
> -			      /* size of cleanup code below */
> -			      (stack_sz / 4) * 3 + 2));
> +			      /* size of cleanup code below (including map fd cleanup) */
> +			      (nr_progs_sz / 4) * 3 + 2 +
> +			      /* 6 insns for emit_sys_close_blob,
> +			       * 6 insns for debug_regs in emit_sys_close_blob
> +			       */
> +			      (nr_maps * (6 + (gen->log_level ? 6 : 0)))));

I've removed the extra () in the above.

And pushed to bpf tree.
Please confirm that +1 removal was correct.

Thanks for the quick debugging and fix. Much appreciate it.



[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