From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 662AEC432C2 for ; Thu, 26 Sep 2019 07:40:16 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3E6062146E for ; Thu, 26 Sep 2019 07:40:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3E6062146E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id CB3C86B000A; Thu, 26 Sep 2019 03:40:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C3C766B000C; Thu, 26 Sep 2019 03:40:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ADC836B000D; Thu, 26 Sep 2019 03:40:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0082.hostedemail.com [216.40.44.82]) by kanga.kvack.org (Postfix) with ESMTP id 874CE6B000A for ; Thu, 26 Sep 2019 03:40:15 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id 3965CBF18 for ; Thu, 26 Sep 2019 07:40:15 +0000 (UTC) X-FDA: 75976273590.09.cream31_58d1de935ea07 X-HE-Tag: cream31_58d1de935ea07 X-Filterd-Recvd-Size: 2144 Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) by imf08.hostedemail.com (Postfix) with ESMTP for ; Thu, 26 Sep 2019 07:40:10 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id B572CAE78; Thu, 26 Sep 2019 07:40:08 +0000 (UTC) Date: Thu, 26 Sep 2019 09:40:05 +0200 From: Oscar Salvador To: Alastair D'Silva Cc: alastair@d-silva.org, Andrew Morton , Michal Hocko , David Hildenbrand , Pavel Tatashin , Dan Williams , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4] memory_hotplug: Add a bounds check to __add_pages Message-ID: <20190926073951.GA17200@linux> References: <20190926013406.16133-1-alastair@au1.ibm.com> <20190926013406.16133-2-alastair@au1.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190926013406.16133-2-alastair@au1.ibm.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Sep 26, 2019 at 11:34:05AM +1000, Alastair D'Silva wrote: > From: Alastair D'Silva > @@ -291,6 +307,10 @@ int __ref __add_pages(int nid, unsigned long pfn, unsigned long nr_pages, > unsigned long nr, start_sec, end_sec; > struct vmem_altmap *altmap = restrictions->altmap; > > + err = check_hotplug_memory_addressable(pfn, nr_pages); > + if (err) > + return err; > + I am probably off here because 1) I am jumping blind in a middle of a discussion and 2) I got back from holydays yesterday, so bear with me. Would not be better to just place the check in add_memory_resource instead? Take into account that we create the memory mapping for this range in arch_add_memory, so it looks weird to me to create the mapping if we are going to fail right after because the range is simply off. But as I said, I might be missing some previous discussion. -- Oscar Salvador SUSE L3