Re: [PATCHv3 bpf-next 2/3] bpf: Do cleanup in bpf_bprintf_cleanup only when needed

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

 





On 12/15/22 1:44 PM, Jiri Olsa wrote:
Currently we always cleanup/decrement bpf_bprintf_nest_level
variable in bpf_bprintf_cleanup if it's > 0.

There's possible scenario where this could cause a problem,
when bpf_bprintf_prepare does not get bin_args buffer (because
num_args is 0) and following bpf_bprintf_cleanup call decrements
bpf_bprintf_nest_level variable, like:

   in task context:
     bpf_bprintf_prepare(num_args != 0) increments 'bpf_bprintf_nest_level = 1'
     -> first irq :
        bpf_bprintf_prepare(num_args == 0)
        bpf_bprintf_cleanup decrements 'bpf_bprintf_nest_level = 0'
     -> second irq:
        bpf_bprintf_prepare(num_args != 0) bpf_bprintf_nest_level = 1
        gets same buffer as task context above

Adding check to bpf_bprintf_cleanup and doing the real cleanup
only if we got bin_args data in the first place.

Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>

Acked-by: Yonghong Song <yhs@xxxxxx>



[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