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 X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=BAYES_00,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4650FC433E2 for ; Thu, 16 Jul 2020 08:35:16 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0CAD42071B for ; Thu, 16 Jul 2020 08:35:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0CAD42071B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A34378D000A; Thu, 16 Jul 2020 04:35:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9E3C38D0005; Thu, 16 Jul 2020 04:35:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8D20E8D000A; Thu, 16 Jul 2020 04:35:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0226.hostedemail.com [216.40.44.226]) by kanga.kvack.org (Postfix) with ESMTP id 74EBE8D0005 for ; Thu, 16 Jul 2020 04:35:15 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 26D6B82499B9 for ; Thu, 16 Jul 2020 08:35:15 +0000 (UTC) X-FDA: 77043279390.10.blade18_3a05fb426f00 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin10.hostedemail.com (Postfix) with ESMTP id E86B216A044 for ; Thu, 16 Jul 2020 08:35:14 +0000 (UTC) X-HE-Tag: blade18_3a05fb426f00 X-Filterd-Recvd-Size: 4902 Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by imf19.hostedemail.com (Postfix) with ESMTP for ; Thu, 16 Jul 2020 08:35:14 +0000 (UTC) Received: by mail-wm1-f65.google.com with SMTP id w3so10583277wmi.4 for ; Thu, 16 Jul 2020 01:35:14 -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=mBtmvjdavaFlN5ONQXRsWLp2lnumbS2N3PQ1lT7MS67RZByytyIhndUX57cXzJNdk3 GuaLHqtOpcqwGwQph6/udzp1BCOJJhCzCMM8ZlWtGqynMQhhiDyznk40DXljeulwquV5 A1bSbNTT/EXfhG61xqIPb1Rd4ebA2WBCC7rTb7TQbtA4iGafshBuwdD7xcC82KpllDX5 BGDDNcoODmC42M7l3IpHysHxZ+Yaju84pcn8kg+mssAaYTG5RFDRgi4xX2eAOpWiA+Zv gmS4D3TE+jcB/dDBZ98n7LdCh7COJyZJH9Qs+CFCj2VXiO5f6FK+ErZLAxg27AkFRVtP iKtA== X-Gm-Message-State: AOAM5338LicaAwICSW/ce5UP/iIWwT7kpyvWa/me3NRkiWDopyTnTROh 3hguSZVzA7wXe/jxehYRqL0= X-Google-Smtp-Source: ABdhPJykcwCVuCzDa+1jzmfvr7sUJBVtZnozf/QJbmRYAEOA1BdDzHjM4ShBya82D//FX2ojusDXsg== 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> X-Rspamd-Queue-Id: E86B216A044 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 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 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