Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1051825ybh; Thu, 16 Jul 2020 01:35:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwd3FtLuGDf1rr7gxOOEbKPQLlnX1mnZJJ3bxlyQDHXpgoOlpMKPPXJ/Ik2h/Yi7O3JFfnl X-Received: by 2002:a50:d7c1:: with SMTP id m1mr3484945edj.217.1594888547573; Thu, 16 Jul 2020 01:35:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594888547; cv=none; d=google.com; s=arc-20160816; b=aO/Tyc8XSfRi6lez40eI2o0e5bdCQ5e3t6b1jP3A1TM9gz7uwYu2fYbvRFazZkeWCg QSFl3fEKiOn6R3m36amlKNv47FrhLmfBa0D0awuhv4pHwm83X3WIhsOMaRh6cMcxUu68 xwvg8X6DquQWmjCXZIC12QLa8ARX5SE+iE4ZRbiZXd6N7P6cZ40dWXG2r4NZEgxY/8P6 Mq65jw0xagHmam4JVVfb3S01YGCvn21N52zReeLTMnWzxO1J0paRAArMppEx+cRyPehy Ko0kzuBUrhbS2iHiuKPe/dJhkMVc1q3XOwW8/Vy541lc2bG020/dNecN6ZsaXEn78OGu P9ZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=SCfJrST46qsDSMEeSPURbguLv5Ok1Ae63n1bRqdpvEU=; b=jr7aBY2SvJ7dhC382DGWUzaw6FP2GmHCskOPueJxrWy2/iAFptPKzWF712cP1VEIx5 SgCYwRFXAzuXUBZVWFs1dF/eBZ1YakWUmkfO6Rw2frirAEIe/3uVtGoTcxPuMRmInwNL AuyAPw1m2cIlyi0898a3Cm7owoBnHRVPOPTWDRJIiltma6VqBXLez9Tl7uc9uwjf0pVQ 7fu+/LNQDw/usDhicV4HLsWgTPad67ZWIpStAKoJUs8n95uz5OMKzvTjeE76dhMETR6q zm7qgWMmS2y9nc2ZKYpadRV6aal8aOxxG0lBi+PgFdCPYIc2AyBkFrvOw5UXIKWjvpdy pUqQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e1si2758168ejb.286.2020.07.16.01.35.24; Thu, 16 Jul 2020 01:35:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726547AbgGPIfP (ORCPT + 99 others); Thu, 16 Jul 2020 04:35:15 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:54114 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725831AbgGPIfP (ORCPT ); Thu, 16 Jul 2020 04:35:15 -0400 Received: by mail-wm1-f66.google.com with SMTP id j18so9396390wmi.3 for ; Thu, 16 Jul 2020 01:35:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=SCfJrST46qsDSMEeSPURbguLv5Ok1Ae63n1bRqdpvEU=; b=LMTbvmHlE71V4G6DDnO4hzqIeC/GAW9XsGTzKjoTp0VUN4UFH/azz0SmN0fv3ub6JN JP07+DdZxCznVtful4waRgo/Bo/4/4IVETsc1AMZmEot36I3ajKgQp9tbqFq4xZJgOvj Wo9IYruquhUCtu2518/Zx2w0jCEd6D9/UeZo7Mk+t6XCE5jJ9CAild9QgTE/mSJI9vcQ vnYMVuroH1KTKDp5z3ep7iNwZxtxsOk4cdMVtd5lBRYhMONX3eBz7IrQZh4buOEsHlvn cxuuhdPEY3/xag+dInAEqjssFcJlATZG4elvwDIodl9Av5/8CrOphfG9c+fLmgF/B8SE eIjQ== X-Gm-Message-State: AOAM531hs1/HUzdvo7YvAf7VJ/yeifpBTHO6AUI5k4Ckq5pVgEK+1HFy F7HkvAAdJqx34uKOAZ5dUtA= X-Received: by 2002:a1c:f60d:: with SMTP id w13mr3460331wmc.51.1594888513277; Thu, 16 Jul 2020 01:35:13 -0700 (PDT) Received: from localhost (ip-37-188-169-187.eurotel.cz. [37.188.169.187]) by smtp.gmail.com with ESMTPSA id j24sm8302028wrd.43.2020.07.16.01.35.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jul 2020 01:35:12 -0700 (PDT) Date: Thu, 16 Jul 2020 10:35:06 +0200 From: Michal Hocko To: Tetsuo Handa Cc: Greg Kroah-Hartman , Arve Hjonnevag , Todd Kjos , Martijn Coenen , Joel Fernandes , Christian Brauner , syzbot , acme@kernel.org, alexander.shishkin@linux.intel.com, jolsa@redhat.com, linux-kernel@vger.kernel.org, mark.rutland@arm.com, mingo@redhat.com, namhyung@kernel.org, peterz@infradead.org, syzkaller-bugs@googlegroups.com, "open list:ANDROID DRIVERS" , linux-mm Subject: Re: [PATCH] binder: Don't use mmput() from shrinker function. Message-ID: <20200716083506.GA20915@dhcp22.suse.cz> References: <0000000000001fbbb605aa805c9b@google.com> <5ce3ee90-333e-638d-ac8c-cd6d7ab7aa3b@I-love.SAKURA.ne.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5ce3ee90-333e-638d-ac8c-cd6d7ab7aa3b@I-love.SAKURA.ne.jp> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 16-07-20 08:36:52, Tetsuo Handa wrote: > syzbot is reporting that mmput() from shrinker function has a risk of > deadlock [1]. Don't start synchronous teardown of mm when called from > shrinker function. Please add the actual lock dependency to the changelog. Anyway is this deadlock real? Mayve I have missed some details but the call graph points to these two paths. uprobe_mmap do_shrink_slab uprobes_mmap_hash #lock install_breakpoint binder_shrink_scan set_swbp binder_alloc_free_page uprobe_write_opcode __mmput update_ref_ctr uprobe_clear_state mutex_lock(&delayed_uprobe_lock) mutex_lock(&delayed_uprobe_lock); allocation -> reclaim But in order for this to happen the shrinker would have to do the last put on the mm. But mm cannot go away from under uprobe_mmap so those two paths cannot race with each other. Unless I am missing something this is a false positive. I do not mind using mmput_async from the shrinker as a workaround but the changelog should be explicit about the fact. > [1] https://syzkaller.appspot.com/bug?id=bc9e7303f537c41b2b0cc2dfcea3fc42964c2d45 > > Reported-by: syzbot > Reported-by: syzbot > Signed-off-by: Tetsuo Handa > --- > drivers/android/binder_alloc.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/android/binder_alloc.c b/drivers/android/binder_alloc.c > index 42c672f1584e..cbe6aa77d50d 100644 > --- a/drivers/android/binder_alloc.c > +++ b/drivers/android/binder_alloc.c > @@ -947,7 +947,7 @@ enum lru_status binder_alloc_free_page(struct list_head *item, > trace_binder_unmap_user_end(alloc, index); > } > mmap_read_unlock(mm); > - mmput(mm); > + mmput_async(mm); > > trace_binder_unmap_kernel_start(alloc, index); > > -- > 2.18.4 > -- Michal Hocko SUSE Labs