Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2585cd62 authored by Lawrence Brakmo's avatar Lawrence Brakmo Committed by Alexei Starovoitov
Browse files

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: default avatarLawrence Brakmo <brakmo@fb.com>
Acked-by: default avatarYuchung Cheng <ycheng@google.com>
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent e9dcd80b
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -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;