Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp5545974ybe; Tue, 10 Sep 2019 05:33:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqyX29dZzsizrj2+9SzpaLb1uRoeAE7zkGR7IcOpTxv9zGLn9mbc4JSiDL105l/z9gfIWV5x X-Received: by 2002:a17:906:7f91:: with SMTP id f17mr24041618ejr.125.1568118794812; Tue, 10 Sep 2019 05:33:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568118794; cv=none; d=google.com; s=arc-20160816; b=wk4SuPRM0RBVj5J092JyTEw5/JOXHnqebWBCHKkExI7vp7t7fkQUE9MIGJ7R2seG5v 5NFT8QTzeZV4INA5ktMG1j6O2/SnmPSi1VEeUgeEKyxYOm79FPehV2ysibzjVXWHWZ8z vtiuWMon62znHlu97EbUxJOh+BxrqWFb3prPj4EBLvnSuZY961ZoXGMTnq5jiDRDX4/Q +CUBELohWuI3mEhPdAgIe5wviTNE0DLJEkmfLDnbGcPTFOvqd/wXwXup7Nn6Fe8SbJHd zrM8YUSbY2l1I87pVr4ks0EQFoIZn8krfc9V8qMCjdYE4IyQjjmg3acbvJp4cMM4n4Ky Muqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language:thread-index :content-transfer-encoding:mime-version:message-id:date:subject :in-reply-to:references:cc:to:from:dkim-signature; bh=tbEJyL1pzhCgN6+leHZvjfdw1nacb76EZ3WNKZG2SSY=; b=iIOu6+XYRJAJg9ET6pV/0hq0N3ZHeedoBzOBm0rtlGHufWIwSf6kcvWILgCPDoooUf cHLULTRtajoWUQk+mBjSp1w86v8Bkh/ANP9OR4WU97MC1WLlfzxIEuOARAKtZiUjERh+ +ssebIa0Y81M/FXAkZiJji25L5n1oEWIvWT5cDF2vDWoARLhbPVtS0+WqTPJwVan5V6v SUP4/K2/LCQwGdWARpNBkfQzBUegMvdKoruPoz18fOChDo+nVVYfiDnSj9fH4t1oSCKv MtOeTmcp0LiFYd1EniV1YcMmm2DjSJZuzGi1bgMfuSTEGLJDIeJbz/Pg9TIiv+4Ufx3B vQ1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@d-silva.org header.s=201810a header.b=bLdhODUh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s27si10871192edm.226.2019.09.10.05.32.50; Tue, 10 Sep 2019 05:33:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@d-silva.org header.s=201810a header.b=bLdhODUh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732329AbfIJKZH (ORCPT + 99 others); Tue, 10 Sep 2019 06:25:07 -0400 Received: from ushosting.nmnhosting.com ([66.55.73.32]:42938 "EHLO ushosting.nmnhosting.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726960AbfIJKZF (ORCPT ); Tue, 10 Sep 2019 06:25:05 -0400 Received: from mail2.nmnhosting.com (unknown [202.169.106.97]) by ushosting.nmnhosting.com (Postfix) with ESMTPS id C3FF82DC1B4F; Tue, 10 Sep 2019 06:25:00 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=d-silva.org; s=201810a; t=1568111101; bh=HDAltXrE8fa0s1cXwhaPiIFePgfp29KfB1TH4WQiFKM=; h=From:To:Cc:References:In-Reply-To:Subject:Date:From; b=bLdhODUhBW4Fo/x94Nj+R+V91mwnbDdWHLNOGLCq0biZGZH3Jh+idjt+I4APSOr8C Rbc8OmvyYWwlcbdY4DffVqXm1RUEEn3bfRKdaZ1uoMBCsX+spov/LrzTCPI8p/m6yG eorPdXIjF7Xp4/1L2OakqTNsZo7lNf7vyW9f4wCMpok5yTmvZEsL0GMXwFEsrDvVqV u2BgYZUPjehGpv0d4ae7pNuevsXh0ymINJnKAs/jiu7A8fXASd+pYF2Z09eDbzZJTh rpu+wYaQiZaqh9o5kRpPypjiPm7X6UFOTf8brRROPvWQI0tSg3gcbZbnpN8doK/0IN To853JLOgdR9DOz+Rofmdkpor1j24qEnCwrL59ebH7AMvY/hgaDftc8bL+w6G3fDiu /DdLZUth6SFIpG/syJjKU3YM7QaK33iOJMTO6896o/9bTT2Wyrd0PQItUV+aDxtWFh 5uh5FAYEVcPNCe4PJ7st0HYpohFsbuKa9xyf360C6loFML0oFu6jUNQYj0uur0Skg0 1fg545R3fYt0a+/SbIObDbvt9lhOh7fMJeqCxkIaudOiWBuTxoYKmBCzDF+5yKubCL f82z0VccKg8yE5D2YaC57RDufBuKihrXFF2SH0JqSFbPOehLLX0RZH1maGEvkJ7hTj ZOP4NSLQU6ekz1+NkJkLdFdQ= Received: from Hawking (ntp.lan [10.0.1.1]) (authenticated bits=0) by mail2.nmnhosting.com (8.15.2/8.15.2) with ESMTPSA id x8AAOsMd022564 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 10 Sep 2019 20:24:54 +1000 (AEST) (envelope-from alastair@d-silva.org) From: "Alastair D'Silva" To: "'David Hildenbrand'" , "'Alastair D'Silva'" Cc: "'Andrew Morton'" , "'Oscar Salvador'" , "'Michal Hocko'" , "'Pavel Tatashin'" , "'Dan Williams'" , "'Wei Yang'" , "'Qian Cai'" , "'Jason Gunthorpe'" , "'Logan Gunthorpe'" , "'Ira Weiny'" , , References: <20190910025225.25904-1-alastair@au1.ibm.com> <20190910025225.25904-3-alastair@au1.ibm.com> <6ca671a0-8b00-e974-7de9-a574ad9b77ec@redhat.com> In-Reply-To: <6ca671a0-8b00-e974-7de9-a574ad9b77ec@redhat.com> Subject: RE: [PATCH 2/2] mm: Add a bounds check in devm_memremap_pages() Date: Tue, 10 Sep 2019 20:24:54 +1000 Message-ID: <05af01d567c1$fdb256d0$f9170470$@d-silva.org> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQHvMJj7Zv4jgOWqcZIGTeYry0K56gJQpAzUAu4+QZimxyuUcA== Content-Language: en-au X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.6.2 (mail2.nmnhosting.com [10.0.1.20]); Tue, 10 Sep 2019 20:24:56 +1000 (AEST) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > -----Original Message----- > From: David Hildenbrand > Sent: Tuesday, 10 September 2019 5:39 PM > To: Alastair D'Silva ; alastair@d-silva.org > Cc: Andrew Morton ; Oscar Salvador > ; Michal Hocko ; Pavel Tatashin > ; Dan Williams ; > Wei Yang ; Qian Cai ; Jason > Gunthorpe ; Logan Gunthorpe ; Ira > Weiny ; linux-mm@kvack.org; linux- > kernel@vger.kernel.org > Subject: Re: [PATCH 2/2] mm: Add a bounds check in > devm_memremap_pages() > > On 10.09.19 04:52, Alastair D'Silva wrote: > > From: Alastair D'Silva > > > > The call to check_hotplug_memory_addressable() validates that the > > memory is fully addressable. > > > > Without this call, it is possible that we may remap pages that is not > > physically addressable, resulting in bogus section numbers being > > returned from __section_nr(). > > > > Signed-off-by: Alastair D'Silva > > --- > > mm/memremap.c | 8 ++++++++ > > 1 file changed, 8 insertions(+) > > > > diff --git a/mm/memremap.c b/mm/memremap.c index > > 86432650f829..fd00993caa3e 100644 > > --- a/mm/memremap.c > > +++ b/mm/memremap.c > > @@ -269,6 +269,13 @@ void *devm_memremap_pages(struct device > *dev, > > struct dev_pagemap *pgmap) > > > > mem_hotplug_begin(); > > > > + error = check_hotplug_memory_addressable(res->start, > > + resource_size(res)); > > + if (error) { > > + mem_hotplug_done(); > > + goto err_checkrange; > > + } > > + > > No need to check under the memory hotplug lock. > Thanks, I'll adjust it. > > /* > > * For device private memory we call add_pages() as we only need to > > * allocate and initialize struct page for the device memory. More- > > @@ -324,6 +331,7 @@ void *devm_memremap_pages(struct device *dev, > > struct dev_pagemap *pgmap) > > > > err_add_memory: > > kasan_remove_zero_shadow(__va(res->start), resource_size(res)); > > + err_checkrange: > > err_kasan: > > untrack_pfn(NULL, PHYS_PFN(res->start), resource_size(res)); > > err_pfn_remap: > > > > > -- > > Thanks, > > David / dhildenb > -- Alastair D'Silva mob: 0423 762 819 skype: alastair_dsilva msn: alastair@d-silva.org blog: http://alastair.d-silva.org Twitter: @EvilDeece