From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 8FF0F383990 for ; Thu, 25 Jun 2026 02:04:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782353064; cv=none; b=dWWRfTckZbtpkVjvAIpOnRhC5ik+NwZ3BhAei9gWhU9rsdEpSEMrPmnQ9ahdIgNYtf/0UuNTxLC+niVpa3PrBdMss5Jqlk8Fw9hqhaGu3+Ml/oRs0yQqJFBqECHJxse94XdRhgqa0hASA0gyknjGOzJ96sm7PCgnhXGlqolSvKk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782353064; c=relaxed/simple; bh=7H0xp+4ex8CBXcBwtu2poZM/XHBF0WTgS/NeTxdLNWc=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=gcLMWsPeo0EDUz50u7PBKwzicgQuoYePyqvDXBNFqPwlt67vX8nE04J7wzU4nPohdVwhkCTihkV99YOEHF25WO1FkZEZYv+EFtnj45bPTQp36SZsnGJledpk3PI5ekOuCpxQe/rJN6zMpAGzxNugwyAEj6q6nuhGv7FIJ4v7Ib0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=RG3jzbS5; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="RG3jzbS5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 088A01F000E9; Thu, 25 Jun 2026 02:04:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1782353063; bh=Gx4FZ9NCfUy9OrlH5MNdO/AlD9Nd83bqNCipHSXXq3c=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=RG3jzbS5CdNSF7eEF1EJGXAN6ff7HYohVtFudGji+fb6dXeJgTNeXYmvVvYkskaGm XH2VrgskoJpb97nPDrJbFJ8yO+n1+NBFbZaDUKhRydBr8HAlUbSUAmFJz8h+7lcGIw sHJjJ0Vn43uk6rcuKdLZoif2nUQsjQTC2eoWRkpU= Date: Wed, 24 Jun 2026 19:04:22 -0700 From: Andrew Morton To: Ye Liu Cc: Vlastimil Babka , Suren Baghdasaryan , Michal Hocko , Brendan Jackman , Johannes Weiner , Zi Yan , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 0/2] mm/page_owner: fix TOCTOU races in lockless page state reading Message-Id: <20260624190422.4d2be6576104cedbbfa0e320@linux-foundation.org> In-Reply-To: <20260625014708.87386-1-ye.liu@linux.dev> References: <20260625014708.87386-1-ye.liu@linux.dev> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) 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 Thu, 25 Jun 2026 09:47:03 +0800 Ye Liu wrote: > Fix two TOCTOU races found during review of [1]. > > page_owner reads page state locklessly by design. In two places the > code reads the same metadata twice — once as a guard, then again as > a use — and the page can be concurrently reallocated between the two: > > Patch 1: buddy_order_unsafe() in skip_buddy_pages() can return garbage > if the page is allocated between PageBuddy() and the private read, > causing the PFN to skip past a pfn_valid() boundary. Clamp the > advance at MAX_ORDER_NR_PAGES. > > Patch 2: PageMemcgKmem() in print_page_owner_memcg() re-reads > folio->memcg_data and triggers VM_BUG_ON assertions if the page > became a tail page or slab page. Use the snapshot taken at entry. That was fast. I haven't pushed out mm-new yet, so Sashiko wasn't able to apply these. > [1] https://lore.kernel.org/all/20260623065234.31866-2-ye.liu@linux.dev/ > [2] https://sashiko.dev/#/patchset/20260623065234.31866-2-ye.liu@linux.dev Nothing cites "[2]". That's OK.