Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1291271ybh; Thu, 16 Jul 2020 08:13:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyWRdQ4U0u7xbcMXwM6sUoOPQ98exiF4pBl6QwwCgIY9NRNeUVpy8M+ioRzxlehdqaoyfJo X-Received: by 2002:a17:906:5909:: with SMTP id h9mr4343201ejq.501.1594912390797; Thu, 16 Jul 2020 08:13:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594912390; cv=none; d=google.com; s=arc-20160816; b=RnEF58JwEO02oweGImLryRpcK2fb/Kw4U1TbvElrtgyDv9zBbe9464juh3PJAGd5RU Of+qOUCwt81X6NTzDAaS0Eack5bHz0mkDiYwmy9xSazD6gLQN24xCYdB9T6KP7OJaRb3 R3hGdE60yfFwuu7LEly19Pfod3Oy42sYqjuFvdE2x1nNSfleHqt/dqOQXvvaaqxkPR3K Z0FAhfGsuhRJIwtuhBohqirdeWpT8qCHKGcIor30ugfXClBWtA29QxA1nG8V34dpON6E LBkMzUs84rwBNe9duQegwknnNqRX0U0Zgof0fGRZfqtd+QN4SWNKb+chJpx2AP+MAYhg Gw/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=NEH+pbgcudQCCDg1qoRpyf6jtYssUy9EcDrSEV80BZc=; b=oeGptmz/bNvDhGISwMFfOaQdEnPiBchDhBzkcBDnqasYHoENnIjxZV7oH9AG1ia3h/ oZDyaPgEggZN4coWsELqizOUrJJPk44v2h6VVrF9ZwWV/uSic/J1K6W1PNpnh1cf/h+n ViahXxlc4cd6UMs3LXORtGWIOnaJvIUSgmTpH+Gh9u8CvGCK2Y18u4hN116aThaQwn+/ qobvkPqbb5nkosjzLz4BKwHo6MD8coYEs2zvwaGY0H45DlIbqeyhXGqmoFQ+9WgbliYJ aHQ7RAtLlfMtH1vLreFaVpb7EBvC2bMSoRB85mDKMrToV5ErQcf83ZtAYAOPYHhZ6Px6 3uyw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s14si3348956ejq.387.2020.07.16.08.12.46; Thu, 16 Jul 2020 08:13:10 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728552AbgGPPMX (ORCPT + 99 others); Thu, 16 Jul 2020 11:12:23 -0400 Received: from www262.sakura.ne.jp ([202.181.97.72]:62416 "EHLO www262.sakura.ne.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728150AbgGPPMX (ORCPT ); Thu, 16 Jul 2020 11:12:23 -0400 Received: from fsav401.sakura.ne.jp (fsav401.sakura.ne.jp [133.242.250.100]) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTP id 06GFCKfs068296; Fri, 17 Jul 2020 00:12:20 +0900 (JST) (envelope-from penguin-kernel@i-love.sakura.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav401.sakura.ne.jp (F-Secure/fsigk_smtp/550/fsav401.sakura.ne.jp); Fri, 17 Jul 2020 00:12:20 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/550/fsav401.sakura.ne.jp) Received: from [192.168.1.9] (M106072142033.v4.enabler.ne.jp [106.72.142.33]) (authenticated bits=0) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTPSA id 06GFCJbd068287 (version=TLSv1.2 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 17 Jul 2020 00:12:19 +0900 (JST) (envelope-from penguin-kernel@i-love.sakura.ne.jp) Subject: [PATCH v2] binder: Don't use mmput() from shrinker function. To: Greg Kroah-Hartman , Arve Hjonnevag , Todd Kjos , Martijn Coenen , Joel Fernandes , Christian Brauner Cc: Michal Hocko , 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 References: <0000000000001fbbb605aa805c9b@google.com> <5ce3ee90-333e-638d-ac8c-cd6d7ab7aa3b@I-love.SAKURA.ne.jp> <20200716083506.GA20915@dhcp22.suse.cz> <36db7016-98d6-2c6b-110b-b2481fd480ac@i-love.sakura.ne.jp> <20200716135445.GN31089@dhcp22.suse.cz> From: Tetsuo Handa Message-ID: <4ba9adb2-43f5-2de0-22de-f6075c1fab50@i-love.sakura.ne.jp> Date: Fri, 17 Jul 2020 00:12:15 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200716135445.GN31089@dhcp22.suse.cz> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org syzbot is reporting that mmput() from shrinker function has a risk of deadlock [1], for delayed_uprobe_add() from update_ref_ctr() calls kzalloc(GFP_KERNEL) with delayed_uprobe_lock held, and uprobe_clear_state() from __mmput() also holds delayed_uprobe_lock. Commit a1b2289cef92ef0e ("android: binder: drop lru lock in isolate callback") replaced mmput() with mmput_async() in order to avoid sleeping with spinlock held. But this patch replaces mmput() with mmput_async() in order not to start __mmput() from shrinker context. [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