[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211108164620.407305-1-me@ubique.spb.ru>
Date: Mon, 8 Nov 2021 20:46:18 +0400
From: Dmitrii Banshchikov <me@...que.spb.ru>
To: bpf@...r.kernel.org
Cc: Dmitrii Banshchikov <me@...que.spb.ru>, ast@...nel.org,
daniel@...earbox.net, andrii@...nel.org, kafai@...com,
songliubraving@...com, yhs@...com, john.fastabend@...il.com,
kpsingh@...nel.org, netdev@...r.kernel.org, rdna@...com,
john.stultz@...aro.org, sboyd@...nel.org, peterz@...radead.org,
mark.rutland@....com, rosted@...dmis.org
Subject: [PATCH bpf 0/2] Forbid bpf_ktime_get_coarse_ns and bpf_timer_* in tracing progs
syzbot found a locking issue with bpf_ktime_get_coarse_ns() helper
executed in BPF_PROG_TYPE_PERF_EVENT prog type - [1]. The issue is
possible because the helper uses non fast version of time accessors
which isn't safe for any context. The helper was added because it
provides performance benefits in comparison to bpf_ktime_get_ns().
Forbid use of bpf_ktime_get_coarse_ns() helper in tracing progs.
The same issue is possible with bpf_timer_* set of helpers - forbid
their usage in tracing progs too.
In the discussion it was stated that bpf_spin_lock releated helpers
shall also be excluded for tracing progs. This is already done in a
different way - by compatibility check between a map and a program. The
verifier fails if a tracing program tries to use a map which value has
struct bpf_spin_lock. This prevents using bpf_spin_lock in tracing
progs.
Patch 1 adds allowance checks for helpers
Patch 2 adds tests
1. https://lore.kernel.org/all/00000000000013aebd05cff8e064@google.com/
Dmitrii Banshchikov (2):
bpf: Forbid bpf_ktime_get_coarse_ns and bpf_timer_* in tracing progs
selftests/bpf: Add tests for allowed helpers
kernel/bpf/helpers.c | 30 +++
tools/testing/selftests/bpf/test_verifier.c | 36 +++-
.../selftests/bpf/verifier/helper_allowed.c | 196 ++++++++++++++++++
3 files changed, 261 insertions(+), 1 deletion(-)
create mode 100644 tools/testing/selftests/bpf/verifier/helper_allowed.c
--
2.25.1
Powered by blists - more mailing lists