Skip to content
Commit 9146fffc authored by Loris Reiff's avatar Loris Reiff Committed by Greg Kroah-Hartman
Browse files

bpf, cgroup: Fix optlen WARN_ON_ONCE toctou

[ Upstream commit bb8b81e3 ]

A toctou issue in `__cgroup_bpf_run_filter_getsockopt` can trigger a
WARN_ON_ONCE in a check of `copy_from_user`.

`*optlen` is checked to be non-negative in the individual getsockopt
functions beforehand. Changing `*optlen` in a race to a negative value
will result in a `copy_from_user(ctx.optval, optval, ctx.optlen)` with
`ctx.optlen` being a negative integer.

Fixes: 0d01da6a

 ("bpf: implement getsockopt and setsockopt hooks")
Signed-off-by: default avatarLoris Reiff <loris.reiff@liblor.ch>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Reviewed-by: default avatarStanislav Fomichev <sdf@google.com>
Link: https://lore.kernel.org/bpf/20210122164232.61770-1-loris.reiff@liblor.ch
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 4921f81c
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment