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:   Tue, 18 Feb 2020 15:43:11 -0800
From:   Mike Kravetz <mike.kravetz@...cle.com>
To:     Mina Almasry <almasrymina@...gle.com>
Cc:     Andrew Morton <akpm@...ux-foundation.org>, linux-mm@...ck.org,
        linux-kernel@...r.kernel.org, Qian Cai <cai@....pw>
Subject: Re: [PATCH -next] mm/hugetlb: Fix file_region entry allocations

On 2/18/20 2:26 PM, Mina Almasry wrote:
> Commit a9e443086489e ("hugetlb: disable region_add file_region
> coalescing") introduced a bug with adding file_region entries
> that is fixed here:
> 
> 1. Refactor file_region entry allocation logic into 1 function called
>    from region_add and region_chg since the code is now identical.
> 2. region_chg only modifies resv->adds_in_progress after the regions
>    have been allocated. In the past it used to increment
>    adds_in_progress and then drop the lock, which would confuse racing
>    region_add calls into thinking they need to allocate entries when
>    they are not allowed.
> 3. In region_add, only try to allocate regions when
>    actual_regions_needed > in_regions_needed. This is not causing a bug
>    but is better for cleanliness and reasoning about the code.
> 
> Tested using ltp hugemmap0* tests, and libhugetlbfs tests.
> 
> Reported-by: Qian Cai <cai@....pw>
> Signed-off-by: Mina Almasry <almasrymina@...gle.com>
> Fixes: Commit a9e443086489e ("hugetlb: disable region_add file_region
> coalescing")
> 
> ---
>  mm/hugetlb.c | 149 +++++++++++++++++++++++++--------------------------
>  1 file changed, 74 insertions(+), 75 deletions(-)
> 
> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> index 8171d2211be77..3d5b48ae8971f 100644
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -439,6 +439,66 @@ static long add_reservation_in_range(struct resv_map *resv, long f, long t,
>  	return add;
>  }
> 
> +/* Must be called with resv->lock acquired. Will drop lock to allocate entries.
> + */
> +static int allocate_file_region_entries(struct resv_map *resv,
> +					int regions_needed)
> +{

I think this is going to need annotation for the lock or sparse is going
throw a warning.  See,

https://lore.kernel.org/linux-mm/20200214204741.94112-7-jbi.octave@gmail.com/

Other than that, looks good.  Sorry I missed that race in the review.
-- 
Mike Kravetz

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ