Skip to content

Commit d9d0aa4

Browse files
fomichevkernel-patches-bot
authored andcommitted
bpf: don't leak memory in bpf getsockopt when optlen == 0
optlen == 0 indicates that the kernel should ignore BPF buffer and use the original one from the user. We, however, forget to free the temporary buffer that we've allocated for BPF. Reported-by: Martin KaFai Lau <[email protected]> Fixes: d8fe449 ("bpf: Don't return EINVAL from {get,set}sockopt when optlen > PAGE_SIZE") Signed-off-by: Stanislav Fomichev <[email protected]>
1 parent c42ecd1 commit d9d0aa4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

kernel/bpf/cgroup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1395,7 +1395,7 @@ int __cgroup_bpf_run_filter_setsockopt(struct sock *sk, int *level,
13951395
}
13961396

13971397
out:
1398-
if (ret)
1398+
if (*kernel_optval == NULL)
13991399
sockopt_free_buf(&ctx);
14001400
return ret;
14011401
}

0 commit comments

Comments
 (0)