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] [thread-next>] [day] [month] [year] [list]
Message-ID: <61d19ec8-2ba7-e156-7bb7-f746dae8e120@google.com>
Date: Mon, 24 Jun 2024 08:26:44 -0700 (PDT)
From: Hugh Dickins <hughd@...gle.com>
To: Usama Arif <usamaarif642@...il.com>
cc: Yosry Ahmed <yosryahmed@...gle.com>, 
    kernel test robot <oliver.sang@...el.com>, oe-lkp@...ts.linux.dev, 
    lkp@...el.com, Linux Memory Management List <linux-mm@...ck.org>, 
    Andrew Morton <akpm@...ux-foundation.org>, 
    Chengming Zhou <chengming.zhou@...ux.dev>, Nhat Pham <nphamcs@...il.com>, 
    David Hildenbrand <david@...hat.com>, "Huang, Ying" <ying.huang@...el.com>, 
    Hugh Dickins <hughd@...gle.com>, Johannes Weiner <hannes@...xchg.org>, 
    Matthew Wilcox <willy@...radead.org>, 
    Shakeel Butt <shakeel.butt@...ux.dev>, Andi Kleen <ak@...ux.intel.com>, 
    linux-kernel@...r.kernel.org
Subject: Re: [linux-next:master] [mm] 0fa2857d23:
 WARNING:at_mm/page_alloc.c:#__alloc_pages_noprof

On Mon, 24 Jun 2024, Usama Arif wrote:
> On 24/06/2024 15:05, Yosry Ahmed wrote:
> > On Mon, Jun 24, 2024 at 1:49 AM kernel test robot <oliver.sang@...el.com>
> > wrote:
> >>
> >>
> >> Hello,
> >>
> >> kernel test robot noticed
> >> "WARNING:at_mm/page_alloc.c:#__alloc_pages_noprof" on:
> >>
> >> commit: 0fa2857d23aa170e5e28d13c467b303b0065aad8 ("mm: store zero pages to
> >> be swapped out in a bitmap")
> >> https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git master
> > This is coming from WARN_ON_ONCE_GFP(order > MAX_PAGE_ORDER, gfp), and
> > is triggered by the new bitmap_zalloc() call in the swapon path. For a
> > sufficiently large swapfile, bitmap_zalloc() (which uses kmalloc()
> > under the hood) cannot be used to allocate the bitmap.
> >
> > Usama, I think we want to use a variant of kvmalloc() here.

Yes, I hit the same problem with swapon in my testing,
and had been intending to send a patch.

> 
> Yes, just testing with below diff now. The patch is not in mm-stable yet, so
> will just send another revision with below diff included. Thanks!
> 
> 
> diff --git a/mm/swapfile.c b/mm/swapfile.c
> index 0b8270359bcf..2263f71baa31 100644
> --- a/mm/swapfile.c
> +++ b/mm/swapfile.c
> @@ -2643,7 +2643,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *,
> specialfile)
>         free_percpu(p->cluster_next_cpu);
>         p->cluster_next_cpu = NULL;
>         vfree(swap_map);
> -       bitmap_free(p->zeromap);
> +       kvfree(p->zeromap);

Yes.

>         kvfree(cluster_info);
>         /* Destroy swap account information */
>         swap_cgroup_swapoff(p->type);
> @@ -3170,7 +3170,7 @@ SYSCALL_DEFINE2(swapon, const char __user *,
> specialfile, int, swap_flags)
>                 goto bad_swap_unlock_inode;
>         }
> 
> -       p->zeromap = bitmap_zalloc(maxpages, GFP_KERNEL);
> +       p->zeromap = kvzalloc(DIV_ROUND_UP(maxpages, 8), GFP_KERNEL);

No, 8 is not right for 32-bit kernels. I think you want
	p->zeromap = kvzalloc(BITS_TO_LONGS(maxpages), GFP_KERNEL);
but please check it carefully, I'm easily confused by such conversions.

Hugh

>         if (!p->zeromap) {
>                 error = -ENOMEM;
>                 goto bad_swap_unlock_inode;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ