Skip to content

Commit

Permalink
samples: bpf: ensure that we don't load over MAX_PROGS programs
Browse files Browse the repository at this point in the history
I can't see that we check prog_cnt to ensure it doesn't go over
MAX_PROGS.

Signed-off-by: Dan Carpenter <[email protected]>
Signed-off-by: Alexei Starovoitov <[email protected]>
  • Loading branch information
Dan Carpenter authored and Alexei Starovoitov committed Jul 16, 2018
1 parent 301f935 commit b0294bc
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions samples/bpf/bpf_load.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ static int load_and_attach(const char *event, struct bpf_insn *prog, int size)
return -1;
}

if (prog_cnt == MAX_PROGS)
return -1;

fd = bpf_load_program(prog_type, prog, insns_cnt, license, kern_version,
bpf_log_buf, BPF_LOG_BUF_SIZE);
if (fd < 0) {
Expand Down

0 comments on commit b0294bc

Please sign in to comment.