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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D071ECAAA1 for ; Fri, 9 Sep 2022 19:35:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1A9B68D0002; Fri, 9 Sep 2022 15:35:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 15A9C8D0001; Fri, 9 Sep 2022 15:35:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F3BA58D0002; Fri, 9 Sep 2022 15:35:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id E44F08D0001 for ; Fri, 9 Sep 2022 15:35:42 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 9D08114055C for ; Fri, 9 Sep 2022 19:35:42 +0000 (UTC) X-FDA: 79893551724.18.29757CE Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) by imf18.hostedemail.com (Postfix) with ESMTP id 486441C0082 for ; Fri, 9 Sep 2022 19:35:41 +0000 (UTC) Received: by mail-pg1-f173.google.com with SMTP id 78so2470005pgb.13 for ; Fri, 09 Sep 2022 12:35:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date; bh=JskDu5aXXZfrkv/DvMfGjLDKC9YA6Ryz7zHQooGqrH0=; b=YeS6Ueze4ZWEDis47WL4EvWqttTWMAGPnZtyZgts1t5AVEp0n+4ptZuW2m5Tbq21Ys Wp9m/5EisloY7cdVobw8xTvcQpr58InINbHS18kfcCiS4r8ZzVOhilVMiJuuAa1ZkZAu /2o7Bm8hAIK9QavIPMh5ejAcLIemja/Mwirvl/2XghTSt9eOZwZDHV6O7EZ+YSFrId+M KgST9punuGvww16YSFY5KwBcMI995FWeO+F3P2JfYstayCvCJ6pf2FmB5cf7UELLzcTo fgBTG2d6TgYGMgrHuOr0I5lj7PlPjkT+2dB2A6BsbhxQfcEQoVUUW1K3ifggN472+4Hg Kzog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date; bh=JskDu5aXXZfrkv/DvMfGjLDKC9YA6Ryz7zHQooGqrH0=; b=xrteOffatRBmf7YvidVVJ+DPd59neQEqbylyi4OFQdyodYUmv6TyGQiuJrk75cxcX2 tBN1neUf2zp4RDwgdZSvI7fpGdG6dYMFLuBxWU/OWBiuLGy1QlP42wyYcuCiY4qPbLAQ sJidQluHFt9VqOLPbZi98GjbhQ8f4dTyZxKrdwjTUa5x8gVBZTGVKGPPZurcKNxtYfR4 6YqAWnE7ymPkfvDFLbWgRDCSQqAznQ+tErPt/suLh35erBF9P4oPBHzdwIiBcqnRMGth y8+XD6Wkfb/GN46odpxGP2HnPTZdr5WrQ+JG9dyIelWe2HKaX+bMwAEXpw066Q5AZkIW LPug== X-Gm-Message-State: ACgBeo2PET/KSbVu5buukdsHMhGbg1V8P8KxA1PpkOziv5UyYbw6pixi AD9JiHB89ibTAv+Z3kM/var1OQ== X-Google-Smtp-Source: AA6agR6MZ1yV+ofCju7fivzbKfloSaUGCOUtSKr34um4yB7LuN0nXtwcAL9SIlZv0zvh0xxFfBwkhw== X-Received: by 2002:a63:290:0:b0:41c:506f:7ae9 with SMTP id 138-20020a630290000000b0041c506f7ae9mr13688637pgc.373.1662752139974; Fri, 09 Sep 2022 12:35:39 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id jb9-20020a170903258900b0017515e598c5sm873276plb.40.2022.09.09.12.35.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Sep 2022 12:35:39 -0700 (PDT) Date: Fri, 9 Sep 2022 19:35:35 +0000 From: Carlos Llamas To: Suren Baghdasaryan Cc: Andrew Morton , "Liam R. Howlett" , Michal Hocko , Guenter Roeck , Douglas Anderson , Christian Brauner , Greg Kroah-Hartman , linux-mm@kvack.org Subject: Re: BUG in binder_vma_close() at mmap_assert_locked() in stable v5.15 Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662752141; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=JskDu5aXXZfrkv/DvMfGjLDKC9YA6Ryz7zHQooGqrH0=; b=0hgkAb2LDL0LEuPapbkqvseDAJxBuFXybSxuvqRFprdur+Q+d2vYQEkToARAMKk2SVNUvJ NcW8cTzgPoTHBgR/EFhm1tNTTvhINFq526rs7VaPhPmvKJWorrZp8WqB+pVYu+Nb5mBvVC QnCttvoAgM+34wSL93LvLOzve2Imrsk= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=YeS6Ueze; spf=pass (imf18.hostedemail.com: domain of cmllamas@google.com designates 209.85.215.173 as permitted sender) smtp.mailfrom=cmllamas@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662752141; a=rsa-sha256; cv=none; b=Wn1iLK5z8ogSZUl9D+kObSriPvwi5B81YLYjImPP9JyN0TAWkb0xyun/S6h069uXCjKTHd GsgttNm4tyWG334i3t1/ffjk02KR4+LH6SnJXiefh2kXW2Ry4R4GP8q3HPAQK9Vkm9yiQm 2Of+UyoiV6a10EvoFMO5qeQdxVWK0rE= X-Rspam-User: X-Stat-Signature: 4qdjnxedomy1h99rnjxsnmetjyp3mjnd X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 486441C0082 Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=YeS6Ueze; spf=pass (imf18.hostedemail.com: domain of cmllamas@google.com designates 209.85.215.173 as permitted sender) smtp.mailfrom=cmllamas@google.com; dmarc=pass (policy=reject) header.from=google.com X-HE-Tag: 1662752141-809476 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Sep 08, 2022 at 03:33:52PM -0700, Suren Baghdasaryan wrote: > > However, mmap_locking was only added to the exit_mmap() path in commit > > f798a1d4f94d ("mm: fix use-after-free bug when mm->mmap is reused after > > being freed") and since this patch doesn't exist in v5.15 stable tree Sorry, I meant 64591e8605d6 ("mm: protect free_pgtables with mmap_lock write lock in exit_mmap") here, that's when protection was added. > IIUC, the binder patches are backported to 5.15 kernel and they expect > mmap_lock to be held during remove_vma() operation in exit_mmap(). Correct! > However in 5.15 kernel that assumption is incorrect. In that case IMHO > the backport needs to drop that invalid expectation. Does this mean that users of async calls such as find_vma() can't rely on mmap_lock to avoid racing with remove_vma()? I see the following pattern is used quite often: mmap_read_lock(mm); vma = find_vma(mm, addr); [...] mmap_read_unlock(mm); Is this not a real concern? I'd drop the asserts from binder and call it a day. However, we would also need to fix our race with vm_ops->close().