Message ID | 20160810141146.GA22890@void |
---|---|
State | Changes Requested |
Delegated to: | Pablo Neira |
Headers | show |
On Wed, Aug 10, 2016 at 06:11:51PM +0400, Loganaden Velvindron wrote: > It is easier to check that the calculation doesn't wrap or return a smaller > allocation. Could you review the netfilter tree in search for similar kmalloc() invocation that can be replaced? I could at least find one more at quick glace. Thanks. -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Fri, Aug 12, 2016 at 01:13:52AM +0200, Pablo Neira Ayuso wrote: > On Wed, Aug 10, 2016 at 06:11:51PM +0400, Loganaden Velvindron wrote: > > It is easier to check that the calculation doesn't wrap or return a smaller > > allocation. > > Could you review the netfilter tree in search for similar kmalloc() > invocation that can be replaced? I could at least find one more at > quick glace. > > Thanks. Yes. I am currently working on that ! > -- > To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Fri, Aug 12, 2016 at 01:13:52AM +0200, Pablo Neira Ayuso wrote: > On Wed, Aug 10, 2016 at 06:11:51PM +0400, Loganaden Velvindron wrote: > > It is easier to check that the calculation doesn't wrap or return a smaller > > allocation. > > Could you review the netfilter tree in search for similar kmalloc() > invocation that can be replaced? I could at least find one more at > quick glace. > > Thanks. I saw quite a few, but many have constants. OK with replacing the ones with constants too ? > -- > To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" 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/netfilter/x_tables.c b/net/netfilter/x_tables.c index e0aa7c1..c8f20f2 100644 --- a/net/netfilter/x_tables.c +++ b/net/netfilter/x_tables.c @@ -1513,7 +1513,7 @@ xt_hook_ops_alloc(const struct xt_table *table, nf_hookfn *fn) if (!num_hooks) return ERR_PTR(-EINVAL); - ops = kmalloc(sizeof(*ops) * num_hooks, GFP_KERNEL); + ops = kmalloc_array(num_hooks, sizeof(*ops), GFP_KERNEL); if (ops == NULL) return ERR_PTR(-ENOMEM);
It is easier to check that the calculation doesn't wrap or return a smaller allocation. Signed-off-by: Loganaden Velvindron <logan@hackers.mu> --- net/netfilter/x_tables.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)