From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751770AbdKUOUU (ORCPT ); Tue, 21 Nov 2017 09:20:20 -0500 Received: from mail-qt0-f196.google.com ([209.85.216.196]:43289 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751729AbdKUOUO (ORCPT ); Tue, 21 Nov 2017 09:20:14 -0500 X-Google-Smtp-Source: AGs4zMYAWd2BEkKGCMJUISR8oqwnrTcsrdKNVsPoTzgxVrnU+48mR5z+MsFj//v+sf6Uyk4FsoMShQ== From: Michal Nazarewicz To: Mike Kravetz , linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Joonsoo Kim , Vlastimil Babka , Michal Hocko , Mel Gorman , Johannes Weiner , Andrew Morton , Mike Kravetz , stable@vger.kernel.org Subject: Re: [PATCH 1/1] mm/cma: fix alloc_contig_range ret code/potential leak In-Reply-To: <20171120193930.23428-2-mike.kravetz@oracle.com> Organization: https://mina86.com/ References: <20171120193930.23428-1-mike.kravetz@oracle.com> <20171120193930.23428-2-mike.kravetz@oracle.com> Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAJFBMVEWjgIPUupJ7V0jLrom4gmjPs42bY0MdFRLHgE5UPDCbfGm9mH6qmkAJAAACNUlEQVQ4y23SMW/aQBQHcKtb2Zx0abZeIxuTCSELJVmiinboRpGHJktloROQzUQcB2vUXFe35XBYUicRAiYUVSjfru/d+QwlnDz5p/97z+dnVcw5WVQ2zxpcdrQTTiIin3bB6lcaTnaBO5c8eoJG2yBl5El+Ob3fglMW3RUIkQ9xxQ8UBEFQafiVZ/5wZqWExM+LvwEegAY856xZO7MgQkq3jxpO56GXxO5VDQAjpVmWqPLYoSGvIahIuvAVHLeEEDd9DRYAkUcKzscAUgCQ0hwSKBOExuh7kvQQUskY4yjsHqeaCfFjLK6x1AzeeyiRD/C1JW5aGqw5IS5mZre+FVz0RVtoUGPJmBCP/4QPJGKUA1oEMJwAHIv+JljYZYCJi1FRQS2DaUw6sgsQTMfb0Fz9RvjyP3iR01x9RGj0N6HgcefS819CSjidDwIFPSFEDgRg1tUw2oBXAB33T2DV63XbM6AqhZzysm3ZcKZrKBAn5O7Q1rAqGoBKNGRsmUG1n0NKaJtd2RnscTWvnom6fGngDaNrCNl728A+c2gLQP8PFpkEjNWjlGqQfPEhWRqoInSyi2p+drsGDjhAeAeSQI8kfjSwbwCn8gblvIftInzT30HdQT2HlU4gwCbLSQ7VFqVEA0RCtjTwtnjdLlkasNjQwF7x02F2iQSL8XIGB8VQ71WBKHHf5XCIgLUUtIcGSBPhdZIQorpEBrxsqT3GYgRpmicIqrsEgSZm3FG+iJbHYid0/wGj+iTGCXRsqQAAAABJRU5ErkJggg== OpenPGP: id=AC1F5F5CD41888F8CC8458582060401250751FF4; url=https://mina86.com/mina86.pub X-Hashcash: 1:20:171121:stable@vger.kernel.org::/TUI0PiOh8+VAPnp:0000000000000000000000000000000000000001H1p X-Hashcash: 1:20:171121:mgorman@techsingularity.net::jK5b01BYmcSaSIgu:00000000000000000000000000000000001WZs X-Hashcash: 1:20:171121:hannes@cmpxchg.org::EgO1DzBvFlNk0Nag:00000000000000000000000000000000000000000001WSI X-Hashcash: 1:20:171121:mike.kravetz@oracle.com::oCPk11zNRtB/uyEI:0000000000000000000000000000000000000023Bo X-Hashcash: 1:20:171121:mhocko@suse.com::f3Vitrh790D4YhJ7:001wp7 X-Hashcash: 1:20:171121:akpm@linux-foundation.org::DzxDjDCLnDs5PyC/:0000000000000000000000000000000000001Qcc X-Hashcash: 1:20:171121:linux-mm@kvack.org::jvgFWs7AZ6T61ZOp:00000000000000000000000000000000000000000003XgS X-Hashcash: 1:20:171121:linux-kernel@vger.kernel.org::qRwJYScjqMFKCvj/:0000000000000000000000000000000004FVO X-Hashcash: 1:20:171121:mike.kravetz@oracle.com::9Hv55t+YGqa8d89T:000000000000000000000000000000000000007taG X-Hashcash: 1:20:171121:vbabka@suse.cz::TDOlJsJJXLs4jOhu:0009DOt X-Hashcash: 1:20:171121:iamjoonsoo.kim@lge.com::bQYsVQYGnTUVO5cK:000000000000000000000000000000000000000BC33 Date: Tue, 21 Nov 2017 15:20:09 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by nfs id vALEKUxf023286 On Mon, Nov 20 2017, 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(). > > Fixes: 8ef5849fa8a2 ("mm/cma: always check which page caused allocation failure") > Cc: > Signed-off-by: Mike Kravetz Acked-by: Michal Nazarewicz > --- > mm/page_alloc.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index 77e4d3c5c57b..3605ca82fd29 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -7632,10 +7632,10 @@ int alloc_contig_range(unsigned long start, unsigned long end, > } > > /* Make sure the range is really isolated. */ > - if (test_pages_isolated(outer_start, end, false)) { > + ret = test_pages_isolated(outer_start, end, false); > + if (ret) { > pr_info_ratelimited("%s: [%lx, %lx) PFNs busy\n", > __func__, outer_start, end); > - ret = -EBUSY; > goto done; > } -- Best regards ミハウ “𝓶𝓲𝓷𝓪86” ナザレヴイツ «If at first you don’t succeed, give up skydiving» From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: Michal Nazarewicz To: Mike Kravetz , linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Joonsoo Kim , Vlastimil Babka , Michal Hocko , Mel Gorman , Johannes Weiner , Andrew Morton , Mike Kravetz , stable@vger.kernel.org Subject: Re: [PATCH 1/1] mm/cma: fix alloc_contig_range ret code/potential leak In-Reply-To: <20171120193930.23428-2-mike.kravetz@oracle.com> References: <20171120193930.23428-1-mike.kravetz@oracle.com> <20171120193930.23428-2-mike.kravetz@oracle.com> Date: Tue, 21 Nov 2017 15:20:09 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Sender: owner-linux-mm@kvack.org List-ID: On Mon, Nov 20 2017, 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 > =3D=3D -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(). > > Fixes: 8ef5849fa8a2 ("mm/cma: always check which page caused allocation f= ailure") > Cc: > Signed-off-by: Mike Kravetz Acked-by: Michal Nazarewicz > --- > mm/page_alloc.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index 77e4d3c5c57b..3605ca82fd29 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -7632,10 +7632,10 @@ int alloc_contig_range(unsigned long start, unsig= ned long end, > } >=20=20 > /* Make sure the range is really isolated. */ > - if (test_pages_isolated(outer_start, end, false)) { > + ret =3D test_pages_isolated(outer_start, end, false); > + if (ret) { > pr_info_ratelimited("%s: [%lx, %lx) PFNs busy\n", > __func__, outer_start, end); > - ret =3D -EBUSY; > goto done; > } --=20 Best regards =E3=83=9F=E3=83=8F=E3=82=A6 =E2=80=9C=F0=9D=93=B6=F0=9D=93=B2=F0=9D=93=B7= =F0=9D=93=AA86=E2=80=9D =E3=83=8A=E3=82=B6=E3=83=AC=E3=83=B4=E3=82=A4=E3=83= =84 =C2=ABIf at first you don=E2=80=99t succeed, give up skydiving=C2=BB -- 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 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qk0-f199.google.com (mail-qk0-f199.google.com [209.85.220.199]) by kanga.kvack.org (Postfix) with ESMTP id A04AD6B0069 for ; Tue, 21 Nov 2017 09:20:14 -0500 (EST) Received: by mail-qk0-f199.google.com with SMTP id v137so6992007qkb.3 for ; Tue, 21 Nov 2017 06:20:14 -0800 (PST) Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id d20sor9911437qte.56.2017.11.21.06.20.13 for (Google Transport Security); Tue, 21 Nov 2017 06:20:13 -0800 (PST) From: Michal Nazarewicz Subject: Re: [PATCH 1/1] mm/cma: fix alloc_contig_range ret code/potential leak In-Reply-To: <20171120193930.23428-2-mike.kravetz@oracle.com> References: <20171120193930.23428-1-mike.kravetz@oracle.com> <20171120193930.23428-2-mike.kravetz@oracle.com> Date: Tue, 21 Nov 2017 15:20:09 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Sender: owner-linux-mm@kvack.org List-ID: To: Mike Kravetz , linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Joonsoo Kim , Vlastimil Babka , Michal Hocko , Mel Gorman , Johannes Weiner , Andrew Morton , stable@vger.kernel.org On Mon, Nov 20 2017, 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 > =3D=3D -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(). > > Fixes: 8ef5849fa8a2 ("mm/cma: always check which page caused allocation f= ailure") > Cc: > Signed-off-by: Mike Kravetz Acked-by: Michal Nazarewicz > --- > mm/page_alloc.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index 77e4d3c5c57b..3605ca82fd29 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -7632,10 +7632,10 @@ int alloc_contig_range(unsigned long start, unsig= ned long end, > } >=20=20 > /* Make sure the range is really isolated. */ > - if (test_pages_isolated(outer_start, end, false)) { > + ret =3D test_pages_isolated(outer_start, end, false); > + if (ret) { > pr_info_ratelimited("%s: [%lx, %lx) PFNs busy\n", > __func__, outer_start, end); > - ret =3D -EBUSY; > goto done; > } --=20 Best regards =E3=83=9F=E3=83=8F=E3=82=A6 =E2=80=9C=F0=9D=93=B6=F0=9D=93=B2=F0=9D=93=B7= =F0=9D=93=AA86=E2=80=9D =E3=83=8A=E3=82=B6=E3=83=AC=E3=83=B4=E3=82=A4=E3=83= =84 =C2=ABIf at first you don=E2=80=99t succeed, give up skydiving=C2=BB -- 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