lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 6 Jan 2020 17:56:54 +0100
From:   Peter Zijlstra <peterz@...radead.org>
To:     Jann Horn <jannh@...gle.com>
Cc:     bpf@...r.kernel.org, live-patching@...r.kernel.org,
        Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        Steven Rostedt <rostedt@...dmis.org>,
        KP Singh <kpsingh@...omium.org>,
        Andy Lutomirski <luto@...capital.net>,
        kernel list <linux-kernel@...r.kernel.org>,
        the arch/x86 maintainers <x86@...nel.org>,
        Josh Poimboeuf <jpoimboe@...hat.com>,
        Ingo Molnar <mingo@...hat.com>
Subject: Re: BPF tracing trampoline synchronization between update/freeing
 and execution?

On Mon, Jan 06, 2020 at 05:39:30PM +0100, Jann Horn wrote:
> Hi!
> 
> I was chatting with kpsingh about BPF trampolines, and I noticed that
> it looks like BPF trampolines (as of current bpf-next/master) seem to
> be missing synchronization between trampoline code updates and
> trampoline execution. Or maybe I'm missing something?
> 
> If I understand correctly, trampolines are executed directly from the
> fentry placeholders at the start of arbitrary kernel functions, so
> they can run without any locks held. So for example, if task A starts
> executing a trampoline on entry to sys_open(), then gets preempted in
> the middle of the trampoline, and then task B quickly calls
> BPF_RAW_TRACEPOINT_OPEN twice, and then task A continues execution,
> task A will end up executing the middle of newly-written machine code,
> which can probably end up crashing the kernel somehow?
> 
> I think that at least to synchronize trampoline text freeing with
> concurrent trampoline execution, it is necessary to do something
> similar to what the livepatching code does with klp_check_stack(), and
> then either use a callback from the scheduler to periodically re-check
> tasks that were in the trampoline or let the trampoline tail-call into
> a cleanup helper that is part of normal kernel text. And you'd
> probably have to gate BPF trampolines on
> CONFIG_HAVE_RELIABLE_STACKTRACE.

ftrace uses synchronize_rcu_tasks() to flip between trampolines iirc.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ