Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp5142245ybl; Mon, 26 Aug 2019 23:31:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqwXagJHcojFWqLveQcrg6KFqA++yPkGaKSiKk8n8j+IMRDRnWvLg7NsOEIGX2Zg5hTMRjli X-Received: by 2002:a17:90a:fa95:: with SMTP id cu21mr11458338pjb.43.1566887497168; Mon, 26 Aug 2019 23:31:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566887497; cv=none; d=google.com; s=arc-20160816; b=VUcrQ+UnKFd/cYxJhEfCD1GGZihYMs8iF4+ys3zx704Lhnjws2Dzu2GGMLIRjjATwk iGSQn99kaXAT1Pey9dAGQygqPI1aR2g96sGaEiMSWHOp6unmQ+KHAWAc8SmO4Qk3s/2w N82EIN4KMH8d6VBanQZEQNx32deHLuPo4mXBzBCs7o6xt9SFO7mevpv6MODbkvzlgwt1 RmZvNgzcLYEyzCOhEMwjTDksVtBg6ebVP0tMODwWHy8O/I3xkllwK7eh52yX63MSFBkc WwjCs/ye0I2UsSamhEKJCZUwS1o4FmlRJMVwi7jII+pRIravOTEKeYq/TsCIddo9IBkP 76uA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=qzffjXj3LOmrE4XYQUs5URNmcrR5fyIKvV7nNyL+bOU=; b=WF2JoEM81AcAgHoxmYUqP7dxYXpi5AHB0x14+OFrLRsJUCiSQH6efIxgdoa+PojugO 4DGaUBR59o+jl9yZ01kKxDz+zhOxlvQ+v0csy7K+IjSCfHhvMejBm6fxtbPz8Qv9mHph hNvUEMgKLBO4fb1gGfQMTFZLOTaD7SxoNO+9bfw7epvnVKBEF4Mj1a4UHQqMujT6ro9b NYMzI2YYkwKcgpJcNR+O82k7PSigHC3mEWjvC1SZ+lZq0vhMo1fjueJI30y+XpLS78LE 7WdYGf8liLHlySKmoxBpZ39iJpTsgShGvGS2tpmq6nggs80E8lmbK/Fe1hmP0hcGw6dC MCWg== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a17si10970248pgi.430.2019.08.26.23.31.21; Mon, 26 Aug 2019 23:31:37 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728676AbfH0G2r (ORCPT + 99 others); Tue, 27 Aug 2019 02:28:47 -0400 Received: from mx2.suse.de ([195.135.220.15]:56358 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725860AbfH0G2r (ORCPT ); Tue, 27 Aug 2019 02:28:47 -0400 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 D72E8B0B6; Tue, 27 Aug 2019 06:28:45 +0000 (UTC) Date: Tue, 27 Aug 2019 08:28:44 +0200 From: Michal Hocko To: Alastair D'Silva Cc: alastair@d-silva.org, Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Christophe Leroy , Andrew Morton , David Hildenbrand , Mike Rapoport , "Aneesh Kumar K.V" , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] powerpc: Perform a bounds check in arch_add_memory Message-ID: <20190827062844.GQ7538@dhcp22.suse.cz> References: <20190827052047.31547-1-alastair@au1.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190827052047.31547-1-alastair@au1.ibm.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue 27-08-19 15:20:46, Alastair D'Silva wrote: > From: Alastair D'Silva > > It is possible for firmware to allocate memory ranges outside > the range of physical memory that we support (MAX_PHYSMEM_BITS). Doesn't that count as a FW bug? Do you have any evidence of that in the field? Just wondering... > This patch adds a bounds check to ensure that any hotplugged > memory is addressable. > > Signed-off-by: Alastair D'Silva > --- > arch/powerpc/mm/mem.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c > index 9191a66b3bc5..de18fb73de30 100644 > --- a/arch/powerpc/mm/mem.c > +++ b/arch/powerpc/mm/mem.c > @@ -111,6 +111,9 @@ int __ref arch_add_memory(int nid, u64 start, u64 size, > unsigned long nr_pages = size >> PAGE_SHIFT; > int rc; > > + if ((start + size - 1) >> MAX_PHYSMEM_BITS) > + return -EINVAL; > + > resize_hpt_for_hotplug(memblock_phys_mem_size()); > > start = (unsigned long)__va(start); > -- > 2.21.0 -- Michal Hocko SUSE Labs