]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
ebpf: verifier: check that call reg with ARG_ANYTHING is initialized
authorDaniel Borkmann <daniel@iogearbox.net>
Thu, 12 Mar 2015 16:21:42 +0000 (17:21 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 6 May 2015 20:02:04 +0000 (22:02 +0200)
commitef5c23892b7de84e1f88b84a62fa17ab7cb71986
treebfec33ba7d74d0b25447feb4169b931d6779ef78
parent869c623bcdcf2e806cb5e31fed7c3bbdf47ffc6e
ebpf: verifier: check that call reg with ARG_ANYTHING is initialized

commit 80f1d68ccba70b1060c9c7360ca83da430f66bed upstream.

I noticed that a helper function with argument type ARG_ANYTHING does
not need to have an initialized value (register).

This can worst case lead to unintented stack memory leakage in future
helper functions if they are not carefully designed, or unintended
application behaviour in case the application developer was not careful
enough to match a correct helper function signature in the API.

The underlying issue is that ARG_ANYTHING should actually be split
into two different semantics:

  1) ARG_DONTCARE for function arguments that the helper function
     does not care about (in other words: the default for unused
     function arguments), and

  2) ARG_ANYTHING that is an argument actually being used by a
     helper function and *guaranteed* to be an initialized register.

The current risk is low: ARG_ANYTHING is only used for the 'flags'
argument (r4) in bpf_map_update_elem() that internally does strict
checking.

Fixes: 17a5267067f3 ("bpf: verifier (add verifier core)")
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@plumgrid.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
include/linux/bpf.h
kernel/bpf/verifier.c