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=-13.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=no 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 461B5C433DB for ; Sat, 13 Feb 2021 10:58:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B096E64DF2 for ; Sat, 13 Feb 2021 10:58:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B096E64DF2 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 13F758D00C1; Sat, 13 Feb 2021 05:58:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0F0178D0060; Sat, 13 Feb 2021 05:58:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 005588D00C1; Sat, 13 Feb 2021 05:58:47 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0023.hostedemail.com [216.40.44.23]) by kanga.kvack.org (Postfix) with ESMTP id DC02B8D0060 for ; Sat, 13 Feb 2021 05:58:47 -0500 (EST) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 8BE20180D0F9A for ; Sat, 13 Feb 2021 10:58:47 +0000 (UTC) X-FDA: 77812946694.30.grip88_470c80a27629 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin30.hostedemail.com (Postfix) with ESMTP id 66D9218143CC8 for ; Sat, 13 Feb 2021 10:58:47 +0000 (UTC) X-HE-Tag: grip88_470c80a27629 X-Filterd-Recvd-Size: 7760 Received: from mail-qk1-f172.google.com (mail-qk1-f172.google.com [209.85.222.172]) by imf46.hostedemail.com (Postfix) with ESMTP for ; Sat, 13 Feb 2021 10:58:46 +0000 (UTC) Received: by mail-qk1-f172.google.com with SMTP id r77so2081730qka.12 for ; Sat, 13 Feb 2021 02:58:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=IpE0yQR+r9TZYKB7SOgK9TDG3SDQRc6/EdWKyoqtYyE=; b=TpklhvP9JfuDBxHn2I3a5Czxo0QLDVJk590yNeMrhm/7AfqgRxG2Yz6j2K0ePngkcK 36eQEV+FsXe+MYP7CeUrtWvmSmJ7KJRLbl4s0vyhSPWexVHpyvgvggop5oEB/zhTADtX sAJppDn5uad6XoGeoHhT292p/tosHlO9LIzkKTS0k5PPVAD//XP8224R8zJoFZy0r9HC gTfBBG77pNRyb55g2w6o9A65mNzSfsbNEFf0bjkZsfGJ7E9C8NoyJ0csCP9hLhnVIbB8 YbNrqMbyWsZm16BbY4r6oSF0rvyDRmFC/QzDs3qUM0YIHkBUC7D4MZsFGuUhuikJ9DWL +ySw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=IpE0yQR+r9TZYKB7SOgK9TDG3SDQRc6/EdWKyoqtYyE=; b=WoiwzvwuHZEqPqtyyeI5sNYR1yGT6bg9tkyjRxMqP8Dk5s6Ifhv+l4/bvaSApRivDc 916VTGpeHj9hAwfdsCzks2xHjYeNPMbP64vry4ZGbpqP4i8TX2JDX3ng4bFUTMbaJpbz 7L+luQIz/jBSEUd1Zps6hgwca6nif1XnrCe/v1poeOypS7Zogy4IRV4XPu8sxHOTb80u xjSnSEv82lYWdOMWnByRsg+CGUgXZ756kacL5768Ec0iD6P73hXVD4LqPUfV1Rm2/trG 9uFbRGgZy8lQaA/UH2W0ESDbSFyrEP4bAxLeofXSALgasXnFh0WWtIDjOQuk9KDq0brq Euwg== X-Gm-Message-State: AOAM531mtyN8TDiDJPoadRL+JiSQLx3rxw1SQiDc04nrqhZaanYYXIWC /y/QFxC/xEgY9pMxgVSNvg1khWhWaoo0xgxCYUSZ7Q== X-Google-Smtp-Source: ABdhPJyiAR9TdBbuhnelWfP1ti2thf0+q9WpLfxdUaZskEcbXoxYjf1Inq7VahxEH/4Z+rYbayGvK2xRS/8FSHV7Hg0= X-Received: by 2002:a05:620a:1351:: with SMTP id c17mr6679766qkl.350.1613213925899; Sat, 13 Feb 2021 02:58:45 -0800 (PST) MIME-Version: 1.0 References: <20210211125717.GH308988@casper.infradead.org> <20210211132533.GI308988@casper.infradead.org> <20210211142630.GK308988@casper.infradead.org> <9cff0fbf-b6e7-1166-e4ba-d4573aef0c82@i-love.sakura.ne.jp> <20210212122207.GM308988@casper.infradead.org> <2b90c488-a6b9-2565-bd3a-e4f8bf8404e9@i-love.sakura.ne.jp> In-Reply-To: From: Dmitry Vyukov Date: Sat, 13 Feb 2021 11:58:34 +0100 Message-ID: Subject: Re: possible deadlock in start_this_handle (2) To: Michal Hocko Cc: Tetsuo Handa , Matthew Wilcox , Jan Kara , syzbot , Jan Kara , linux-ext4@vger.kernel.org, LKML , syzkaller-bugs , "Theodore Ts'o" , Linux-MM Content-Type: text/plain; charset="UTF-8" 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 Fri, Feb 12, 2021 at 4:43 PM Michal Hocko wrote: > > On Fri 12-02-21 21:58:15, Tetsuo Handa wrote: > > On 2021/02/12 21:30, Michal Hocko wrote: > > > On Fri 12-02-21 12:22:07, Matthew Wilcox wrote: > > >> On Fri, Feb 12, 2021 at 08:18:11PM +0900, Tetsuo Handa wrote: > > >>> On 2021/02/12 1:41, Michal Hocko wrote: > > >>>> But I suspect we have drifted away from the original issue. I thought > > >>>> that a simple check would help us narrow down this particular case and > > >>>> somebody messing up from the IRQ context didn't sound like a completely > > >>>> off. > > >>>> > > >>> > > >>> From my experience at https://lkml.kernel.org/r/201409192053.IHJ35462.JLOMOSOFFVtQFH@I-love.SAKURA.ne.jp , > > >>> I think we can replace direct PF_* manipulation with macros which do not receive "struct task_struct *" argument. > > >>> Since TASK_PFA_TEST()/TASK_PFA_SET()/TASK_PFA_CLEAR() are for manipulating PFA_* flags on a remote thread, we can > > >>> define similar ones for manipulating PF_* flags on current thread. Then, auditing dangerous users becomes easier. > > >> > > >> No, nobody is manipulating another task's GFP flags. > > > > > > Agreed. And nobody should be manipulating PF flags on remote tasks > > > either. > > > > > > > No. You are misunderstanding. The bug report above is an example of > > manipulating PF flags on remote tasks. > > The bug report you are referring to is ancient. And the cpuset code > doesn't touch task->flags for a long time. I haven't checked exactly but > it is years since regular and atomic flags have been separated unless I > misremember. > > > You say "nobody should", but the reality is "there indeed was". There > > might be unnoticed others. The point of this proposal is to make it > > possible to "find such unnoticed users who are manipulating PF flags > > on remote tasks". > > I am really confused what you are proposing here TBH and referring to an > ancient bug doesn't really help. task->flags are _explicitly_ documented > to be only used for _current_. Is it possible that somebody writes a > buggy code? Sure, should we build a whole infrastructure around that to > catch such a broken code? I am not really sure. One bug 6 years ago > doesn't sound like a good reason for that. Another similar one was just reported: https://syzkaller.appspot.com/bug?extid=1b2c6989ec12e467d65c WARNING: possible circular locking dependency detected 5.11.0-rc7-syzkaller #0 Not tainted ------------------------------------------------------ kswapd0/2232 is trying to acquire lock: ffff88801f552650 (sb_internal){.+.+}-{0:0}, at: evict+0x2ed/0x6b0 fs/inode.c:577 but task is already holding lock: ffffffff8be89240 (fs_reclaim){+.+.}-{0:0}, at: __fs_reclaim_acquire+0x0/0x30 mm/page_alloc.c:5195 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #3 (fs_reclaim){+.+.}-{0:0}: __fs_reclaim_acquire mm/page_alloc.c:4326 [inline] fs_reclaim_acquire+0x117/0x150 mm/page_alloc.c:4340 might_alloc include/linux/sched/mm.h:193 [inline] slab_pre_alloc_hook mm/slab.h:493 [inline] slab_alloc_node mm/slab.c:3221 [inline] kmem_cache_alloc_node_trace+0x48/0x520 mm/slab.c:3596 __do_kmalloc_node mm/slab.c:3618 [inline] __kmalloc_node+0x38/0x60 mm/slab.c:3626 kmalloc_node include/linux/slab.h:575 [inline] kvmalloc_node+0x61/0xf0 mm/util.c:587 kvmalloc include/linux/mm.h:781 [inline] ext4_xattr_inode_cache_find fs/ext4/xattr.c:1465 [inline] ext4_xattr_inode_lookup_create fs/ext4/xattr.c:1508 [inline] ext4_xattr_set_entry+0x1ce6/0x3780 fs/ext4/xattr.c:1649 ext4_xattr_ibody_set+0x78/0x2b0 fs/ext4/xattr.c:2224 ext4_xattr_set_handle+0x8f4/0x13e0 fs/ext4/xattr.c:2380 ext4_xattr_set+0x13a/0x340 fs/ext4/xattr.c:2493 __vfs_setxattr+0x10e/0x170 fs/xattr.c:177 __vfs_setxattr_noperm+0x11a/0x4c0 fs/xattr.c:208 __vfs_setxattr_locked+0x1bf/0x250 fs/xattr.c:266 vfs_setxattr+0x135/0x320 fs/xattr.c:291 setxattr+0x1ff/0x290 fs/xattr.c:553 path_setxattr+0x170/0x190 fs/xattr.c:572 __do_sys_setxattr fs/xattr.c:587 [inline] __se_sys_setxattr fs/xattr.c:583 [inline] __x64_sys_setxattr+0xc0/0x160 fs/xattr.c:583 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46