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: <CAGsJ_4zUf04L6PJROFbt9+QiYu6ceWJTwWzTDaD7pkd6v4GPNw@mail.gmail.com>
Date: Mon, 20 Jan 2025 15:02:18 +1300
From: Barry Song <21cnbao@...il.com>
To: Lance Yang <ioworker0@...il.com>
Cc: akpm@...ux-foundation.org, ryan.roberts@....com, dev.jain@....com, 
	david@...hat.com, shy828301@...il.com, ziy@...dia.com, libang.li@...group.com, 
	baolin.wang@...ux.alibaba.com, linux-kernel@...r.kernel.org, 
	linux-mm@...ck.org, Liam.Howlett@...cle.com, lorenzo.stoakes@...cle.com, 
	vbabka@...e.cz, jannh@...gle.com, Jason@...c4.com, 
	Mingzhe Yang <mingzhe.yang@...com>
Subject: Re: [RFC 1/1] mm/madvise: fail MADV_PAGEOUT on VM_DROPPABLE VMA

On Mon, Jan 20, 2025 at 2:31 PM Lance Yang <ioworker0@...il.com> wrote:
>
> MADV_PAGEOUT should fail on VMAs with the VM_DROPPABLE flag. While
> MADV_PAGEOUT is intended to move anonymous pages to swap, VM_DROPPABLE
> should not be swapped out.
>
> There is an issue where using MADV_PAGEOUT on a VMA with the VM_DROPPABLE
> flag behaves like MADV_DONTNEED, causing the pages to be dropped. This
> could break the semantics of MADV_PAGEOUT, IMO.
>
> So, let's add a check to detect the VM_DROPPABLE flag before doing
> MADV_PAGEOUT and returns -EINVAL.
>
> Fixes: 9651fcedf7b9 ("mm: add MAP_DROPPABLE for designating always lazily freeable mappings")
> Signed-off-by: Mingzhe Yang <mingzhe.yang@...com>
> Signed-off-by: Lance Yang <ioworker0@...il.com>

I am not convinced this is a correct patch. try_to_unmap_one() will
drop the folio.
madvise_pageout(vma, prev, start, end) will still go to shrink_folio_list() and
try_to_unmap_one().

> ---
>  mm/madvise.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/mm/madvise.c b/mm/madvise.c
> index 49f3a75046f6..29d0234da8a1 100644
> --- a/mm/madvise.c
> +++ b/mm/madvise.c
> @@ -1263,6 +1263,8 @@ static int madvise_vma_behavior(struct vm_area_struct *vma,
>         case MADV_COLD:
>                 return madvise_cold(vma, prev, start, end);
>         case MADV_PAGEOUT:
> +               if (vma->vm_flags & VM_DROPPABLE)
> +                       return -EINVAL;
>                 return madvise_pageout(vma, prev, start, end);
>         case MADV_FREE:
>         case MADV_DONTNEED:
> --
> 2.45.2
>

Thanks
Barry

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ