diff options
| author | Dan Carpenter <dan.carpenter@oracle.com> | 2018-07-13 11:11:39 -0400 |
|---|---|---|
| committer | Alexei Starovoitov <ast@kernel.org> | 2018-07-16 18:00:56 -0400 |
| commit | b0294bc1ad19e9d2dd03df5faa1ccc395d4ddd4b (patch) | |
| tree | 830ba9e74e7b8d8c48c60f9dda4ec0d0b4305e87 /samples | |
| parent | 301f935be9e09a1bf188bd8262a4db0aeeac2b50 (diff) | |
samples: bpf: ensure that we don't load over MAX_PROGS programs
I can't see that we check prog_cnt to ensure it doesn't go over
MAX_PROGS.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'samples')
| -rw-r--r-- | samples/bpf/bpf_load.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/samples/bpf/bpf_load.c b/samples/bpf/bpf_load.c index 89161c9ed466..904e775d1a44 100644 --- a/samples/bpf/bpf_load.c +++ b/samples/bpf/bpf_load.c | |||
| @@ -107,6 +107,9 @@ static int load_and_attach(const char *event, struct bpf_insn *prog, int size) | |||
| 107 | return -1; | 107 | return -1; |
| 108 | } | 108 | } |
| 109 | 109 | ||
| 110 | if (prog_cnt == MAX_PROGS) | ||
| 111 | return -1; | ||
| 112 | |||
| 110 | fd = bpf_load_program(prog_type, prog, insns_cnt, license, kern_version, | 113 | fd = bpf_load_program(prog_type, prog, insns_cnt, license, kern_version, |
| 111 | bpf_log_buf, BPF_LOG_BUF_SIZE); | 114 | bpf_log_buf, BPF_LOG_BUF_SIZE); |
| 112 | if (fd < 0) { | 115 | if (fd < 0) { |
