Message ID | 20241107124116.579108-1-chenqiuji666@gmail.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 AE275E7716D for <linux-mm@archiver.kernel.org>; Thu, 5 Dec 2024 15:25:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8AE2D6B00A5; Thu, 5 Dec 2024 10:19:24 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 667666B0111; Thu, 5 Dec 2024 10:19:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 99C196B0112; Thu, 5 Dec 2024 10:19:12 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 538146B0083 for <linux-mm@kvack.org>; Thu, 7 Nov 2024 07:41:30 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id CA40F4060C for <linux-mm@kvack.org>; Thu, 7 Nov 2024 12:41:29 +0000 (UTC) X-FDA: 82759258848.23.1201A3E Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) by imf21.hostedemail.com (Postfix) with ESMTP id 91EB11C000A for <linux-mm@kvack.org>; Thu, 7 Nov 2024 12:40:20 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=TSxyDH5v; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf21.hostedemail.com: domain of chenqiuji666@gmail.com designates 209.85.214.194 as permitted sender) smtp.mailfrom=chenqiuji666@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1730983228; a=rsa-sha256; cv=none; b=qyFOX+TIj2YN1zsx0xIcM+IGXpLzL/kl4Ur0QvopxkpFepgTWR4D3lmKFGRiCmvDlXxdUM MA6VdDOmHrLUuPuYz1TJRvqSu8Zwot4TDq5RM+UaUMoJMR7I4lIIgh4nqTXFkMJK2xp7FO rA/LI6FmTCvI1tgUMxs6nVkKf65lbVY= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=TSxyDH5v; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf21.hostedemail.com: domain of chenqiuji666@gmail.com designates 209.85.214.194 as permitted sender) smtp.mailfrom=chenqiuji666@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1730983228; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=c2CJ986UJvVOmnYCWRFgLTfaGLueWOJGgrSGwHXq3Is=; b=8Mc+nb4GkB930GOc5r9QZHKOJHF08TMeQuKGQjgnVmcnDEPXnP3VsQ4oyjywG/zezRsi4m InuZN3Js8xrMyMFetwqfIjnjMVQhPI/FfpZVlfndm0KpgQMxJY/FD3n2Epcg6R6ZqxeOX/ kAQmHSaATusjCkS0nv71LgwaAIyAE5c= Received: by mail-pl1-f194.google.com with SMTP id d9443c01a7336-20c77459558so8416345ad.0 for <linux-mm@kvack.org>; Thu, 07 Nov 2024 04:41:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730983287; x=1731588087; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=c2CJ986UJvVOmnYCWRFgLTfaGLueWOJGgrSGwHXq3Is=; b=TSxyDH5ve3QLH8vlJB7pI7MH0hhxRrWe5ZfxWGjEOYWjWOffLLUEkIQogPPejnw9ib HF6JPuQ4ydVLqnUjmHhq4LFFX5NXXHmLN+uQr9SAObS6SfUNwkCHd1WxGcWB+IXY+C44 SxPa2w9ztAqLvEt5AXBdAcOeIzQs7LZRPB6Etgu73K2X2zD01MQ8jREh1uJlYNCe5j3Y vTNX9pmS/YpDRmaK2I0M8tvyetwgr0J9wcoYaYh1ls6CDjPb4ZJczTUEpVbz3HgNaWt1 eBodaHvrbFi3O/Gn4lyHIcvkZE8bfzD628LfJY2onke8dTLuBUVm10k/NI3ueSUV1lOq 2UOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730983287; x=1731588087; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=c2CJ986UJvVOmnYCWRFgLTfaGLueWOJGgrSGwHXq3Is=; b=sZJJ2QEsEZtzoSKBEbV0E5IXnIO8yVRJOMeyO0pre6AMNPTD1g1isgLIs7P9TzfpcL NzM6PSSc9F6a0sgTgZ58lbfRLQiPdXZUxOgU3C34hrcmzx35znq6klUjjl4rhWvfEJ1G 44qnLt0rrnhflQOM3GTSmyK7EXFClO88wHGLUH+bu7Nly87AJ04drpXS0mSuUAAc50vU BiaE8M18bo8umGUP9DfE+EDUZF8wiIXzZXSBoOV1qc5nz9poLlrkkL1PmMgVes8Ogsrt TD+fUREIAhlyxDwon+lfU3d/Bibqtt8bka3qT5rCHu1lLUYQ8DfUBqLHVl79eV/0wZrE LXcw== X-Gm-Message-State: AOJu0YyNTMCcgUouuLB+HBpOaqdzvLxrpJFi/XDN0uM1Ribr1E0aFkVC zxcpfdLZOuMEzvnaBJg6qzImIe/AV5JkM40tZKOabkoCz7C9yDB6 X-Google-Smtp-Source: AGHT+IGnJExR3DC/2QmwR+Z4/bRRQ9XGraI5dktdBuzJBr3CYwDgrgMxEs3TmN+2BvNAJj3RrnQ0dA== X-Received: by 2002:a17:902:db06:b0:20c:af5c:fc90 with SMTP id d9443c01a7336-2117d46ca7dmr8861825ad.49.1730983286612; Thu, 07 Nov 2024 04:41:26 -0800 (PST) Received: from tom-QiTianM540-A739.. ([106.39.42.118]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21177e41480sm11130145ad.116.2024.11.07.04.41.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Nov 2024 04:41:26 -0800 (PST) From: Qiu-ji Chen <chenqiuji666@gmail.com> To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, baijiaju1990@gmail.com, Qiu-ji Chen <chenqiuji666@gmail.com>, stable@vger.kernel.org Subject: [PATCH v2] mm: fix a possible null pointer dereference in setup_zone_pageset() Date: Thu, 7 Nov 2024 20:41:16 +0800 Message-Id: <20241107124116.579108-1-chenqiuji666@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspam-User: X-Rspamd-Queue-Id: 91EB11C000A X-Rspamd-Server: rspam01 X-Stat-Signature: wmf8crbtn68mmm8ig5jwin9yug715fk5 X-HE-Tag: 1730983220-415575 X-HE-Meta: U2FsdGVkX19epi0IEtq1jEgnTx1c0Mh+0ZIBfrKel/Z0larf1kDVHtWpwSctVIKGDtSceAyP4zrWjgnRStMXgk1faany8otboEdCh/FrjciGiaZA57RXiRmo5qppYVcukIFp2Cy1Cb5qRSGyiZeahOlUhmWzV8q/cVFy64ef+SZQtV1SjtF+ou/eqI3dJjxmlJu0/1lTi+VntHZyx0+YV3JjljIEyvkvsVyqqe/q5crXq7HZXgNB8izx1HJTdYLMoJo4m3J4gPKePUxJzuWou8SwcVIJXhnhuucXVHjEoEM7dMCWVPEWgW5L1aPYOewxxDq0YmBLF20aM0hE3+Cm5R1FjmNp0cbODO2JWrGLjdVDpTntRqPbKvcWlMXgm7wm/lFEsBndgMcTMDgtWTKn4qBl1x7At5GMiC4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e2ZMCXsYyr/sTc0Za5JEVQVL+cwzuuY56NcFwsEfXxwYM8tWmn1Y/t3lYdop0oYc54ZoifJyWGOVM= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: <linux-mm.kvack.org> List-Subscribe: <mailto:majordomo@kvack.org> List-Unsubscribe: <mailto:majordomo@kvack.org> |
Series |
[v2] mm: fix a possible null pointer dereference in setup_zone_pageset()
|
expand
|
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 8afab64814dc..7c8a74fd02d6 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -5703,8 +5703,14 @@ void __meminit setup_zone_pageset(struct zone *zone) /* Size may be 0 on !SMP && !NUMA */ if (sizeof(struct per_cpu_zonestat) > 0) zone->per_cpu_zonestats = alloc_percpu(struct per_cpu_zonestat); + if (!zone->per_cpu_zonestats) + return; zone->per_cpu_pageset = alloc_percpu(struct per_cpu_pages); + if (!zone->per_cpu_pageset) { + free_percpu(zone->per_cpu_zonestats); + return; + } for_each_possible_cpu(cpu) { struct per_cpu_pages *pcp; struct per_cpu_zonestat *pzstats;
The function call alloc_percpu() returns a pointer to the memory address, but it hasn't been checked. Our static analysis tool indicates that null pointer dereference may exist in pointer zone->per_cpu_pageset. It is always safe to judge the null pointer before use. Signed-off-by: Qiu-ji Chen <chenqiuji666@gmail.com> Cc: stable@vger.kernel.org Fixes: 9420f89db2dd ("mm: move most of core MM initialization to mm/mm_init.c") --- V2: Fixed the incorrect code logic. Thanks David Hildenbrand for helpful suggestion. --- mm/page_alloc.c | 6 ++++++ 1 file changed, 6 insertions(+)