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 107D7C6FA82 for ; Mon, 12 Sep 2022 19:11:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 362188D0002; Mon, 12 Sep 2022 15:11:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2E9F28D0001; Mon, 12 Sep 2022 15:11:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 164448D0002; Mon, 12 Sep 2022 15:11:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 01B7B8D0001 for ; Mon, 12 Sep 2022 15:11:15 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id C8015AABBC for ; Mon, 12 Sep 2022 19:11:15 +0000 (UTC) X-FDA: 79904376510.04.8353D5F Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) by imf06.hostedemail.com (Postfix) with ESMTP id 7C585180086 for ; Mon, 12 Sep 2022 19:11:15 +0000 (UTC) Received: by mail-pl1-f174.google.com with SMTP id f24so9506219plr.1 for ; Mon, 12 Sep 2022 12:11:15 -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=ikh9ZQ7u447br/1g7G+8Sbgsqv90wPmrbkZpnAsub+M=; b=GuT/bzB+Mgp94eGm+Ni5uOu8DducUm9X1tLFUGnUOS8onmZ5rleQfN4QRZ5/TF4Ljk ij6WkvktDHbmuPWyP3c7GHcxp8n1Nt5Eyzh7RtIPHvtTrVLlSM7tcp8a2M/nhf+VxYRh Ugodk5Wb0oVsbrrzLvOSCMAJs9gT2yok7reqfszDyy+37UONH/E77rg6fhqDNcKEIcTX Jqiclpjpf6VVt45uSlnZV7c8ld/KW70q8mQupnzZwHWFU7EzHkPDZBMPtqmDWFFVbHqK +dWcQ1L1ZbUkmIxcAZVIJRRN8E29kIkANsScsKVxByQyI7vbKpUR9YMpktfTU058m9BV 9Yiw== 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=ikh9ZQ7u447br/1g7G+8Sbgsqv90wPmrbkZpnAsub+M=; b=GkSyNvcbeyUzGYd7F2UwU/IGhtnpOJLEARMmE/isJWByEVMW92XssbMcB+Eg+PdTrE 3BD6VHHqjkcPXHlojY6ve23CC4/02x8fqQXRfWdB9oBMhD/BS3lfAioWXKPXJVrhYZaC +r9YhULrRl8RzDe2b4iAo/z7zYd5Jjsmt4znxlrwPlh1+86+clh/s/shWKPleltm0LUg 2THpPmXL4pf5bng5y75bJIuOXB8WgELuRNnRGHC4FX6ltlqjQo3pWEoijpmMOcOZf5C0 fmU6niX+l+zZ4C2xJm0E3SfOe+3XHndfxuM1U4JkpCA4adNzbgUYmnKPGtbh/DwbbjoH 8aGQ== X-Gm-Message-State: ACgBeo2jJek5znddZWbNcCsPURNtNQ38OjRiVuGbpgiZv+nST8lSr0w7 /K0vHngDRLNwC12OTiDhMGtDVc3GBxlpEA== X-Google-Smtp-Source: AA6agR66VHw+ADRrIzMlhspEG0Sg7R/FVDSoTTGGfKQ8Nz/59yWNgQD6rKNBh+z1y13t0RkCqBM5yw== X-Received: by 2002:a17:90b:1d0f:b0:202:be3e:a14a with SMTP id on15-20020a17090b1d0f00b00202be3ea14amr10272508pjb.102.1663009874309; Mon, 12 Sep 2022 12:11:14 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id q6-20020a17090311c600b00177ef3246absm6458109plh.103.2022.09.12.12.11.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Sep 2022 12:11:13 -0700 (PDT) Date: Mon, 12 Sep 2022 19:11:10 +0000 From: Carlos Llamas To: Suren Baghdasaryan , "Liam R. Howlett" 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=1663009875; 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=ikh9ZQ7u447br/1g7G+8Sbgsqv90wPmrbkZpnAsub+M=; b=3DBcomWEt86fOXVO8uL8GUZ6GgXz6Gkv2b8soJ0GVypIVWSgMSYpAb8vO7QmLKaw+5WtfJ joCjK1mtzz6jP0Ew/HX3EkvrETococrVLF90xQbO7J+RbEb+ZOqPM6st2X8IJmb1iRHt2Q Ej027nzEJaJCyD3PVW9UGVwtt+tOC+g= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b="GuT/bzB+"; spf=pass (imf06.hostedemail.com: domain of cmllamas@google.com designates 209.85.214.174 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=1663009875; a=rsa-sha256; cv=none; b=f+/PBofjyiot6P7C0Gm2IPPya3fD1qFNHcwmfZ8nu9Y2dxiRnvsgADpzAWl3g09gI7NEuT avSxYHlibUe+bOMMaP8KXqFMFcWziSfWfrRudnF//9Svj/W+iDXZm0EHYFBzlVWW7m3MTj kcATZbq24jLnr6+l5q4VCKiN+laDIaQ= X-Stat-Signature: zurz9sc6jx4cscy646gdumush7jiyc9j X-Rspamd-Queue-Id: 7C585180086 Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b="GuT/bzB+"; spf=pass (imf06.hostedemail.com: domain of cmllamas@google.com designates 209.85.214.174 as permitted sender) smtp.mailfrom=cmllamas@google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspam-User: X-Rspamd-Server: rspam09 X-HE-Tag: 1663009875-360735 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 Fri, Sep 09, 2022 at 01:03:08PM -0700, Suren Baghdasaryan wrote: > On Fri, Sep 9, 2022 at 12:35 PM Carlos Llamas wrote: > > > > 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(). > > I think by the time exit_mmap() calls remove_vma() there can be no > other user of that mm to race with, even oom-reaper would have > finished by then (see: > https://elixir.bootlin.com/linux/v5.15.67/source/mm/mmap.c#L3157). > So, generally remove_vma() would be done under mmap_lock write > protection but in case of exit_mmap() that's not necessary. Michal, > please correct me if I'm wrong. I see, that makes more sense. Then it sounds to me like binder should be using mmget_not_zero() to serialize against exit_mmap() during these async calls. I'll have a closer look at this change. Also, we should drop the mmap_lock asserts in binder from v5.15 as the expectations there are incorrect. Again, this was done in [1], but for different reasons. We could simply amend a small note to the commit log with an accurate reason for the backport. Liam, wdyt? [1] https://lore.kernel.org/all/20220829201254.1814484-5-cmllamas@google.com/