From patchwork Tue Apr 1 20:23:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sweet Tea Dorminy X-Patchwork-Id: 14035278 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 9F836C36010 for ; Tue, 1 Apr 2025 20:24:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 937D5280002; Tue, 1 Apr 2025 16:24:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8E79E280001; Tue, 1 Apr 2025 16:24:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7D57F280002; Tue, 1 Apr 2025 16:24:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 5EBD6280001 for ; Tue, 1 Apr 2025 16:24:09 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 555161408A5 for ; Tue, 1 Apr 2025 20:24:10 +0000 (UTC) X-FDA: 83286601860.29.4E32CD4 Received: from box.fidei.email (box.fidei.email [71.19.144.250]) by imf18.hostedemail.com (Postfix) with ESMTP id C40281C0008 for ; Tue, 1 Apr 2025 20:24:08 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=dorminy.me header.s=mail header.b=How5cAAn; spf=pass (imf18.hostedemail.com: domain of sweettea-kernel@dorminy.me designates 71.19.144.250 as permitted sender) smtp.mailfrom=sweettea-kernel@dorminy.me; dmarc=pass (policy=quarantine) header.from=dorminy.me ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1743539049; 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=UKFyS8Qp1ZdEjFxSA5fLAPSyFeijhLH/ihgG7Lr2X1c=; b=sSpuxJtjVf5ZVVyfcGXBBVXQwuRmYaKKoxt/AmNGATuwIosrqtpt6JKqSjbXXhgymrMqZj CCFM68JKA8F4pr6Cj1XtuIRR+Q5DHh458kSQR889jMFlUBD1KDChKZ+c4R7sZm0u3wFJ6+ vK/yIch8qhbKOXPuUERJzXfxwc9mXMs= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=dorminy.me header.s=mail header.b=How5cAAn; spf=pass (imf18.hostedemail.com: domain of sweettea-kernel@dorminy.me designates 71.19.144.250 as permitted sender) smtp.mailfrom=sweettea-kernel@dorminy.me; dmarc=pass (policy=quarantine) header.from=dorminy.me ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1743539049; a=rsa-sha256; cv=none; b=zL8O9R0/S61aQ+inPkXxxMr34OHzxSRuGusADpjBvRpm+7HaqnsETnExr/ZyQ0Q+VRIA1C V80NgiS3grG3qgWHU7BrVZYlfMXzPzcZmaSodB5miDIWlzIVTUnYbtHheu8v4F1qQpF+vv TWb7HEboyFwfO49gbIZmatTeS0Rnh+E= Received: from authenticated-user (box.fidei.email [71.19.144.250]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by box.fidei.email (Postfix) with ESMTPSA id 8C934834C2; Tue, 1 Apr 2025 16:24:07 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=dorminy.me; s=mail; t=1743539047; bh=BsSRILVhhDPgo5niRJu4FUZyXl80DfST1ovx9ux28P0=; h=From:To:Cc:Subject:Date:From; b=How5cAAnmTGDB2VhAPr5uld/jBvKb7nNQt0Hu6bWdGkhFsPMapW90wbP63PHUq19k AmWE3FcMS9Ip+FGP3WtkM/H9E9KvvO9IXv1+ODuspXqqym4ImRD2Bui3P+z4nweuPq oxwT8vV/mbEvzTbBFE1PYBRCOIAvyd10yNPLN9e2ts0jQdSy274gp4GMurHcXK74oy g9oLPPDCHWEWfLDYVMWzgSDJ7y5dPf7KXU/msmFNmeQ9Ip2mFAp8SiQug3PHdBx11p o1KmFjNvtn++viBV7+Nym+c/lkjffhnJfii3TI1HJn5a4xqR+AYsuwqwfyD4NKqPyr B4FOKIasmc0Mg== From: Sweet Tea Dorminy To: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Sweet Tea Dorminy Subject: [PATCH] mm/khugepaged: fix a tracepoint for error cases Date: Tue, 1 Apr 2025 16:23:53 -0400 Message-ID: <20250401202354.103501-2-sweettea-kernel@dorminy.me> MIME-Version: 1.0 X-Rspamd-Queue-Id: C40281C0008 X-Rspamd-Server: rspam05 X-Rspam-User: X-Stat-Signature: whdmwxjhohxfdsgrga5nc8qgoxgjqk3f X-HE-Tag: 1743539048-728328 X-HE-Meta: U2FsdGVkX19VMfopmHBjGo766hV77k6pxhwzKjtrNc3aLjQedayQnzDtPsF3PHXZqx9Yh5eAZNZqLd25/WKnN0fZVWEG7vvycCA8u+Y0K4t39biwXiFa5g83QH7H5V1FyiyrbW749zblSIMMF+l+CouhPcX8cPRVTyjHHuUbVW9o0taNmwLRm4UWDw1lLbQvLeTBtaJXiyo2IzjXTyTJNodVCGVEKQZWN326g/Ukr0lYvpCA80qYSfXwTulyRC6YnYgDaw89hrJv/q9yLVaSIf/yhzyCU3JRWEaH20cPuX/Gaa2eKHkojg/Voi9BGC/eFae1U9c36LxUOsr2VHOFnO66xgESZm2eFEnm0vFvT5W2K/d4JmeFoaoEMY9ODWzZwoV3nqWp+pL4BAHD/c8DDjzp5HVN7tl/csbjgfkxaWFDciDFpiDAuxCi27/JlHb1PINUPM7L0+5eBMJ5u5JzhsKjcdmH0lz3G8Fu81p0w+oNaRvRoSchzLa9BoOTM8DrX1nV+OtEM6comKhtn+ppNhRyBQoi/Kja+b65t0AZOfrseKhsb4J7CfsDCuuJUXYQeCr4/wPsIxlPFmGTMsZh9kAP48w4QO5WNpjRGg3fIf8KtMrjEfaIDCZknUxS7bVBU7eXa8dlON5B+Uo8w8uAUCLoDdZ7bLdLHOWtXWS3MrR/EywCc5bWpulHDw9wuOhvHG4A7DIdY992oxI4nM8TRPT7SnCaSkaSveynLAzwD676LjdY8Z2NaWK2XvRGGDX+wJPfGIGk7x2LuRR0OL4iunL5BX6UrvbBvUs9sOyKHM25BEGreSMI58YNqjxPVL4Kqx2B0TLs0Id7RzaKJR1w31XITpcfqSmqR7Bij2dvpifnk8/xRDrLH/vcy6Yz73zVaTqMKZ+gN/Szx2gXqRvzJ2ALFLgnhxDHulo0mKw353Z+3dGnBxeN/LTuX+XqTVVts/3/zHsUeTJDMx+sBbU PQis9CuK DL0FnKPVpFTvHOtiupO+H84WD+hpaBKs6fqYlm979gGZsm60CAR4B2odHFskX6rCylPnhjEdsqsGH/EtPn9p44MQjO4nI91wJv/j65XoqfztKY7B9+8WjYSnzog21cjv3LKpzLqDzVQgUAxz2tBNyHrKEkORgJyhee5L3FmG+ocy4RNLrFq3Qwlt1G4XVcIkYyh6Ct5jOSgjXPy6m4fSqzfU/02RoTeYqAHoc2NHJ1LiniD1o3mXAFTp9Ps+VtX++uZNEYSALiQFtVhger1876aRc3RrQR013vvITwn6XAhPGPzs= X-Bogosity: Ham, tests=bogofilter, spamicity=0.078941, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Fix a potential NULL pointer dereference in trace_mm_khugepaged_scan_pmd() when folio is NULL. This is possible if vm_normal_page() returned a NULL page -- which is unlikely, but was hit in testing. (The tracepoint in include/trace/events/huge_memory.h can already deal with a NULL page.) Signed-off-by: Sweet Tea Dorminy --- Based on akpm/mm-unstable. mm/khugepaged.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) base-commit: e026356e4192ff5a52c1d535e6b9e3fa50def2c4 diff --git a/mm/khugepaged.c b/mm/khugepaged.c index cc945c6ab3bd..eb7b019159d4 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -1435,8 +1435,9 @@ static int hpage_collapse_scan_pmd(struct mm_struct *mm, *mmap_locked = false; } out: - trace_mm_khugepaged_scan_pmd(mm, &folio->page, writable, referenced, - none_or_zero, result, unmapped); + trace_mm_khugepaged_scan_pmd(mm, folio ? &folio->page : NULL, + writable, referenced, none_or_zero, + result, unmapped); return result; }