Skip to content

Commit a83562f

Browse files
ea1davisKernel Patches Daemon
authored andcommitted
bpf: Plug a potential exclusive map memory leak
When excl_prog_hash is 0 and excl_prog_hash_size is non-zero, the map also needs to be freed. Otherwise, the map memory will not be reclaimed, just like the memory leak problem reported by syzbot [1]. syzbot reported: BUG: memory leak backtrace (crc 7b9fb9b4): map_create+0x322/0x11e0 kernel/bpf/syscall.c:1512 __sys_bpf+0x3556/0x3610 kernel/bpf/syscall.c:6131 Fixes: baefdbd ("bpf: Implement exclusive map creation") Reported-by: [email protected] Closes: https://syzkaller.appspot.com/bug?extid=cf08c551fecea9fd1320 Tested-by: [email protected] Signed-off-by: Edward Adam Davis <[email protected]> Acked-by: Yonghong Song <[email protected]>
1 parent 44cbecf commit a83562f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

kernel/bpf/syscall.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1586,7 +1586,8 @@ static int map_create(union bpf_attr *attr, bpfptr_t uattr)
15861586
goto free_map;
15871587
}
15881588
} else if (attr->excl_prog_hash_size) {
1589-
return -EINVAL;
1589+
err = -EINVAL;
1590+
goto free_map;
15901591
}
15911592

15921593
err = security_bpf_map_create(map, attr, token, uattr.is_kernel);

0 commit comments

Comments
 (0)