OSDN Git Service

bpf: write back the verifier log buffer as it gets filled
authorJakub Kicinski <jakub.kicinski@netronome.com>
Mon, 9 Oct 2017 17:30:15 +0000 (10:30 -0700)
committerDavid S. Miller <davem@davemloft.net>
Tue, 10 Oct 2017 19:30:16 +0000 (12:30 -0700)
commita2a7d5701052542cd2260e7659b12443e0a74733
treef879063be29de0e6d7435759db62f0157c7773ff
parentd66f2b91f95b56e31772b9faa0d036cd2e53cb02
bpf: write back the verifier log buffer as it gets filled

Verifier log buffer can be quite large (up to 16MB currently).
As Eric Dumazet points out if we allow multiple verification
requests to proceed simultaneously, malicious user may use the
verifier as a way of allocating large amounts of unswappable
memory to OOM the host.

Switch to a strategy of allocating a smaller buffer (1024B)
and writing it out into the user buffer after every print.

While at it remove the old BUG_ON().

This is in preparation of the global verifier lock removal.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Simon Horman <simon.horman@netronome.com>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/bpf_verifier.h
kernel/bpf/verifier.c