Skip to content

Commit d4e505c

Browse files
chudihuangyonghong-song
authored andcommitted
libbpf-tools/bitesize.bpf.c: Fix potential out-of-bounds access in comm_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.
1 parent d13cab9 commit d4e505c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

libbpf-tools/bitesize.bpf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ static __always_inline bool comm_allowed(const char *comm)
2727
{
2828
int i;
2929

30-
for (i = 0; targ_comm[i] != '\0' && i < TASK_COMM_LEN; i++) {
30+
for (i = 0; i < TASK_COMM_LEN && targ_comm[i] != '\0'; i++) {
3131
if (comm[i] != targ_comm[i])
3232
return false;
3333
}

0 commit comments

Comments
 (0)