From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mta1.migadu.com (out-13.mta1.migadu.com [95.215.58.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 34F2642885E for ; Sat, 15 Aug 2026 17:45:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.13 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786815909; cv=none; b=K8m3hUG9JS32jfBxdOFxiOsyHbKx0WiZEEdY4ZKHbSQ/dcZ1NKejeOx+ET5tfTJ3a8d4KY8SD7AGSedXKOI31WBZOnY+XG78ODXt4UjYeDWqdHPUrCHPV2mnA03xeE4Y7lYfzxYHjohEbCo89WPB3A0WYrg0f7WB7Ss8Y5perLA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786815909; c=relaxed/simple; bh=avPeZm5/T510jKkZ9/tRUIvDLKwmbUPM18DoG4CWRaM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=M3nEdGyzX5TYh45tTOxMRryF9FIJ5UQnQ3A5pxVltHQ3/GkIdC4xfh6SrO5eEw8waXYsE7epzqC3Ylmw+T/3ctU1Y5kJeU1OLGMvgoyVSUdka8TKSJpEGJDbcmGwT+IVaze1UHdkIs6VLUAl9DvknLFqonUcczsCMBKfNIik9IM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=bXHsQ0um; arc=none smtp.client-ip=95.215.58.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="bXHsQ0um" X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=avPeZm5/T510jKkZ9/tRUIvDLKwmbUPM18DoG4CWRaM=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1786815903; v=1; x=1787420703; b=bXHsQ0umtW/GtIkRyR4lU1+4icT/D/jA9upKgAax7BVitHUn7k97hcKH8fg0gu4G9demU2oM 1243nle566EJVFNibqqjKbSxU1ry3BuLYmBenuvDWMDxtdwRsAReKoPVKanKEKBtNeCdUoTU60c IYJWcCCaaMsQaZcmHEsZxQw4= X-Envelope-To: linux-kernel@vger.kernel.org Received: from localhost (2602:fce1:44f:115e::) by smtp.migadu.com with ESMTPS id 3174625ea40415ed; Sat, 15 Aug 2026 17:44:53 +0000 X-Migadu-Flow: FLOW_OUT From: Lance Yang To: vernon2gm@gmail.com Cc: akpm@linux-foundation.org, david@kernel.org, ljs@kernel.org, nico.pache@linux.dev, ryan.roberts@arm.com, dev.jain@arm.com, baohua@kernel.org, lance.yang@linux.dev, usama.arif@linux.dev, zokeefe@google.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v2 0/3] mm: khugepaged: fix tracepoint UAF Date: Sun, 16 Aug 2026 01:44:44 +0800 Message-Id: <20260815174444.4164-1-lance.yang@linux.dev> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20260815051924.194810-1-vernon2gm@gmail.com> References: <20260815051924.194810-1-vernon2gm@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On Sat, Aug 15, 2026 at 01:19:21PM +0800, Vernon Yang wrote: >From: Vernon Yang > >The khugepaged tracepoints take a folio pointer and call folio_pfn(), >but by then the folio may no longer be valid: freed after folio_put(), >folio_unlock() or pte_unmap_unlock(), or not a folio at all but an >xarray-encoded swap entry. On classic SPARSEMEM, dereferencing it oopses >khugepaged as soon as the trace event is enabled; on other memory models >it merely prints a bogus pfn. > >Pass the pfn to the tracepoints directly, captured while the folio is >still pinned, closing the use-after-free windows in >mm_khugepaged_scan_file(), mm_khugepaged_scan_pmd() and >mm_khugepaged_collapse_file(). Well spotted! Gave the series a run on x86_64 (KVM), all good (only classic SPARSEMEM untested) :) Tested-by: Lance Yang