summaryrefslogtreecommitdiff
path: root/kernel/bpf/cgroup.c
diff options
context:
space:
mode:
authorLoris Reiff <loris.reiff@liblor.ch>2021-01-22 19:42:32 +0300
committerDaniel Borkmann <daniel@iogearbox.net>2021-01-23 01:11:47 +0300
commitf4a2da755a7e1f5d845c52aee71336cee289935a (patch)
tree5d8ffc8d9b3a7f18fc706b2aeffb6fa059b370d3 /kernel/bpf/cgroup.c
parentbb8b81e396f7afbe7c50d789e2107512274d2a35 (diff)
downloadlinux-f4a2da755a7e1f5d845c52aee71336cee289935a.tar.xz
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: 0d01da6afc54 ("bpf: implement getsockopt and setsockopt hooks") Signed-off-by: Loris Reiff <loris.reiff@liblor.ch> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Reviewed-by: Stanislav Fomichev <sdf@google.com> Link: https://lore.kernel.org/bpf/20210122164232.61770-2-loris.reiff@liblor.ch
Diffstat (limited to 'kernel/bpf/cgroup.c')
-rw-r--r--kernel/bpf/cgroup.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/kernel/bpf/cgroup.c b/kernel/bpf/cgroup.c
index 6ec8f02f463b..6aa9e10c6335 100644
--- a/kernel/bpf/cgroup.c
+++ b/kernel/bpf/cgroup.c
@@ -1464,7 +1464,7 @@ int __cgroup_bpf_run_filter_getsockopt(struct sock *sk, int level,
goto out;
}
- if (ctx.optlen > max_optlen) {
+ if (ctx.optlen > max_optlen || ctx.optlen < 0) {
ret = -EFAULT;
goto out;
}