From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754251AbdASSeb (ORCPT ); Thu, 19 Jan 2017 13:34:31 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:47978 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754052AbdASSe0 (ORCPT ); Thu, 19 Jan 2017 13:34:26 -0500 Date: Thu, 19 Jan 2017 19:16:51 +0100 From: Greg KH To: Mike Kravetz Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Paul Cassella , Michal Hocko , Masayoshi Mizuma , Naoya Horiguchi , Aneesh Kumar , Hillf Danton , Andrew Morton , stable@vger.kernel.org Subject: Re: [PATCH] mm/hugetlb.c: fix reservation race when freeing surplus pages Message-ID: <20170119181651.GA30720@kroah.com> References: <1483991767-6879-1-git-send-email-mike.kravetz@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1483991767-6879-1-git-send-email-mike.kravetz@oracle.com> User-Agent: Mutt/1.7.2 (2016-11-26) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 09, 2017 at 11:56:07AM -0800, Mike Kravetz wrote: > The routine return_unused_surplus_pages decrements the global > reservation count, and frees any unused surplus pages that were > backing the reservation. Commit 7848a4bf51b3 ("mm/hugetlb.c: > add cond_resched_lock() in return_unused_surplus_pages()") added > a call to cond_resched_lock in the loop freeing the pages. As > a result, the hugetlb_lock could be dropped, and someone else > could use the pages that will be freed in subsequent iterations > of the loop. This could result in inconsistent global hugetlb > page state, application api failures (such as mmap) failures or > application crashes. > > When dropping the lock in return_unused_surplus_pages, make sure > that the global reservation count (resv_huge_pages) remains > sufficiently large to prevent someone else from claiming pages > about to be freed. > > Fixes: 7848a4bf51b3 ("mm/hugetlb.c: add cond_resched_lock() in return_unused_surplus_pages()") > Reported-and-analyzed-by: Paul Cassella > Suggested-by: Michal Hocko > Signed-off-by: Mike Kravetz > --- > mm/hugetlb.c | 37 ++++++++++++++++++++++++++++--------- > 1 file changed, 28 insertions(+), 9 deletions(-) This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read Documentation/stable_kernel_rules.txt for how to do this properly.