From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B3542C433EF for ; Sat, 26 Feb 2022 01:05:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240968AbiBZBFl (ORCPT ); Fri, 25 Feb 2022 20:05:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238284AbiBZBFi (ORCPT ); Fri, 25 Feb 2022 20:05:38 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D97021130B for ; Fri, 25 Feb 2022 17:05:02 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 8EA33B833C4 for ; Sat, 26 Feb 2022 01:05:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 47542C340E7; Sat, 26 Feb 2022 01:04:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1645837500; bh=+WGZU2B7OK2kDrKLALrUq7SGwFhKbhHKtTHepbvKTlE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=TuzfmWa8Oigv0ZAHb4qZLlcHWrm70ej1XaddNLTxOlZmIEUzY5fr1oXIAXqTKDHtb 3/0Mn+w3oeUte5Vsn2G1mDKPkCYB5MkKbop296XqH47GJQmmcXcYd0aB9cRVWMRmWh vLSaT0txEkudXbUni9cZ52IFkAMkIEQCD07qfzI0= Date: Fri, 25 Feb 2022 17:04:58 -0800 From: Andrew Morton To: Michal Hocko Cc: Suren Baghdasaryan , shy828301@gmail.com, rientjes@google.com, willy@infradead.org, hannes@cmpxchg.org, guro@fb.com, riel@surriel.com, minchan@kernel.org, kirill@shutemov.name, aarcange@redhat.com, brauner@kernel.org, christian@brauner.io, hch@infradead.org, oleg@redhat.com, david@redhat.com, jannh@google.com, shakeelb@google.com, luto@kernel.org, christian.brauner@ubuntu.com, fweimer@redhat.com, jengelh@inai.de, timmurray@google.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@android.com, syzbot+2ccf63a4bd07cf39cab0@syzkaller.appspotmail.com, Liam Howlett Subject: Re: [PATCH 1/1] mm: fix use-after-free bug when mm->mmap is reused after being freed Message-Id: <20220225170458.2fc661d3088def39b2ed3e41@linux-foundation.org> In-Reply-To: References: <20220215201922.1908156-1-surenb@google.com> <20220224201859.a38299b6c9d52cb51e6738ea@linux-foundation.org> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 25 Feb 2022 11:17:34 +0100 Michal Hocko wrote: > On Thu 24-02-22 20:18:59, Andrew Morton wrote: > > On Tue, 15 Feb 2022 12:19:22 -0800 Suren Baghdasaryan wrote: > > > > > After exit_mmap frees all vmas in the mm, mm->mmap needs to be reset, > > > otherwise it points to a vma that was freed and when reused leads to > > > a use-after-free bug. > > > > > > ... > > > > > > --- a/mm/mmap.c > > > +++ b/mm/mmap.c > > > @@ -3186,6 +3186,7 @@ void exit_mmap(struct mm_struct *mm) > > > vma = remove_vma(vma); > > > cond_resched(); > > > } > > > + mm->mmap = NULL; > > > mmap_write_unlock(mm); > > > vm_unacct_memory(nr_accounted); > > > } > > > > After the Maple tree patches, mm_struct.mmap doesn't exist. So I'll > > revert this fix as part of merging the maple-tree parts of linux-next. > > I'll be sending this fix to Linus this week. > > But this is a regression introduced in this release cycle so the patch > should be merged before Maple tree patches, no? Yes, I'll be sending this one-liner upstream very soon and we'll then undo it in the maple-tree patchset.