提交 2585cd62 编写于 作者: L Lawrence Brakmo 提交者: Alexei Starovoitov

bpf: Only reply field should be writeable

Currently, a sock_ops BPF program can write the op field and all the
reply fields (reply and replylong). This is a bug. The op field should
not have been writeable and there is currently no way to use replylong
field for indices >= 1. This patch enforces that only the reply field
(which equals replylong[0]) is writeable.

Fixes: 40304b2a ("bpf: BPF support for sock_ops")
Signed-off-by: NLawrence Brakmo <brakmo@fb.com>
Acked-by: NYuchung Cheng <ycheng@google.com>
Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
上级 e9dcd80b
......@@ -3845,8 +3845,7 @@ static bool sock_ops_is_valid_access(int off, int size,
{
if (type == BPF_WRITE) {
switch (off) {
case offsetof(struct bpf_sock_ops, op) ...
offsetof(struct bpf_sock_ops, replylong[3]):
case offsetof(struct bpf_sock_ops, reply):
break;
default:
return false;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册