Re: [4.14-stable PATCH] mm: mempolicy: make mbind() return -EIO when MPOL_MF_STRICT is specified

From: Greg KH
Date: Wed Apr 03 2019 - 10:06:01 EST


On Tue, Apr 02, 2019 at 07:16:20AM +0800, Yang Shi wrote:
> commit a7f40cfe3b7ada57af9b62fd28430eeb4a7cfcb7 upstream
>
> When MPOL_MF_STRICT was specified and an existing page was already on a
> node that does not follow the policy, mbind() should return -EIO. But
> commit 6f4576e3687b ("mempolicy: apply page table walker on
> queue_pages_range()") broke the rule.
>
> And commit c8633798497c ("mm: mempolicy: mbind and migrate_pages support
> thp migration") didn't return the correct value for THP mbind() too.
>
> If MPOL_MF_STRICT is set, ignore vma_migratable() to make sure it
> reaches queue_pages_to_pte_range() or queue_pages_pmd() to check if an
> existing page was already on a node that does not follow the policy.
> And, non-migratable vma may be used, return -EIO too if MPOL_MF_MOVE or
> MPOL_MF_MOVE_ALL was specified.
>
> Tested with https://github.com/metan-ucw/ltp/blob/master/testcases/kernel/syscalls/mbind/mbind02.c
>
> [akpm@xxxxxxxxxxxxxxxxxxxx: tweak code comment]
> Link: http://lkml.kernel.org/r/1553020556-38583-1-git-send-email-yang.shi@xxxxxxxxxxxxxxxxx
> Fixes: 6f4576e3687b ("mempolicy: apply page table walker on queue_pages_range()")
> Signed-off-by: Yang Shi <yang.shi@xxxxxxxxxxxxxxxxx>
> Signed-off-by: Oscar Salvador <osalvador@xxxxxxx>
> Reported-by: Cyril Hrubis <chrubis@xxxxxxx>
> Suggested-by: Kirill A. Shutemov <kirill@xxxxxxxxxxxxx>
> Acked-by: Rafael Aquini <aquini@xxxxxxxxxx>
> Reviewed-by: Oscar Salvador <osalvador@xxxxxxx>
> Acked-by: David Rientjes <rientjes@xxxxxxxxxx>
> Cc: Vlastimil Babka <vbabka@xxxxxxx>
> Cc: <stable@xxxxxxxxxxxxxxx>
> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
> Signed-off-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
> ---
> mm/mempolicy.c | 40 +++++++++++++++++++++++++++++++++-------
> 1 file changed, 33 insertions(+), 7 deletions(-)

All 3 of these now queued up, thanks.

greg k-h