Message ID | 20241107113447.402194-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 D1ABBE7716C for <linux-mm@archiver.kernel.org>; Thu, 5 Dec 2024 15:24:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8BCAC6B012B; Thu, 5 Dec 2024 10:19:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EC0656B00B7; Thu, 5 Dec 2024 10:19:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D102F6B00C5; Thu, 5 Dec 2024 10:19:12 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 2BD456B0099 for <linux-mm@kvack.org>; Thu, 7 Nov 2024 06:35:00 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id D68BB405FC for <linux-mm@kvack.org>; Thu, 7 Nov 2024 11:34:59 +0000 (UTC) X-FDA: 82759091310.12.ED1F8D0 Received: from mail-pl1-f195.google.com (mail-pl1-f195.google.com [209.85.214.195]) by imf24.hostedemail.com (Postfix) with ESMTP id 58D62180006 for <linux-mm@kvack.org>; Thu, 7 Nov 2024 11:34:53 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=F5sIzMBF; spf=pass (imf24.hostedemail.com: domain of chenqiuji666@gmail.com designates 209.85.214.195 as permitted sender) smtp.mailfrom=chenqiuji666@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1730979130; 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=uTYKUcTQxzsh1mvxH/LAhn9PQQYcWg2Ig+zmw8mJl8A=; b=USwFWII0lS1r7zPQ7MxjSVhMcQA0tm3s1fx26ljVWmIwysXhSg9MOyPy8/wsM2TL+MFNo3 4V1Hpi5XVqqY/xMYu0VItaiSzRa5F6GYQOebSIw/VvrINoNBiK53zsjaWFf+jdDxHAsRD/ iAbl8MbRZWiCwDfVV1AUuvrZ10GOYbI= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=F5sIzMBF; spf=pass (imf24.hostedemail.com: domain of chenqiuji666@gmail.com designates 209.85.214.195 as permitted sender) smtp.mailfrom=chenqiuji666@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1730979130; a=rsa-sha256; cv=none; b=y6VN2cqgu8+SbCPDiLIfyR7qGOb8mjz6NWm2X7qJ2MJKdhsQj/TJxmPcrWk8sPmfpmKO4m rrAbT4EFSmpVTEofKANSS4UI2O0ziLDS6gsXI1gkPT9mWrzwK4qXfOrC9gEog2W023ehqx thpxlaAjgps5DgwRHG6FShOrTCSNbnQ= Received: by mail-pl1-f195.google.com with SMTP id d9443c01a7336-2113da91b53so6286715ad.3 for <linux-mm@kvack.org>; Thu, 07 Nov 2024 03:34:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730979297; x=1731584097; 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=uTYKUcTQxzsh1mvxH/LAhn9PQQYcWg2Ig+zmw8mJl8A=; b=F5sIzMBF/O43CwG5zf0PaR8r9DtMtOnb0vJuI3UhynC6qnFDAyhGaEyPieq4zKoAet hb5AXO/7LJXP85fzgzewh1hhTSMNHEoie7OfgRb5wxIiBS7H1BzKvUAOpXgJNh9lu6/i LBqcG5CfEC0/5Vpy7WTvDk0LB5EfD3LP17x1ljz6J7YnUsYr2RfOOc/qhQjukQn5/zLu YO4HnXXb00iHZotU3xy/7+4PG6NYz/jYmV5IKv7yY0hUlgTcHQA+pR6OEduIIDA+I1Tn kALt0AdGeYrPd431hoTXQtVIPFE16UWz4IUHGLrC6agD8beM3d3RyotVbKNqzHaVw2wr BXtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730979297; x=1731584097; 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=uTYKUcTQxzsh1mvxH/LAhn9PQQYcWg2Ig+zmw8mJl8A=; b=LiGYrE8p1n6/NSxRx+NSkIOhaxfvqjimox0CdYqIQcgpSr702ZL8nOIS/yHA3g5hxp 5qpnbeKcUGnGeG1DgRzlfs5ZGpx1tsOxC5f42xuYClnleYMkX2O2Q8Ac7pjBVwhf7V63 feKMPwJoaAtfsMGwDyq7yY0R4e4bvr3nz1Jt6vDChSGcTXK9VzYGvHNwWMDWawrui09k HA8ICIdlmWWX1L3B2+DOzbzAtT7+5z8xoTVXP4bqII/pxPVCUxL/xt/E3UbMWt7XTz8E +rC1mQt4Slv5/2+PnOPV1nQWiMzDJO/hZDkDDUJtSqc6tO4iQyXV5qI0GxZfiPypgoha N0hg== X-Gm-Message-State: AOJu0Yy7wq4NWVPg1RkopBamE3AvtXxlMg6cDiWslDVv4Mhuxcqidc8Q 84ws0isYtlH4UH5tricLPdEkNopsFUSXiGq6tSwKi3ecliQtO8jf X-Google-Smtp-Source: AGHT+IGvgdSx6cMQf4xfAmvWvUZOtcDEpa4o5ogRI63GYMC3f7X6zRi2BnG+oJpEXC/zMSNMxc63JQ== X-Received: by 2002:a17:902:e886:b0:20c:d578:d72d with SMTP id d9443c01a7336-210c687963bmr575517765ad.7.1730979296673; Thu, 07 Nov 2024 03:34:56 -0800 (PST) Received: from tom-QiTianM540-A739.. ([106.39.42.118]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21177e59486sm9808255ad.204.2024.11.07.03.34.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Nov 2024 03:34:56 -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] mm: fix a possible null pointer dereference in setup_zone_pageset() Date: Thu, 7 Nov 2024 19:34:47 +0800 Message-Id: <20241107113447.402194-1-chenqiuji666@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 58D62180006 X-Stat-Signature: h7ktbw8f67cny55peb3aob8ewhrk1c87 X-Rspam-User: X-HE-Tag: 1730979293-806078 X-HE-Meta: U2FsdGVkX18HPpnEX4WlIVCuhjJknfTx9vHOKlviXHekzJ38qklD8c8RfyHGqxIL1mAiegByP5HsF51zfVNza7Ac2OxX2me3AHtoxMYToTdwcbzy7JJaGg6oeskcC5ONTrYsSBdETPneJSlnKchKRJEKmM5Oj7JqLxwk+C/v4ATGEABN7f4VUy8GY8csFtocV5yB1dPM6WR26xMyKy+/6c5J3auocBQzhC+pMbMWPE/2g6ymvFuKEwX4mk4TWTq5MaVqaFMj3RtCpysdplTE75TEx+uOlKXIWAWFviyBtHUAnkSSZnIQtl1HdCfS31V1XXSkl50V0640o4iBYUEbmsHHjpq8nizwckLvxVi8qG7SNs+TM020DhD18SiM4BP36VVf4WiR3obf7bwcEqE+gaT/XBulIrNSpdOfsSYQrQr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Dh+tJFXlBnPl7v1ipFImZ96Dc5LypF/YNIUN/a5nRHbCS1L9DqVCPy+gmsFccidrk7nFQZYo0HT061mqwz0= 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 |
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..5deae1193dc3 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_pageset) + return; zone->per_cpu_pageset = alloc_percpu(struct per_cpu_pages); + if (!zone->per_cpu_pageset) { + free_percpu(zone->per_cpu_pageset); + 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") --- mm/page_alloc.c | 6 ++++++ 1 file changed, 6 insertions(+)