lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CA+tQmHAzoBAvMHWGyTxzeNP6ghK6MAkPMfW0UhpE7so-ibb8uQ@mail.gmail.com>
Date:   Sat, 10 Sep 2022 22:24:22 +0800
From:   chi wu <wuchi.zero@...il.com>
To:     Andrew Morton <akpm@...ux-foundation.org>
Cc:     hch@....de, axboe@...nel.dk, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] relay: use kvcalloc to alloc page array in relay_alloc_page_array

Andrew Morton <akpm@...ux-foundation.org> 于2022年9月10日周六 05:48写道:

>
> On Fri,  9 Sep 2022 18:10:25 +0800 wuchi <wuchi.zero@...il.com> wrote:
>
> > The kvcalloc is safer because it will check the integer overflows,
> > and using it will simple the logic of allocation size.
> >
> > ...
> >
> > --- a/kernel/relay.c
> > +++ b/kernel/relay.c
> > @@ -60,10 +60,7 @@ static const struct vm_operations_struct relay_file_mmap_ops = {
> >   */
> >  static struct page **relay_alloc_page_array(unsigned int n_pages)
> >  {
> > -     const size_t pa_size = n_pages * sizeof(struct page *);
> > -     if (pa_size > PAGE_SIZE)
> > -             return vzalloc(pa_size);
> > -     return kzalloc(pa_size, GFP_KERNEL);
> > +     return kvcalloc(n_pages, sizeof(struct page *), GFP_KERNEL);
> >  }
>
> It isn't really equivalent because kvcalloc() may attempt a large
> kmalloc() request, whereas the current relay_alloc_page_array()
> implementation avoids this by choosing vmalloc() instead.
>
> But I doubt if it matters - kvcalloc()->kvmalloc_node() does take some
> care to prevent that large kmalloc() request from being too disruptive.
>
Thanks very much,got it.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ