Re: [PATCH v2] mm/mempolicy: do not allow illegal MPOL_F_NUMA_BALANCING | MPOL_LOCAL in mbind()

From: Huang, Ying
Date: Thu Oct 07 2021 - 21:23:17 EST


Hi, Eric,

Eric Dumazet <eric.dumazet@xxxxxxxxx> writes:

> From: Eric Dumazet <edumazet@xxxxxxxxxx>
>
> syzbot reported access to unitialized memory in mbind() [1]
>
> Issue came with commit bda420b98505 ("numa balancing: migrate on
> fault among multiple bound nodes")
>
> This commit added a new bit in MPOL_MODE_FLAGS, but only checked
> valid combination (MPOL_F_NUMA_BALANCING can only be used with MPOL_BIND)
> in do_set_mempolicy()
>
> This patch moves the check in sanitize_mpol_flags() so that it
> is also used by mbind()

Good catch! Thanks! When MPOL_F_NUMA_BALANCING is introduced, it is
intended to be used with set_memopolicy() syscall only, it is not
allowed to be used with mbind() syscall at least for now. But I
misunderstood the original code apparently.

So I think it may be better to return EINVAL for mbind() +
MPOL_F_NUMA_BALANCING?

Best Regards,
Huang, Ying