* [PATCH 1/2] samples: bpf: ensure that we don't load over MAX_PROGS programs
@ 2018-07-13 15:11 Dan Carpenter
2018-07-13 15:13 ` Colin Ian King
0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2018-07-13 15:11 UTC (permalink / raw)
To: Alexei Starovoitov; +Cc: Daniel Borkmann, netdev, kernel-janitors
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>
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)
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) {
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH 1/2] samples: bpf: ensure that we don't load over MAX_PROGS programs
2018-07-13 15:11 [PATCH 1/2] samples: bpf: ensure that we don't load over MAX_PROGS programs Dan Carpenter
@ 2018-07-13 15:13 ` Colin Ian King
2018-07-13 15:15 ` Dan Carpenter
0 siblings, 1 reply; 3+ messages in thread
From: Colin Ian King @ 2018-07-13 15:13 UTC (permalink / raw)
To: Dan Carpenter, Alexei Starovoitov
Cc: Daniel Borkmann, netdev, kernel-janitors
On 13/07/18 16:11, Dan Carpenter wrote:
> 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>
>
> 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)
> return -1;
> }
>
> + if (prog_cnt == MAX_PROGS)
> + return -1;
> +
Should that be "if (prog_cnt >= MAX_PROGS)" ?
> fd = bpf_load_program(prog_type, prog, insns_cnt, license, kern_version,
> bpf_log_buf, BPF_LOG_BUF_SIZE);
> if (fd < 0) {
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH 1/2] samples: bpf: ensure that we don't load over MAX_PROGS programs
2018-07-13 15:13 ` Colin Ian King
@ 2018-07-13 15:15 ` Dan Carpenter
0 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2018-07-13 15:15 UTC (permalink / raw)
To: Colin Ian King
Cc: Alexei Starovoitov, Daniel Borkmann, netdev, kernel-janitors
On Fri, Jul 13, 2018 at 04:13:30PM +0100, Colin Ian King wrote:
> On 13/07/18 16:11, Dan Carpenter wrote:
> > 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>
> >
> > 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)
> > return -1;
> > }
> >
> > + if (prog_cnt == MAX_PROGS)
> > + return -1;
> > +
>
> Should that be "if (prog_cnt >= MAX_PROGS)" ?
It's incremented one at a time so it can't go over.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-07-13 15:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-13 15:11 [PATCH 1/2] samples: bpf: ensure that we don't load over MAX_PROGS programs Dan Carpenter
2018-07-13 15:13 ` Colin Ian King
2018-07-13 15:15 ` Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox