From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.160.175 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796247967; b=tEtpnSCGHmSlekGW7a3TRMRrZsQEiLL1Ga3J1gUg2oohOXO4shnsFnrqrqvpumP8UJsd gEkZAYZ13cxewzsDha3bmCjsD7oHhXM5jlngibrhMsSVhz56GRmfezsKUpGngXN8p03MY 7Xh/+JGMiTni/IiuYzwfKWg8xtkVVRjZNY+ZSBTG64J9K9dS3OWybHACj6n+iN4En0u6R /fuKoqtF+6b7IUhZTXIyFC7A9Ls+u6eNd5jxxgRBDu0VB8AQoQKopbe7Rf8P1J4OJLB8o YNsTTi2fPalZux5Y25O/pfUTte8/QwngYGNtPdpt7dFfwSyTSQF7gBPhRe5sOXz5aqg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796247967; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: MIME-Version:Content-Type:Content-Transfer-Encoding:Subject:From:To: Cc:In-Reply-To:References:Date:Message-Id:X-Mailer; bh=A/Lces7IEqJ7arehs5Fc5P0KWk+upxz+uNZBPSu4qZY=; b=PfipQI1z107YYNqaN7ZlZMI2LOUwrQKX2BSjvDNaWi5W4fOHimIAK9tUk4HZgOccHZ6p zQRZC737wU6+NoN56JYzQkGWCgf6g/uRGZ1LNd6wCETz8kmX+PLkd7Vha2LYBPwR4F4rZ chBt+Jogbz/oGQo7v1iYOQIvCKnkXQib1wbnF+ItGiaqMfFYDGrOm6kmksfMi5G5KV+0I xuFXzo62WYt9daPMX4d1zMKX8NtWFRBuct+mWlMt77fAiJ3IDyQlmwR5QMZcjXCXjmvgd jiKMxnxUrCAH29TmOcy2GxALxEFxqNF1xX8RFvSkKHuOcjY5DFW6B9SZsmIC3rMnUfA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=gourry.net; spf=pass smtp.mailfrom=gourry.net; dkim=pass header.d=gourry.net header.i=@gourry.net header.a=rsa-sha256 header.s=google header.b=GaZvl8PP; arc=none smtp.remote-ip=209.85.160.175 Received: from mail-qt1-f175.google.com (mail-qt1-f175.google.com [209.85.160.175]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 64D67606A322 for ; Wed, 2 Dec 2026 21:46:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 64D67606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gourry.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gourry.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gourry.net header.i=@gourry.net header.a=rsa-sha256 header.s=google header.b=GaZvl8PP Received: by mail-qt1-f175.google.com with SMTP id d75a77b69052e-5365d725440so117147501cf.0 for ; Wed, 02 Dec 2026 13:46:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gourry.net; s=google; t=1796247966; x=1796852766; darn=vger.kernel.org; h=message-id:date:references:in-reply-to:cc:to:from:subject :content-transfer-encoding:content-type:mime-version:from:to:cc :subject:date:message-id:reply-to:content-type; bh=A/Lces7IEqJ7arehs5Fc5P0KWk+upxz+uNZBPSu4qZY=; b=GaZvl8PPxF7G2f1WSONKQKv6YmJjq6rBvvGtE583XSxVyO6NeU3uWXXNbhFIZVOBGl u+EnlIzJVYQ/Tm4mZ0ogbbWx4MppBIou+yGUp+Q6sbttJKyum+kU39FzukLcv44OPoOu LSIhZzJIJLr0RqciXHBTmVOP1DFLXouVUntgwDt1PVOos1wFsMQl0+t5gk0zcPXgCAWm CPmR9jZ2Mo7Aql4uPrzjxgv6arKvsTdmA1FxVOwmF5iM/XC5rdRN18CDqzwcddGHnq6F sZiPz+rgBzVPmzm9UBfDxHFQNUwrrUVH2bilpvsyCKYsMk5Q9QuJesRiGJSvXd5FHrqO pQbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796247966; x=1796852766; h=message-id:date:references:in-reply-to:cc:to:from:subject :content-transfer-encoding:content-type:mime-version:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=A/Lces7IEqJ7arehs5Fc5P0KWk+upxz+uNZBPSu4qZY=; b=HwVh1EjgSexl4Nr6kPCs6Vz9aToSjMIJY18ysqsnmI4sg9NC8MsxoAsi1/DDNdDJG2 mUtF9737xSMbbxUh5T09DYiumV3fvrcElB1MoQouVH9MooDC7UgTEqM0S/qquEE+aTmI ebUFOUKdgKYOWnQr9jjY8jwr1pGOLzuGoFG11hZH2vpjUTkd0juJ5P0VwkMRRvLnceWO 51OtlY8UFHBZAUd+FozyIw3pmfXUKtVnQv3zUNvU9jvHZsA0NRe5+MUyJFSbabTB1vyA khXZHn6AtCD0Qyd2jHwNEPd7QLQZe/SBlwiTHSAXnw3XgRBsYGlzlsoruW1HumuKWqDm +zQQ== X-Forwarded-Encrypted: i=1; AL+hErFEbFNEPB+faufIk/uMhwBx/90Mt1AbtAWXwLM9By+jcS+N+tuBzfr3jwewDi0vxQYNI2+CiuaCfCM0EDk=@vger.kernel.org X-Gm-Message-State: APuU4Z8voWn4fCgGp1mdcZZoTDjJUFdjS5L3kifOF7pwiEKXnjlLpZwA fW00eXg6c6Nba81HVx608vKTAhd1sG+T7pyj27PxLJ/hHudkZTmYenKG5QR+D9tksE8= X-Gm-Gg: AZFdTZcq9/d/KfK8Kz6lz04+IG9DQAjreE/FukoqGDCpGH2IpKHzNyVQIFoPyQk/pMR CLHlATWguwqE+DmT7OOlDTNWf9e/8i8Wy2h6vg/N4r89F5KX7H1arWBuuS3wRX3QbjBRyrWc3k8 kCsUnZ29GlIdWR3Hm93wjo8DBRNxTpzIqrekuv2j4fkUFUPMTInUZT8eLnWaIk7s6i2M6YL8hEw ZIooWbkzoMjO8rg/n3lCEzwDt4v3v4O9zra7X78eTEqSAHOe1q0V1JpEYde87Zg5icabDmwHk5Q Hs5ikdmk01sUB0rQughn0Uvogq0pTxai9+Tc6LwpQrCQzZKUbXvag3MrLeOoZ3zZUa5j1BIJKpg rcaPKMy6OFH+d2xmm8XfY54Fn0AfQFzZRecy+H61eUldiLKTuH4OTpHxvcQPRMGe/ihZEnhucor jEY4hCpGHaXPna9olpr+gdKhDxnBtBOqE48qhF/UETwg7wPqgR7HpMvlW3AIYr9zSpvORxJiV0e X2uFRoP+7eMskHT6M3PzQ+jB9SvfYeQsDBsfs/+Q9qq7yBmwnugJ0T9huYUMRsFTASmD/Ca4VjK 8IWKUonx2YNt/OeNe8YMITnvNMMN6g5fo1MzCOGmfCL93xgnEFVeBWRTwiS+oH/0TPsFRB5o26g n+8Jh8QCBqxtLMiETfvjYsILGw+RY X-Received: by 2002:a05:622a:413:b0:55d:3721:873c with SMTP id d75a77b69052e-55d76a65140mr770899481cf.34.1796247966133; Wed, 02 Dec 2026 13:46:06 -0800 (PST) Received: from [192.168.50.231] (pool-71-191-145-202.washdc.fios.verizon.net. [71.191.145.202]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-55dbcddc13csm203336191cf.19.2026.12.02.13.46.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2026 13:46:05 -0800 (PST) X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: Re: [PATCH 18/32] mm: consistently check MMF_UNSTABLE when populating in CoW mappings From: "Gregory Price (Meta)" To: "David Hildenbrand (Arm)" Cc: Hugh Dickins , Baolin Wang , Andrew Morton , Mike Rapoport , Peter Xu , Michal Hocko , Kiryl Shutsemau , Manfred Spraul , Davidlohr Bueso , Cyrill Gorcunov , Zi Yan , "Liam R. Howlett" , Nico Pache , Ryan Roberts , Dev Jain , Barry Song , Lance Yang , Usama Arif , Lorenzo Stoakes , Rik van Riel , Vlastimil Babka , Harry Yoo , Jann Horn , Yang Shi , Zach O'Keefe , Song Liu , David Stevens , Kefeng Wang , Alex Williamson , Suren Baghdasaryan , Dave Jiang , Matthew Wilcox , Miaohe Lin , David Rientjes , Shakeel Butt , Jan Kara , Mel Gorman , Jason Gunthorpe , John Hubbard , Gerd Hoffmann , Vivek Kasireddy , Dave Airlie , Matthew Brost , Joshua Hahn , Byungchul Park , Gregory Price , Ying Huang , Alistair Popple , Hagen Paul Pfeifer , James Bottomley , Felix Kuehling , Alex Sierra , Balbir Singh , Kairui Song , Qi Zheng , Axel Rasmussen , Yuanchu Xie , Wei Xu , Baoquan He , Oscar Salvador , Muchun Song , Dan Williams , Rakie Kim , Hao Li , Christoph Lameter , Roman Gushchin , Sebastian Andrzej Siewior , Clark Williams , Steven Rostedt , Alexei Starovoitov , Xu Xin , Chengming Zhou , Shivank Garg , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-cxl@vger.kernel.org, linux-rt-devel@lists.linux.dev, SJ Park , Chris Mason In-Reply-To: <20261129-fixes_core_3-v1-18-f66094116801@kernel.org> References: <20261129-fixes_core_3-v1-0-f66094116801@kernel.org> <20261129-fixes_core_3-v1-18-f66094116801@kernel.org> Date: Wed, 02 Dec 2026 16:46:03 -0500 Message-Id: <179624796382.2841792.15919708104381848890.b4-reply@b4> X-Mailer: b4 0.17-dev On 2026-11-29 11:06 +0100, David Hildenbrand (Arm) wrote: > The OOM reaper and process_mrelease() zap private mappings of a target > MM, including CoW'ed anonymous folios. Re-populating these page table > entries is bad: it will look like a memory corruption to anybody still > accessing the MM. For example, a read fault could map a pagecache folio > where the process previously mapped a CoW'ed anon folio. > > We must consistently disallow populating page table entries in CoW > mappings if MMF_UNSTABLE is set, and we must check under the page table > lock. > > We are still missing checks when populating empty page table entries > in CoW mappings in: > - filemap_map_pages() (fault-around) > - do_set_pmd() (fault-around, MADV_COLLAPSE) > - the vmf_insert_*() helpers (fs DAX, drivers) > - UFFDIO_COPY, UFFDIO_ZEROPAGE, UFFDIO_CONTINUE and UFFDIO_MOVE > > Let's fix it by adding these checks. To avoid duplicating code, add > vma_may_populate_pgtable() and document it properly. Also extend the > documentation of check_stable_address_space(). > > Also fix the check in finish_fault(), which must really happen under the > page table lock to handle races with the OOM reaping correctly. > > After reaping, populating page table entries in CoW mappings now > consistently fails (e.g., with SIGBUS or -EFAULT). > > At some point we should probably consistently just use > vma_may_populate_pgtable() when populating; also, we can think about > checking for the existence of an anon_vma instead of checking for CoW > mappings. We should also make __oom_reap_task_mm() check for > vma_is_cow_mapping() instead. > > This has low urgency, as the target MM is about to go away anyway. No > need to CC stable. > > Fixes: aac453635549 ("mm, oom: introduce oom reaper") > Reported-by: Chris Mason > Signed-off-by: David Hildenbrand (Arm) used uffd + a child locked in inode-lock wait and reproduced this pretty trivially. the new hooks everywhere seem regretable, but I don't see an obvious choice that deals with it - and we're effectively spewing random data with this bug so bleh... Tested-by: Gregory Price (Meta) Reviewed-by: Gregory Price (Meta) -- ~Gregory