Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp896454lqj; Mon, 3 Jun 2024 04:29:27 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUZZyuoA5gBZZuqGKgYmUt5VCdRPH5s9qN18lGXzo9cc0/cARvmc3sqC+iW1O5AmSG/5tiSIvmH3IdRKYfD96KmtBo6PSn316I4zcgg8A== X-Google-Smtp-Source: AGHT+IEdItv+szf4//Y2XQ45CCTa51ZMmYf9ixY7vgML0BZ7NPacSVU1dcIlUItpMmA/dweg5heX X-Received: by 2002:a05:6a20:2590:b0:1b1:d371:334d with SMTP id adf61e73a8af0-1b26f17e13cmr9178400637.30.1717414167090; Mon, 03 Jun 2024 04:29:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717414167; cv=pass; d=google.com; s=arc-20160816; b=Rib7AcOWN5jqb1v1b/GgjJvoXEc5AP/RTZ0L4OlOEeiNO60v6exDxkwC+xy2Vqf7gZ BjotM/YpgPUotmWgi3OcbTcCvlwJP5gELFdvskBS1CEs79Z79L2IUyz6bJG/MxeGMp/8 DZpD5APKi65WaghwD96JN5sPBMXgg5xMZmBaQnaQMsh3JQmMJmbMrQ52eUPghkbUM9iw u25b32TWvDggql4ONoWB+7YgFUP/gqjhgi5BG97tN5wycktgUzMCHnPt+FZ6VOAM4bP7 uygl3dnNSEj5JKtY0ZfSqM6W743j17GhB+u3K6+40QyHpecyhboQ+U1wKlmVyiKJQhIP ZmqA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=nmCbtCjlOeE8C0MOveuVjkkNDvPDHJtQtsNCIxtYh7Y=; fh=HlPzSTcwyGoWiUooRoWmFj3wmfeAeB18/BY6H1AsaDk=; b=cu0Gwu+o6QX0+DKg4BGDXT2LlElLFQZR/s/f1bDQDE1035j9FuTv6tpxd48/CnpsZ5 G9fXrOm/LqdVYScan9y5JwFTGbhCjh458WazsHQkmJ/MVkIG7uo0JmJHjv8mMCfZgpBr buX3m3/N7BAhwG2lejt40ABvK5WUT+nZ2zkWdVy/FGwuV54fzs88tkHTOhf2UVzhnpji mk1fcXjnmbSWOaAw6TWsVlY6XHxX5CA4WxD+hV039vkPtt+GNRqrOyi+XI4tSLLuAPvC FxtRN2B4bEadkC194j+Gu/y+Yi77TFus5QRjC2ZbK8Q7+FV5HntEZK9b07I/mySLVnMQ II1A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=astralinux.ru); spf=pass (google.com: domain of linux-kernel+bounces-199050-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199050-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d2e1a72fcca58-70242b09c96si266250b3a.179.2024.06.03.04.29.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 04:29:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-199050-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=astralinux.ru); spf=pass (google.com: domain of linux-kernel+bounces-199050-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199050-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 312F3282F04 for ; Mon, 3 Jun 2024 11:29:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1CBBC84A46; Mon, 3 Jun 2024 11:29:21 +0000 (UTC) Received: from new-mail.astralinux.ru (new-mail.astralinux.ru [51.250.53.244]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 70BD484039 for ; Mon, 3 Jun 2024 11:29:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=51.250.53.244 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717414160; cv=none; b=liCcrr3gYStgJgQCi9qazlKgoK1mhvi68+g3Kt2V1R99rOBEWRBscQOBzL0U1SeLJ43oRfQ5uKuqqm4rHABpFfsA22OH9Slo8BtvgWSDUflcF9Ko7Mnz+WdTfGvANaDQ77OZsdFGgexwb+39+Wtvi0jpB+lSGzhNoPpiE+AitdM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717414160; c=relaxed/simple; bh=sDb05zDbDJ3VczZK0QFfMzi1YM/ZIKErl9mjc1+LK4c=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=fb2kfwZNsUPFaY8ICcMVB0g2kzphzEiSywYHQYUdO3ZwMQjbG88l/GYFutybjqImPv9jzW85jyeZIXEAvtziXvgiv7Z5606sxGmo/SyuLJjp3WD55MvtxnU7W73mB+ATpJ0rSPdHmGT/qGan+RzaWtbz3169gUOwDFdbwp7yR3E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=astralinux.ru; spf=pass smtp.mailfrom=astralinux.ru; arc=none smtp.client-ip=51.250.53.244 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=astralinux.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=astralinux.ru Received: from rbta-msk-lt-106062.astralinux.ru (unknown [10.177.20.58]) by new-mail.astralinux.ru (Postfix) with ESMTPA id 4VtBMF2Ln0zyfG; Mon, 3 Jun 2024 14:29:13 +0300 (MSK) From: Anastasia Belova To: David Hildenbrand Cc: Anastasia Belova , Oscar Salvador , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org Subject: [PATCH] mm/memory_hotplug: prevent accessing by index=-1 Date: Mon, 3 Jun 2024 14:28:30 +0300 Message-Id: <20240603112830.7432-1-abelova@astralinux.ru> X-Mailer: git-send-email 2.30.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-DrWeb-SpamScore: -100 X-DrWeb-SpamState: legit X-DrWeb-SpamDetail: gggruggvucftvghtrhhoucdtuddrgedvfedrvdehuddgtddvucetufdoteggodetrfcurfhrohhfihhlvgemucfftfghgfeunecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkffoggfgsedtkeertdertddtnecuhfhrohhmpeetnhgrshhtrghsihgruceuvghlohhvrgcuoegrsggvlhhovhgrsegrshhtrhgrlhhinhhugidrrhhuqeenucggtffrrghtthgvrhhnpeffvddvueehvedvgfeivdeuvdduteeulefgfeehieffgfehtedutdfgveefvdeiheenucffohhmrghinheplhhinhhugihtvghsthhinhhgrdhorhhgnecukfhppedutddrudejjedrvddtrdehkeenucfrrghrrghmpehhvghloheprhgsthgrqdhmshhkqdhlthdquddtiedtiedvrdgrshhtrhgrlhhinhhugidrrhhupdhinhgvthepuddtrddujeejrddvtddrheekmeefheejkeeipdhmrghilhhfrhhomheprggsvghlohhvrgesrghsthhrrghlihhnuhigrdhruhdpnhgspghrtghpthhtohepjedprhgtphhtthhopegurghvihgusehrvgguhhgrthdrtghomhdprhgtphhtthhopegrsggvlhhovhgrsegrshhtrhgrlhhinhhugidrrhhupdhrtghpthhtohepohhsrghlvhgrughorhesshhushgvrdguvgdprhgtphhtthhopegrkhhpmheslhhinhhugidqfhhouhhnuggrthhiohhnrdhorhhgpdhrtghpthhtoheplhhinhhugidqmhhmsehkvhgrtghkrdhorhhgpd hrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhvtgdqphhrohhjvggttheslhhinhhugihtvghsthhinhhgrdhorhhg X-DrWeb-SpamVersion: Vade Retro 01.423.251#02 AS+AV+AP Profile: DRWEB; Bailout: 300 X-AntiVirus: Checked by Dr.Web [MailD: 11.1.19.2307031128, SE: 11.1.12.2210241838, Core engine: 7.00.65.05230, Virus records: 12717933, Updated: 2024-Jun-03 09:24:46 UTC] nid may be equal to NUMA_NO_NODE=-1. Prevent accessing node_data array by invalid index with check for nid. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: e83a437faa62 ("mm/memory_hotplug: introduce "auto-movable" online policy") Signed-off-by: Anastasia Belova --- mm/memory_hotplug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 431b1f6753c0..bb98ee8fe698 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -846,7 +846,7 @@ static bool auto_movable_can_online_movable(int nid, struct memory_group *group, unsigned long kernel_early_pages, movable_pages; struct auto_movable_group_stats group_stats = {}; struct auto_movable_stats stats = {}; - pg_data_t *pgdat = NODE_DATA(nid); + pg_data_t *pgdat = (nid != NUMA_NO_NODE) ? NODE_DATA(nid) : NULL; struct zone *zone; int i; -- 2.30.2