Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b0294bc1 authored by Dan Carpenter's avatar Dan Carpenter Committed by Alexei Starovoitov
Browse files

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: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent 301f935b
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -107,6 +107,9 @@ static int load_and_attach(const char *event, struct bpf_insn *prog, int size)
		return -1;
		return -1;
	}
	}


	if (prog_cnt == MAX_PROGS)
		return -1;

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