Skip to content

Commit f4a2da7

Browse files
Liblorborkmann
authored andcommitted
bpf, cgroup: Fix problematic bounds check
Since ctx.optlen is signed, a larger value than max_value could be passed, as it is later on used as unsigned, which causes a WARN_ON_ONCE in the copy_to_user. Fixes: 0d01da6 ("bpf: implement getsockopt and setsockopt hooks") Signed-off-by: Loris Reiff <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Reviewed-by: Stanislav Fomichev <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent bb8b81e commit f4a2da7

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
@@ -1464,7 +1464,7 @@ int __cgroup_bpf_run_filter_getsockopt(struct sock *sk, int level,
14641464
goto out;
14651465
}
14661466

1467-
if (ctx.optlen > max_optlen) {
1467+
if (ctx.optlen > max_optlen || ctx.optlen < 0) {
14681468
ret = -EFAULT;
14691469
goto out;
14701470
}

0 commit comments

Comments
 (0)