From patchwork Sat May 20 11:33:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tetsuo Handa X-Patchwork-Id: 13249175 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 7EEF0C77B7F for ; Sat, 20 May 2023 11:33:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DA416900005; Sat, 20 May 2023 07:33:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D5494900003; Sat, 20 May 2023 07:33:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C4336900005; Sat, 20 May 2023 07:33:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id B58B2900003 for ; Sat, 20 May 2023 07:33:31 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 761621C7C74 for ; Sat, 20 May 2023 11:33:31 +0000 (UTC) X-FDA: 80810423022.29.C6F476B Received: from www262.sakura.ne.jp (www262.sakura.ne.jp [202.181.97.72]) by imf08.hostedemail.com (Postfix) with ESMTP id 399C4160017 for ; Sat, 20 May 2023 11:33:27 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=none; dmarc=none; spf=none (imf08.hostedemail.com: domain of penguin-kernel@I-love.SAKURA.ne.jp has no SPF policy when checking 202.181.97.72) smtp.mailfrom=penguin-kernel@I-love.SAKURA.ne.jp ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684582409; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uyy9//M3BwBqmLOoKOJh5JZwBZicGYDNipme9R6fLug=; b=mRyokCsTbdm5ij0qJulVrxh0sNX3N6PXC9k1JKycuY/sbpEOgc6qa41ELfOY0a+uoc8+ur TkMe3ALVO0FUoJ+VPDtZ0hhbF49CwE7CgJ8NNwU3OT528FqFh8QNaLmfiQ8x3+Fr0BA8gY V6b+NRIwxiJQNvALIO9JHizpWcdR7rs= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=none; dmarc=none; spf=none (imf08.hostedemail.com: domain of penguin-kernel@I-love.SAKURA.ne.jp has no SPF policy when checking 202.181.97.72) smtp.mailfrom=penguin-kernel@I-love.SAKURA.ne.jp ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684582409; a=rsa-sha256; cv=none; b=evXHNCK9xIUlZncoMaRBFEPq/C0aEy+YFB8xoZPUl6PfJmvIBodUBhBuv9e6rL81uGdi30 7DnEVO63e8+bC16kgP332ECHZ2Om82BWfvzYlk/I4FNRf4+AwsMsO4Fi8s/f1/d3QK1zp5 w959sd8lh3xgzXPbXmYFcESJQq6Zoik= Received: from fsav415.sakura.ne.jp (fsav415.sakura.ne.jp [133.242.250.114]) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTP id 34KBX4GB028805; Sat, 20 May 2023 20:33:04 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav415.sakura.ne.jp (F-Secure/fsigk_smtp/550/fsav415.sakura.ne.jp); Sat, 20 May 2023 20:33:04 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/550/fsav415.sakura.ne.jp) Received: from [192.168.1.6] (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 34KBX4JW028802 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NO); Sat, 20 May 2023 20:33:04 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Message-ID: Date: Sat, 20 May 2023 20:33:04 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: [PATCH] lib/stackdepot: stackdepot: don't use __GFP_KSWAPD_RECLAIM from __stack_depot_save() if atomic context Content-Language: en-US From: Tetsuo Handa To: syzbot , syzkaller-bugs@googlegroups.com, Mel Gorman , "Huang, Ying" , Vlastimil Babka , Andrew Morton , Alexander Potapenko , Andrey Konovalov , Dmitry Vyukov , Andrey Ryabinin Cc: kasan-dev , linux-mm References: <000000000000cef3a005fc1bcc80@google.com> In-Reply-To: X-Rspam-User: X-Stat-Signature: xfgewcajs9pwbn7fkcsp8wto46akd6rj X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 399C4160017 X-HE-Tag: 1684582407-809876 X-HE-Meta: U2FsdGVkX19dE/M8U0aQ1nUth7o3YfAsb4tqIL8valcOijU0cQk+jA5VFerPaNvLBi7Gas8dmqVMj0gE1yUgXdPtcDir5TZJtcWssOoVQL7XRQTPpVqz/3xzBOfRpsnMGZlxak+555Ba/lAxJxOi70jhxydfmlli6BeCy7ZHF2KYk4B0sBPeyL2t85G2XMLlRLhGbh3AzzC0E0xKdFeoXsDN/KI5hBqTYEwbcFBWRZ/eVIyZNYiVSwxBmmSQBscRnLt51hypAcMzElSXYJd/kscYIBpgsCxg0hgzLmeUa5E6jKLE7+XrL+W3Jn0ojRMQ0PZmk+qvbPfZb96NHosVErHM+Mm5F7Y3U/zXEewZFAtGWeTzDQvtwG+V+RbmGj5BNW0DoaB2BfpX6wxcmultCQq8KFcfBhftoUowujIX7mq8meG8Yyn70y7TKcsNvzB3zZJCsISlpERyoVNohCi8OTkEfThZZIWCy9zMdwPLq1EGbLnGNfpiySZThG19fnc0Kw/GcZghhzz7fzANTe3lJjK+vbZ+u5AWhljd7eHdJV0VYJ6gbjhnpZVIWP9K5+9aLmO+qUDdF8Kr1QXKNVGiF5TfcfFjhFaEmR8m7wTY5UaoUQdVVF4XqV5c0Z0b6jVnaHJ94utekUMjg/DKd54GNyB949ClV7jzt8p+FW+wazgDRLWoGgM68rQilS497hSBO48z3gG5CUEXti4HBh2oKjvf8Iza/UqMY7gULuQk8+j0hIknKL54acFDoHPU8Jad4z+uWmyXmHDWUImxzzEAEQfju/iMukCfudtg3v0KtggP4HiX+g85j6j5cmNFBWiu63FgBVCRnYKhywBgSzT0m4pqx5/+rROtIaW9lnL0PugF/7I1gJvi1X5ieQKq2pBNtRTa0QHAwf+rPDEURGhgldeBjQOuh1JipNiv8n+VIUHv3KEvIdAvLH5MZCRaJ7bNbghk7Unh8RbY+9cGApX wiN2ZdSJ 1ijqXEeG/p/9TYB+h1dhRbx/L2Khl8N10RGNIWeMgccxcMvT1R3BFecJ2E3sBX/OWgiScl4W6rQjc9jvscW43y88UzTthJoodJ5KU4VGdRQP/WSEPUN/Bnfd/0r1sbgVDxPK7T4jQvvfKzWuVaAbdbX+lahpGBeiOUXt8BMRTDhRyePQOwnE0HdX2cRJuFgvoMxye1g0lgoIkvv5cetX9Qc9e45tNYSYenwvGUE/LgynAm2eqEl+IJBYPzb7GMRIGUWr5WzE7wdkZFCbi+n1u2cmbQ7TQO5J8kByCVEWhR1st3V2yyygd2DjKCEqHX7D0O/xXLnuM0tMBsp4i1mFO9rJ3sfHKt6dfs78ASuCycqUNbsKApF6vUSkR2Y1GQUX6RZPVObPa1s211qsQgxY2xUuC/CUdOKa6bn9SwIvlJtkHtLOPck0lIiMVp4RJQjTyagF7/6n+qgGYnJ+zVJdE0f+An1m0gYv2K0pfx8Ptf+lfT1w= 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 lockdep warning in __stack_depot_save(), for wakeup_kswapd() from wake_all_kswapds() from __alloc_pages_slowpath() calls wakeup_kcompactd() when __GFP_KSWAPD_RECLAIM is set and __GFP_DIRECT_RECLAIM is not set (i.e. GFP_ATOMIC). Since __stack_depot_save() might be called with arbitrary locks held, __stack_depot_save() should not wake kswapd which in turn wakes kcompactd. Reported-by: syzbot Closes: https://syzkaller.appspot.com/bug?extid=ece2915262061d6e0ac1 Signed-off-by: Tetsuo Handa Fixes: cd11016e5f52 ("mm, kasan: stackdepot implementation. Enable stackdepot for SLAB") --- lib/stackdepot.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/stackdepot.c b/lib/stackdepot.c index 2f5aa851834e..5c331a80b87a 100644 --- a/lib/stackdepot.c +++ b/lib/stackdepot.c @@ -405,7 +405,10 @@ depot_stack_handle_t __stack_depot_save(unsigned long *entries, * contexts and I/O. */ alloc_flags &= ~GFP_ZONEMASK; - alloc_flags &= (GFP_ATOMIC | GFP_KERNEL); + if (!(alloc_flags & __GFP_DIRECT_RECLAIM)) + alloc_flags &= __GFP_HIGH; + else + alloc_flags &= GFP_KERNEL; alloc_flags |= __GFP_NOWARN; page = alloc_pages(alloc_flags, DEPOT_POOL_ORDER); if (page)