summaryrefslogtreecommitdiffstats
path: root/net/core/filter.c
diff options
context:
space:
mode:
authorLawrence Brakmo2018-01-26 01:14:05 +0100
committerAlexei Starovoitov2018-01-26 01:41:13 +0100
commit2585cd62f0986a6e6d9c83363ed6dbcc66bc9f32 (patch)
treec253c21199292459117b3e72e0a98701bab5c9fe /net/core/filter.c
parentbpf, doc: Correct one wrong value in "Register value tracking" (diff)
downloadkernel-qcow2-linux-2585cd62f0986a6e6d9c83363ed6dbcc66bc9f32.tar.gz
kernel-qcow2-linux-2585cd62f0986a6e6d9c83363ed6dbcc66bc9f32.tar.xz
kernel-qcow2-linux-2585cd62f0986a6e6d9c83363ed6dbcc66bc9f32.zip
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: 40304b2a1567 ("bpf: BPF support for sock_ops") Signed-off-by: Lawrence Brakmo <brakmo@fb.com> Acked-by: Yuchung Cheng <ycheng@google.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'net/core/filter.c')
-rw-r--r--net/core/filter.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/net/core/filter.c b/net/core/filter.c
index 18da42a81d0c..bf9bb755e369 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -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;