From be25f963906280ebd30e0685280cd9ebc10d98f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20=C5=BBenczykowski?= Date: Thu, 20 Oct 2022 00:13:15 +0000 Subject: [PATCH] offload.c - make tether_error_map read only. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: 254543135 Signed-off-by: Maciej Żenczykowski Change-Id: I5d4c9cad66f59bd7eed54323ba72ea5a54ddf5e1 --- bpf_progs/offload.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bpf_progs/offload.c b/bpf_progs/offload.c index bb9fc34ce3..c7b444d003 100644 --- a/bpf_progs/offload.c +++ b/bpf_progs/offload.c @@ -91,8 +91,11 @@ // ----- Tethering Error Counters ----- -DEFINE_BPF_MAP_GRW(tether_error_map, ARRAY, uint32_t, uint32_t, BPF_TETHER_ERR__MAX, - TETHERING_GID) +// Note that pre-T devices with Mediatek chipsets may have a kernel bug (bad patch +// "[ALPS05162612] bpf: fix ubsan error") making it impossible to write to non-zero +// offset of bpf map ARRAYs. This file (offload.o) loads on T, but luckily this +// array is only written by bpf code, and only read by userspace. +DEFINE_BPF_MAP_RO(tether_error_map, ARRAY, uint32_t, uint32_t, BPF_TETHER_ERR__MAX, TETHERING_GID) #define COUNT_AND_RETURN(counter, ret) do { \ uint32_t code = BPF_TETHER_ERR_ ## counter; \