Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1566575
| From | Michal Hocko <mhocko@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 5/6] treewide: use kv[mz]alloc* rather than opencoded variants |
| Date | 2017-01-25 14:10 +0100 |
| Message-ID | <t3vuO-2ag-13@gated-at.bofh.it> (permalink) |
| References | (2 earlier) <sYRmi-6IL-17@gated-at.bofh.it> <sYRvY-6LY-39@gated-at.bofh.it> <t1HTs-7WH-19@gated-at.bofh.it> <t3aTo-5Sx-31@gated-at.bofh.it> <t3tMl-136-1@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Wed 25-01-17 12:15:59, Vlastimil Babka wrote:
> On 01/24/2017 04:00 PM, Michal Hocko wrote:
> > > > Well, I am not opposed to kvmalloc_array but I would argue that this
> > > > conversion cannot introduce new overflow issues. The code would have
> > > > to be broken already because even though kmalloc_array checks for the
> > > > overflow but vmalloc fallback doesn't...
> > >
> > > Yeah I agree, but if some of the places were really wrong, after the
> > > conversion we won't see them anymore.
> > >
> > > > If there is a general interest for this API I can add it.
> > >
> > > I think it would be better, yes.
> >
> > OK, fair enough. I will fold the following into the original patch. I
> > was little bit reluctant to create kvcalloc so I've made the original
> > callers more talkative and added | __GFP_ZERO.
>
> Fair enough,
>
> > To be honest I do not
> > really like how kcalloc...
>
> how kcalloc what?
how kcalloc hides the GFP_ZERO and the name doesn't reflect that.
> [...]
> > diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c
> > index cdc55d5ee4ad..eca16612b1ae 100644
> > --- a/net/netfilter/x_tables.c
> > +++ b/net/netfilter/x_tables.c
> > @@ -712,10 +712,7 @@ EXPORT_SYMBOL(xt_check_entry_offsets);
> > */
> > unsigned int *xt_alloc_entry_offsets(unsigned int size)
> > {
> > - if (size < (SIZE_MAX / sizeof(unsigned int)))
> > - return kvzalloc(size * sizeof(unsigned int), GFP_KERNEL);
> > -
> > - return NULL;
> > + return kvmalloc_array(size * sizeof(unsigned int), GFP_KERNEL | __GFP_ZERO);
>
> This one wouldn't compile.
fixed, thanks!
--
Michal Hocko
SUSE Labs
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: [PATCH 5/6] treewide: use kv[mz]alloc* rather than opencoded variants Vlastimil Babka <vbabka@suse.cz> - 2017-01-20 15:00 +0100
Re: [PATCH 5/6] treewide: use kv[mz]alloc* rather than opencoded variants Michal Hocko <mhocko@kernel.org> - 2017-01-24 16:10 +0100
Re: [PATCH 5/6] treewide: use kv[mz]alloc* rather than opencoded variants Vlastimil Babka <vbabka@suse.cz> - 2017-01-25 12:20 +0100
Re: [PATCH 5/6] treewide: use kv[mz]alloc* rather than opencoded variants Michal Hocko <mhocko@kernel.org> - 2017-01-25 14:10 +0100
Re: [PATCH 5/6] treewide: use kv[mz]alloc* rather than opencoded variants Ilya Dryomov <idryomov@gmail.com> - 2017-01-25 14:50 +0100
csiph-web