]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: dynamically allocate digest scratch buffer
authorDaniel Borkmann <daniel@iogearbox.net>
Sun, 18 Dec 2016 00:52:57 +0000 (01:52 +0100)
committerDavid S. Miller <davem@davemloft.net>
Sun, 18 Dec 2016 02:27:44 +0000 (21:27 -0500)
commit0c01ce6e5ef875b80ac0a580d54e9ac02fec66f6
tree4aa9958d1ddf599f4ed32d491f8ab217c9747056
parent05c9ef03d82d7ec9feb7c73fa3fc5946f48ac390
bpf: dynamically allocate digest scratch buffer

Geert rightfully complained that 4df59680c4ca ("bpf: add prog_digest
and expose it via fdinfo/netlink") added a too large allocation of
variable 'raw' from bss section, and should instead be done dynamically:

  # ./scripts/bloat-o-meter kernel/bpf/core.o.1 kernel/bpf/core.o.2
  add/remove: 3/0 grow/shrink: 0/0 up/down: 33291/0 (33291)
  function                                     old     new   delta
  raw                                            -   32832  +32832
  [...]

Since this is only relevant during program creation path, which can be
considered slow-path anyway, lets allocate that dynamically and be not
implicitly dependent on verifier mutex. Move bpf_prog_calc_digest() at
the beginning of replace_map_fd_with_map_ptr() and also error handling
stays straight forward.

Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/bpf.h
include/linux/filter.h
kernel/bpf/core.c
kernel/bpf/syscall.c
kernel/bpf/verifier.c