From patchwork Thu Jul 16 15:12:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tetsuo Handa X-Patchwork-Id: 11667773 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 794861392 for ; Thu, 16 Jul 2020 15:14:20 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 443BB2083B for ; Thu, 16 Jul 2020 15:14:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 443BB2083B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=i-love.sakura.ne.jp Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 4E2C88D001E; Thu, 16 Jul 2020 11:14:19 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 46DBF8D0016; Thu, 16 Jul 2020 11:14:19 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 335718D001E; Thu, 16 Jul 2020 11:14:19 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0109.hostedemail.com [216.40.44.109]) by kanga.kvack.org (Postfix) with ESMTP id 1A82C8D0016 for ; Thu, 16 Jul 2020 11:14:19 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 9BFB1180AD811 for ; Thu, 16 Jul 2020 15:14:18 +0000 (UTC) X-FDA: 77044284996.03.actor91_5a0412e26f03 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin03.hostedemail.com (Postfix) with ESMTP id 55FF01777E for ; Thu, 16 Jul 2020 15:12:52 +0000 (UTC) X-Spam-Summary: 1,0,0,028d379c4a5bf92f,d41d8cd98f00b204,penguin-kernel@i-love.sakura.ne.jp,,RULES_HIT:41:152:355:379:854:960:966:967:973:988:989:1260:1261:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2196:2198:2199:2200:2393:2525:2559:2563:2682:2685:2731:2859:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3352:3866:3867:3868:3870:3871:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4385:5007:6261:6742:7652:9025:10004:10400:11026:11658:11914:12043:12048:12296:12297:12438:12517:12519:12523:12532:12555:12760:12895:13069:13075:13215:13221:13229:13311:13357:14093:14096:14097:14181:14394:14721:21080:21365:21433:21451:21627:30054,0,RBL:202.181.97.72:@i-love.sakura.ne.jp:.lbl8.mailshell.net-64.201.201.201 62.8.10.100;04ygj9mwmftei6tw3rxoanth5bhkwopd9p8ga6uxwe4197ayxqeoaimoc9jyr6d.uzaqqycrsdkqbx6kfgdscxhcwb88jytg9crr96uhum85zstbfyjt487u3ts6k3q.s-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5, 0.5,0.5, X-HE-Tag: actor91_5a0412e26f03 X-Filterd-Recvd-Size: 3919 Received: from www262.sakura.ne.jp (www262.sakura.ne.jp [202.181.97.72]) by imf49.hostedemail.com (Postfix) with ESMTP for ; Thu, 16 Jul 2020 15:12:51 +0000 (UTC) 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-Language: en-US X-Rspamd-Queue-Id: 55FF01777E X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam02 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: 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 Reviewed-by: Michal Hocko Acked-by: Christian Brauner Acked-by: Todd Kjos --- 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);