Message ID | 1403616802-25743-3-git-send-email-tklauser@distanz.ch |
---|---|
State | Accepted, archived |
Delegated to: | David Miller |
Headers | show |
On 06/24/2014 03:33 PM, Tobias Klauser wrote: > Use kcalloc/kmalloc_array to make it clear we're allocating arrays. No > integer overflow can actually happen here, since len/flen is guaranteed > to be less than BPF_MAXINSNS (4096). However, this changed makes sure > we're not going to get one if BPF_MAXINSNS were ever increased. > > Signed-off-by: Tobias Klauser <tklauser@distanz.ch> Acked-by: Daniel Borkmann <dborkman@redhat.com> -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Tue, Jun 24, 2014 at 6:33 AM, Tobias Klauser <tklauser@distanz.ch> wrote: > Use kcalloc/kmalloc_array to make it clear we're allocating arrays. No > integer overflow can actually happen here, since len/flen is guaranteed > to be less than BPF_MAXINSNS (4096). However, this changed makes sure > we're not going to get one if BPF_MAXINSNS were ever increased. > > Signed-off-by: Tobias Klauser <tklauser@distanz.ch> typo in the commit log '… this changeD…' other than that: Acked-by: Alexei Starovoitov <ast@plumgrid.com> > --- > net/core/filter.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/net/core/filter.c b/net/core/filter.c > index ed8d929..e44c1c4 100644 > --- a/net/core/filter.c > +++ b/net/core/filter.c > @@ -844,7 +844,7 @@ int sk_convert_filter(struct sock_filter *prog, int len, > return -EINVAL; > > if (new_prog) { > - addrs = kzalloc(len * sizeof(*addrs), GFP_KERNEL); > + addrs = kcalloc(len, sizeof(*addrs), GFP_KERNEL); > if (!addrs) > return -ENOMEM; > } > @@ -1101,7 +1101,7 @@ static int check_load_and_stores(struct sock_filter *filter, int flen) > > BUILD_BUG_ON(BPF_MEMWORDS > 16); > > - masks = kmalloc(flen * sizeof(*masks), GFP_KERNEL); > + masks = kmalloc_array(flen, sizeof(*masks), GFP_KERNEL); > if (!masks) > return -ENOMEM; > > -- > 1.7.9.5 > > -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
From: Tobias Klauser <tklauser@distanz.ch> Date: Tue, 24 Jun 2014 15:33:22 +0200 > Use kcalloc/kmalloc_array to make it clear we're allocating arrays. No > integer overflow can actually happen here, since len/flen is guaranteed > to be less than BPF_MAXINSNS (4096). However, this changed makes sure > we're not going to get one if BPF_MAXINSNS were ever increased. > > Signed-off-by: Tobias Klauser <tklauser@distanz.ch> Applied, thank you. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/net/core/filter.c b/net/core/filter.c index ed8d929..e44c1c4 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -844,7 +844,7 @@ int sk_convert_filter(struct sock_filter *prog, int len, return -EINVAL; if (new_prog) { - addrs = kzalloc(len * sizeof(*addrs), GFP_KERNEL); + addrs = kcalloc(len, sizeof(*addrs), GFP_KERNEL); if (!addrs) return -ENOMEM; } @@ -1101,7 +1101,7 @@ static int check_load_and_stores(struct sock_filter *filter, int flen) BUILD_BUG_ON(BPF_MEMWORDS > 16); - masks = kmalloc(flen * sizeof(*masks), GFP_KERNEL); + masks = kmalloc_array(flen, sizeof(*masks), GFP_KERNEL); if (!masks) return -ENOMEM;
Use kcalloc/kmalloc_array to make it clear we're allocating arrays. No integer overflow can actually happen here, since len/flen is guaranteed to be less than BPF_MAXINSNS (4096). However, this changed makes sure we're not going to get one if BPF_MAXINSNS were ever increased. Signed-off-by: Tobias Klauser <tklauser@distanz.ch> --- net/core/filter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)