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]
Date: Mon, 3 Jun 2024 22:55:37 +0800
From: Lance Yang <ioworker0@...il.com>
To: Matthew Wilcox <willy@...radead.org>
Cc: akpm@...ux-foundation.org, ryan.roberts@....com, david@...hat.com, 
	21cnbao@...il.com, baolin.wang@...ux.alibaba.com, ziy@...dia.com, 
	fengwei.yin@...el.com, ying.huang@...el.com, libang.li@...group.com, 
	linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 1/1] mm/mlock: implement folio_mlock_step() using folio_pte_batch()

On Mon, Jun 3, 2024 at 10:43 PM Matthew Wilcox <willy@...radead.org> wrote:
>
> On Mon, Jun 03, 2024 at 10:07:45PM +0800, Lance Yang wrote:
> > +++ b/mm/mlock.c
> > @@ -307,26 +307,15 @@ void munlock_folio(struct folio *folio)
> >  static inline unsigned int folio_mlock_step(struct folio *folio,
> >               pte_t *pte, unsigned long addr, unsigned long end)
> >  {
> > -     unsigned int count, i, nr = folio_nr_pages(folio);
> > -     unsigned long pfn = folio_pfn(folio);
> > +     const fpb_t fpb_flags = FPB_IGNORE_DIRTY | FPB_IGNORE_SOFT_DIRTY;
> > +     unsigned int count = (end - addr) >> PAGE_SHIFT;
>
> This is a pre-existing bug, but ... what happens if you're on a 64-bit
> system and you mlock() a range that is exactly 2^44 bytes?  Seems to me
> that count becomes 0.  Why not use an unsigned long here and avoid the
> problem entirely?

Good catch! Thanks for pointing that out!
Let's use an unsigned long here instead to avoid the problem entirely :)

Thanks,
Lance

>
> folio_pte_batch() also needs to take an unsigned long max_nr in that
> case, because you aren't restricting it to folio_nr_pages().
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ