From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752354AbdKUNG4 (ORCPT ); Tue, 21 Nov 2017 08:06:56 -0500 Received: from mx2.suse.de ([195.135.220.15]:41744 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752292AbdKUNGy (ORCPT ); Tue, 21 Nov 2017 08:06:54 -0500 Date: Tue, 21 Nov 2017 14:06:52 +0100 From: Michal Hocko To: Vlastimil Babka Cc: Mike Kravetz , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Joonsoo Kim , Michal Nazarewicz , Mel Gorman , Johannes Weiner , Andrew Morton , stable@vger.kernel.org Subject: Re: [PATCH 1/1] mm/cma: fix alloc_contig_range ret code/potential leak Message-ID: <20171121130652.pdgsswo63o4tfcee@dhcp22.suse.cz> References: <20171120193930.23428-1-mike.kravetz@oracle.com> <20171120193930.23428-2-mike.kravetz@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue 21-11-17 08:53:11, Vlastimil Babka wrote: > On 11/20/2017 08:39 PM, Mike Kravetz wrote: > > If the call __alloc_contig_migrate_range() in alloc_contig_range > > returns -EBUSY, processing continues so that test_pages_isolated() > > is called where there is a tracepoint to identify the busy pages. > > However, it is possible for busy pages to become available between > > the calls to these two routines. In this case, the range of pages > > may be allocated. Unfortunately, the original return code (ret > > == -EBUSY) is still set and returned to the caller. Therefore, > > the caller believes the pages were not allocated and they are leaked. > > > > Update the return code with the value from test_pages_isolated(). > > Good catch and seems ok for a stable fix. But it's another indication > that this area needs some larger rewrite. Absolutely. The whole thing is subtle as hell. And shaping the code just around the tracepoint here smells like the whole design could be thought through much more. -- Michal Hocko SUSE Labs From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Tue, 21 Nov 2017 14:06:52 +0100 From: Michal Hocko To: Vlastimil Babka Cc: Mike Kravetz , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Joonsoo Kim , Michal Nazarewicz , Mel Gorman , Johannes Weiner , Andrew Morton , stable@vger.kernel.org Subject: Re: [PATCH 1/1] mm/cma: fix alloc_contig_range ret code/potential leak Message-ID: <20171121130652.pdgsswo63o4tfcee@dhcp22.suse.cz> References: <20171120193930.23428-1-mike.kravetz@oracle.com> <20171120193930.23428-2-mike.kravetz@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: owner-linux-mm@kvack.org List-ID: On Tue 21-11-17 08:53:11, Vlastimil Babka wrote: > On 11/20/2017 08:39 PM, Mike Kravetz wrote: > > If the call __alloc_contig_migrate_range() in alloc_contig_range > > returns -EBUSY, processing continues so that test_pages_isolated() > > is called where there is a tracepoint to identify the busy pages. > > However, it is possible for busy pages to become available between > > the calls to these two routines. In this case, the range of pages > > may be allocated. Unfortunately, the original return code (ret > > == -EBUSY) is still set and returned to the caller. Therefore, > > the caller believes the pages were not allocated and they are leaked. > > > > Update the return code with the value from test_pages_isolated(). > > Good catch and seems ok for a stable fix. But it's another indication > that this area needs some larger rewrite. Absolutely. The whole thing is subtle as hell. And shaping the code just around the tracepoint here smells like the whole design could be thought through much more. -- Michal Hocko SUSE Labs -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org