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>
This commit is contained in:

committed by
David S. Miller

parent
d66f2b91f9
commit
a2a7d57010
@@ -115,9 +115,11 @@ struct bpf_insn_aux_data {
|
||||
|
||||
#define MAX_USED_MAPS 64 /* max number of maps accessed by one eBPF program */
|
||||
|
||||
#define BPF_VERIFIER_TMP_LOG_SIZE 1024
|
||||
|
||||
struct bpf_verifer_log {
|
||||
u32 level;
|
||||
char *kbuf;
|
||||
char kbuf[BPF_VERIFIER_TMP_LOG_SIZE];
|
||||
char __user *ubuf;
|
||||
u32 len_used;
|
||||
u32 len_total;
|
||||
|
Reference in New Issue
Block a user