iovisor / bcc

BCC - Tools for BPF-based Linux IO analysis, networking, monitoring, and more
Apache License 2.0
20.36k stars 3.86k forks source link

libbpf-tools/bitesize.bpf.c: Fix potential out-of-bounds access in co… #5030

Closed chudihuang closed 3 months ago

chudihuang commented 3 months ago

…mm_allowed function

fixes a potential out-of-bounds access in the comm_allowed function. Previously, the condition in the for loop checked the value of targ_comm[i] before ensuring that i is less than TASK_COMM_LEN. This could lead to out-of-bounds access if i equals TASK_COMM_LEN.

The condition in the for loop has been updated to check that i is less than TASK_COMM_LEN before accessing targ_comm[i]. This ensures that targ_comm is not accessed out-of-bounds.