[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAADnVQ+zo-DMC=yqqphEno9pxwhBQ3soQzKd=2yLPNoLyBcFHw@mail.gmail.com>
Date: Sun, 14 Nov 2021 10:38:31 -0800
From: Alexei Starovoitov <alexei.starovoitov@...il.com>
To: Dmitrii Banshchikov <me@...que.spb.ru>
Cc: bpf <bpf@...r.kernel.org>, Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Andrii Nakryiko <andrii@...nel.org>,
Martin KaFai Lau <kafai@...com>,
Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
John Fastabend <john.fastabend@...il.com>,
KP Singh <kpsingh@...nel.org>,
Network Development <netdev@...r.kernel.org>,
Thomas Gleixner <tglx@...utronix.de>,
Andrey Ignatov <rdna@...com>
Subject: Re: [PATCH bpf v2 0/2] Forbid bpf_ktime_get_coarse_ns and bpf_timer_*
in tracing progs
On Sat, Nov 13, 2021 at 6:22 AM Dmitrii Banshchikov <me@...que.spb.ru> wrote:
>
> Various locking issues are possible with bpf_ktime_get_coarse_ns() and
> bpf_timer_* set of helpers.
>
> 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 accessor that isn't safe for any context.
> The helper was added because it provided performance benefits in comparison to
> bpf_ktime_get_ns() helper.
>
> A similar locking issue is possible with bpf_timer_* set of helpers when used
> in tracing progs.
>
> The solution is to restrict use of the helpers in tracing progs.
>
> In the [1] discussion it was stated that bpf_spin_lock related helpers shall
> also be excluded for tracing progs. The verifier has a compatibility check
> between a map and a program. If a tracing program tries to use a map which
> value has struct bpf_spin_lock the verifier fails that is why bpf_spin_lock is
> already restricted.
>
> Patch 1 restricts helpers
> Patch 2 adds tests
>
> v1 -> v2:
> * Limit the helpers via func proto getters instead of allowed callback
> * Add note about helpers' restrictions to linux/bpf.h
> * Add Fixes tag
> * Remove extra \0 from btf_str_sec
> * Beside asm tests add prog tests
> * Trim CC
>
> 1. https://lore.kernel.org/all/00000000000013aebd05cff8e064@google.com/
Applied. Thanks
Powered by blists - more mailing lists