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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 324C9C433F5 for ; Mon, 7 Mar 2022 05:14:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8AC938D0002; Mon, 7 Mar 2022 00:14:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 85AF88D0001; Mon, 7 Mar 2022 00:14:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6FBE48D0002; Mon, 7 Mar 2022 00:14:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0142.hostedemail.com [216.40.44.142]) by kanga.kvack.org (Postfix) with ESMTP id 611C78D0001 for ; Mon, 7 Mar 2022 00:14:15 -0500 (EST) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 07A7880DE36F for ; Mon, 7 Mar 2022 05:14:15 +0000 (UTC) X-FDA: 79216424070.16.3D0694D Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by imf03.hostedemail.com (Postfix) with ESMTP id 4210820004 for ; Mon, 7 Mar 2022 05:14:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646630054; x=1678166054; h=from:to:cc:subject:references:date:in-reply-to: message-id:mime-version; bh=T9LRO1EA9aNE6ZHnL/DaWq8Qv6KP6Ww4LEmcqSgmFVM=; b=hv3dc2ixW6q0I0Zb43B9hRHl9c4ukLQpeaRfZrJl85vKJlUDIOBHLC+M e6Cjv9eWdjerwT/cHKEYTUgVVM2MHKbWoUXqbFEdLSuvHDyNdWsDG2gC1 6KBZC6tHyMZSgDJGLURR7Y//zEYuzAIMHFqp9UlRFh28LDNeU+lN0of90 t/a/x7R4h3WnzDb1jOG6t43ac5JbyK54r1EDTzDxNmNVQooMbRvTaHPDu 5ciVgc1661P/bazn5g4tKNuxxfDaNkPEBWURBTZZXGUiqOP3Va3lA4nGv cwXEhiCD0YD472v0bO7822mhlKV8YOkWVsx+U36UgScm7APy3vYfCn7IL A==; X-IronPort-AV: E=McAfee;i="6200,9189,10278"; a="234908280" X-IronPort-AV: E=Sophos;i="5.90,160,1643702400"; d="scan'208";a="234908280" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2022 21:14:12 -0800 X-IronPort-AV: E=Sophos;i="5.90,160,1643702400"; d="scan'208";a="552998917" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.239.13.94]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2022 21:14:07 -0800 From: "Huang, Ying" To: Baolin Wang Cc: Miaohe Lin , , , , , , , , , , , , , , , , , , Subject: Re: [PATCH 14/16] mm/migration: fix potential invalid node access for reclaim-based migration References: <20220304093409.25829-1-linmiaohe@huawei.com> <20220304093409.25829-15-linmiaohe@huawei.com> Date: Mon, 07 Mar 2022 13:14:05 +0800 In-Reply-To: (Baolin Wang's message of "Mon, 7 Mar 2022 10:25:03 +0800") Message-ID: <87ee3e5opu.fsf@yhuang6-desk2.ccr.corp.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=ascii X-Rspamd-Queue-Id: 4210820004 X-Stat-Signature: 8f1chtkuozujadwnhc6ato8x7mhf6buf Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=hv3dc2ix; spf=none (imf03.hostedemail.com: domain of ying.huang@intel.com has no SPF policy when checking 192.55.52.151) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1646630054-883972 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: Baolin Wang writes: > On 3/4/2022 5:34 PM, Miaohe Lin wrote: >> If we failed to setup hotplug state callbacks for mm/demotion:online in >> some corner cases, node_demotion will be left uninitialized. Invalid node >> might be returned from the next_demotion_node() when doing reclaim-based >> migration. Use kcalloc to allocate node_demotion to fix the issue. >> Fixes: ac16ec835314 ("mm: migrate: support multiple target nodes >> demotion") >> Signed-off-by: Miaohe Lin >> --- >> mm/migrate.c | 6 +++--- >> 1 file changed, 3 insertions(+), 3 deletions(-) >> diff --git a/mm/migrate.c b/mm/migrate.c >> index 279940c0c064..7b1c0b988234 100644 >> --- a/mm/migrate.c >> +++ b/mm/migrate.c >> @@ -2516,9 +2516,9 @@ static int __init migrate_on_reclaim_init(void) >> { >> int ret; >> - node_demotion = kmalloc_array(nr_node_ids, >> - sizeof(struct demotion_nodes), >> - GFP_KERNEL); >> + node_demotion = kcalloc(nr_node_ids, >> + sizeof(struct demotion_nodes), >> + GFP_KERNEL); > > Nit: not sure if this is worthy of this rare corner case, but I think > the target demotion nodes' default value should be NUMA_NO_NODE > instead of 0. The "nr" field of "struct demotion_nodes" should be initialized as 0. I think that is checked before "nodes[]" field. Best Regards, Huang, Ying