From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793109365; b=vwUy8ghiD/DEkXnltejvUw1YjNUYplQPP8DoyH54/5rKOPVgrADK7uD/k1uPfwOF21qF 0v6f+rMwJCihSJmqWt1EOjz2yb4dpazwBJh11La6SjNnMiuSOmpqQLkk8dXkHHG2d6QLv 8THb6r9nMjr7LwCOgUxiLJPdpJJIXNbYPFh2/dWhQ+UHdsRUCSvx630AJMuNzX/Ovw2XC eoyIizJY/BxRWUHmjwtrlEGVuHBUtSbbxHJNbPRNPoEhsEe81EpSnQdsjpkNwNItavQKy egkBNcmnuhu4uZmKttfCcnN4w87kcD1OoxiSYR+9M3h+WGvut3L/YyQ3fyr3XmTLoDg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793109365; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=Zr1jTThDFAddOSK457sc66293xmVyHCCi9iGlWUeddU=; b=sTn0sPUqmFAiDPy8q4VCKVadAtQ4U7hzk36VR7xSnNVqJ+5EPk14VKvEKtsRzrEUA+0q op1OPE+AGKMxtlBC/t4J1a+XK2L5dUfiljQ7Jrn/JwY+Xovh+XFuSuljgXMZFnFYayagG A9rhU2zthJO0D6dqxXS6hhvcbJ4pM9k0x7/kjWUs2rPnLGDAIgR+OOfM9cMflS8n2ezrj Eyj42HhNQd+p3ajGytJbWWYI4BB6vLdNanhG42lp5b3RVBxomK/winobZI0QsE4SpHJdy o46wu3sWbHm3PYM5psYlDRKlJUdHpUaj8aO0J55ixiAi8exC7bvqD1EDugpkRJw2UIQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=jIhYLNBN; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A9E5C606A320; Tue, 27 Oct 2026 13:56:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=jIhYLNBN Received: by smtp.kernel.org (Postfix) with ESMTPSA id B17E81F01825; Tue, 27 Oct 2026 13:56:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1793109364; bh=Zr1jTThDFAddOSK457sc66293xmVyHCCi9iGlWUeddU=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=jIhYLNBNpp0NexZNmMUHOUCY+eEy16NfWjuSuwLJqmFHwNWPY9BdmcaHZW+1fGIg9 fiBkl7KehfwTpd4R+QE8pIbz2ex/lWNl//inoU+svKsu/oI0sqh9JGs4nayk/63cZa PuQtRNz2s2eqW5o62hUTfQo+difIHb2bfTQI3wmFE48eH1hqvasX2J061wIVJ/8XLp B8iwzzJIHvVnrgkO1CLMhM/dtnxK1pMp932wcPpTyDMf/mtjlI6T7bM2e0ImgLpb5G itjSlM0i78ybkEbvAJ0jTU2GNXWaOjkHSgMcq3b5iw8EB94IUavJ0yBcssBsMi8xzh 0HHSAVhaSG0Nw== Date: Tue, 27 Oct 2026 13:56:02 +0000 From: Harry Yoo To: "David Hildenbrand (Arm)" Cc: Andrew Morton , Johannes Weiner , Michal Hocko , Qi Zheng , Shakeel Butt , Lorenzo Stoakes , Kairui Song , Barry Song , Axel Rasmussen , Yuanchu Xie , Wei Xu , Baoquan He , Baolin Wang , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Kees Cook , Peter Zijlstra , Jann Horn , Pedro Falcato , Hugh Dickins , Pasha Tatashin , Pratyush Yadav , "Matthew Wilcox (Oracle)" , Jan Kara , Zi Yan , Lance Yang , Rik van Riel , Alistair Popple , Nico Pache , Ryan Roberts , Dev Jain , Usama Arif , Kiryl Shutsemau , Matthew Brost , John Hubbard , Peter Xu , Will Deacon , "Aneesh Kumar K.V" , Nick Piggin , Oscar Salvador , Minchan Kim , Muchun Song , Xu Xin , Chengming Zhou , Chris Li , Kemeng Shi , Nhat Pham , Youngjun Park , Gregory Price , Joshua Hahn , Rakie Kim , Ying Huang , Jason Gunthorpe , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kexec@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-arch@vger.kernel.org, linux-cxl@vger.kernel.org, stable@vger.kernel.org, Josef Bacik Subject: Re: [PATCH 02/46] fork: take mmap_lock before copying mm_struct Message-ID: References: <20261027-fixes_core-v1-0-6f74bec9a5bb@kernel.org> <20261027-fixes_core-v1-2-6f74bec9a5bb@kernel.org> X-Mailing-List: linux-arch@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=us-ascii Content-Disposition: inline In-Reply-To: <20261027-fixes_core-v1-2-6f74bec9a5bb@kernel.org> On Tue, Oct 27, 2026 at 12:17:22AM +0100, David Hildenbrand (Arm) wrote: > dup_mm() copies the parent's mm_struct before dup_mmap() takes the > mmap_lock. A concurrent brk() can leave the child with a stale mm->brk > and newer heap mappings, causing later brk() requests to fail. > > Other operations (e.g., PR_SET_MM) on the parent's mm_struct can similarly > cause inconsistencies. > > As a simple and robust fix, grab the parent's mmap_lock earlier. This > way we don't need to update individual mm fields in dup_mmap() and > keep missing ones. Stop updating the 4 existing members (total_vm, data_vm, > exec_vm, stack_vm), as that is now no longer required. > > Keep releasing the parent's mmap_lock in dup_mmap(), before > userfaultfd completion, to avoid moving the userfaultfd handling into the > caller. This should get cleaned up later. > > Move uprobe_start_dup_mmap() to preserve the lock ordering. > > Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") > Cc: stable@vger.kernel.org > Reported-by: Josef Bacik > Reviewed-by: Lorenzo Stoakes (ARM) > Signed-off-by: David Hildenbrand (Arm) > --- Looks good to me, Reviewed-by: Harry Yoo (Meta) -- Cheers, Harry / Hyeonggon