bpf: fix context access in tracing progs on 32 bit archs
[linux-2.6-block.git] / kernel / trace / bpf_trace.c
index af1486d9a0ed6aff0a8d41c6921a73e2d0ac4f8a..752992ce35131a68145cb61b7bdc4bcb77c1852e 100644 (file)
@@ -880,8 +880,14 @@ static bool pe_prog_is_valid_access(int off, int size, enum bpf_access_type type
                return false;
        if (type != BPF_READ)
                return false;
-       if (off % size != 0)
-               return false;
+       if (off % size != 0) {
+               if (sizeof(unsigned long) != 4)
+                       return false;
+               if (size != 8)
+                       return false;
+               if (off % size != 4)
+                       return false;
+       }
 
        switch (off) {
        case bpf_ctx_range(struct bpf_perf_event_data, sample_period):