From: Michal Hocko <mhocko@suse.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: Jan Kara <jack@suse.cz>, Dmitry Vyukov <dvyukov@google.com>,
syzbot <syzbot+bfdded10ab7dcd7507ae@syzkaller.appspotmail.com>,
Jan Kara <jack@suse.com>,
linux-ext4@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>,
syzkaller-bugs <syzkaller-bugs@googlegroups.com>,
Theodore Ts'o <tytso@mit.edu>, Linux-MM <linux-mm@kvack.org>
Subject: Re: possible deadlock in start_this_handle (2)
Date: Thu, 11 Feb 2021 14:07:03 +0100 [thread overview]
Message-ID: <YCUr99//z8hJmnDH@dhcp22.suse.cz> (raw)
In-Reply-To: <20210211125717.GH308988@casper.infradead.org>
On Thu 11-02-21 12:57:17, Matthew Wilcox wrote:
> On Thu, Feb 11, 2021 at 01:34:48PM +0100, Michal Hocko wrote:
> > On Thu 11-02-21 13:10:20, Jan Kara wrote:
> > > On Thu 11-02-21 12:28:48, Dmitry Vyukov wrote:
> > > > On Thu, Feb 11, 2021 at 12:22 PM Dmitry Vyukov <dvyukov@google.com> wrote:
> > > > >
> > > > > On Thu, Feb 11, 2021 at 11:49 AM Jan Kara <jack@suse.cz> wrote:
> > > > > >
> > > > > > Hello,
> > > > > >
> > > > > > added mm guys to CC.
> > > > > >
> > > > > > On Wed 10-02-21 05:35:18, syzbot wrote:
> > > > > > > HEAD commit: 1e0d27fc Merge branch 'akpm' (patches from Andrew)
> > > > > > > git tree: upstream
> > > > > > > console output: https://syzkaller.appspot.com/x/log.txt?x=15cbce90d00000
> > > > > > > kernel config: https://syzkaller.appspot.com/x/.config?x=bd1f72220b2e57eb
> > > > > > > dashboard link: https://syzkaller.appspot.com/bug?extid=bfdded10ab7dcd7507ae
> > > > > > > userspace arch: i386
> > > > > > >
> > > > > > > Unfortunately, I don't have any reproducer for this issue yet.
> > > > > > >
> > > > > > > IMPORTANT: if you fix the issue, please add the following tag to the commit:
> > > > > > > Reported-by: syzbot+bfdded10ab7dcd7507ae@syzkaller.appspotmail.com
> > > > > > >
> > > > > > > ======================================================
> > > > > > > WARNING: possible circular locking dependency detected
> > > > > > > 5.11.0-rc6-syzkaller #0 Not tainted
> > > > > > > ------------------------------------------------------
> > > > > > > kswapd0/2246 is trying to acquire lock:
> > > > > > > ffff888041a988e0 (jbd2_handle){++++}-{0:0}, at: start_this_handle+0xf81/0x1380 fs/jbd2/transaction.c:444
> > > > > > >
> > > > > > > but task is already holding lock:
> > > > > > > ffffffff8be892c0 (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:
> > > > > > >
> > > > > > > -> #2 (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/slub.c:2817 [inline]
> > > > > > > __kmalloc_node+0x5f/0x430 mm/slub.c:4015
> > > > > > > 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
> > > > > > > ext4_xattr_user_set+0xbc/0x100 fs/ext4/xattr_user.c:40
> > > > > > > __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]
> > > > > > > __ia32_sys_setxattr+0xbc/0x150 fs/xattr.c:583
> > > > > > > do_syscall_32_irqs_on arch/x86/entry/common.c:77 [inline]
> > > > > > > __do_fast_syscall_32+0x56/0x80 arch/x86/entry/common.c:139
> > > > > > > do_fast_syscall_32+0x2f/0x70 arch/x86/entry/common.c:164
> > > > > > > entry_SYSENTER_compat_after_hwframe+0x4d/0x5c
> > > > > >
> > > > > > This stacktrace should never happen. ext4_xattr_set() starts a transaction.
> > > > > > That internally goes through start_this_handle() which calls:
> > > > > >
> > > > > > handle->saved_alloc_context = memalloc_nofs_save();
> > > > > >
> > > > > > and we restore the allocation context only in stop_this_handle() when
> > > > > > stopping the handle. And with this fs_reclaim_acquire() should remove
> > > > > > __GFP_FS from the mask and not call __fs_reclaim_acquire().
> > > > > >
> > > > > > Now I have no idea why something here didn't work out. Given we don't have
> > > > > > a reproducer it will be probably difficult to debug this. I'd note that
> > > > > > about year and half ago similar report happened (got autoclosed) so it may
> > > > > > be something real somewhere but it may also be just some HW glitch or
> > > > > > something like that.
> > > > >
> > > > > HW glitch is theoretically possible. But if we are considering such
> > > > > causes, I would say a kernel memory corruption is way more likely, we
> > > > > have hundreds of known memory-corruption-capable bugs open. In most
> > > > > cases they are caught by KASAN before doing silent damage. But KASAN
> > > > > can miss some cases.
> > > > >
> > > > > I see at least 4 existing bugs with similar stack:
> > > > > https://syzkaller.appspot.com/bug?extid=bfdded10ab7dcd7507ae
> > > > > https://syzkaller.appspot.com/bug?extid=a7ab8df042baaf42ae3c
> > > > > https://syzkaller.appspot.com/bug?id=c814a55a728493959328551c769ede4c8ff72aab
> > > > > https://syzkaller.appspot.com/bug?id=426ad9adca053dafcd698f3a48ad5406dccc972b
> > > > >
> > > > > All in all, I would not assume it's a memory corruption. When we had
> > > > > bugs that actually caused silent memory corruption, that caused a
> > > > > spike of random one-time crashes all over the kernel. This does not
> > > > > look like it.
> > > >
> > > > I wonder if memalloc_nofs_save (or any other manipulation of
> > > > current->flags) could have been invoked from interrupt context? I
> > > > think it could cause the failure mode we observe (extremely rare
> > > > disappearing flags). It may be useful to add a check for task context
> > > > there.
> > >
> > > That's an interesting idea. I'm not sure if anything does manipulate
> > > current->flags from inside an interrupt (definitely memalloc_nofs_save()
> > > doesn't seem to be) but I'd think that in fully preemtible kernel,
> > > scheduler could preempt the task inside memalloc_nofs_save() and the
> > > current->flags manipulation could also clash with a manipulation of these
> > > flags by the scheduler if there's any?
> >
> > current->flags should be always manipulated from the user context. But
> > who knows maybe there is a bug and some interrupt handler is calling it.
> > This should be easy to catch no?
>
> Why would it matter if it were?
I was thinking about a clobbered state because updates to ->flags are
not atomic because this shouldn't ever be updated concurrently. So maybe
a racing interrupt could corrupt the flags state?
--
Michal Hocko
SUSE Labs
next prev parent reply other threads:[~2021-02-11 13:07 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <000000000000563a0205bafb7970@google.com>
2021-02-11 10:49 ` possible deadlock in start_this_handle (2) Jan Kara
2021-02-11 10:55 ` Michal Hocko
2021-02-11 11:22 ` Dmitry Vyukov
2021-02-11 11:28 ` Dmitry Vyukov
2021-02-11 12:10 ` Jan Kara
2021-02-11 12:34 ` Michal Hocko
2021-02-11 12:57 ` Matthew Wilcox
2021-02-11 13:07 ` Michal Hocko [this message]
2021-02-11 13:25 ` Matthew Wilcox
2021-02-11 14:20 ` Michal Hocko
2021-02-11 14:26 ` Matthew Wilcox
2021-02-11 16:41 ` Michal Hocko
2021-02-12 11:18 ` Tetsuo Handa
2021-02-12 12:22 ` Matthew Wilcox
2021-02-12 12:30 ` Michal Hocko
2021-02-12 12:58 ` Tetsuo Handa
2021-02-12 13:12 ` Michal Hocko
2021-02-12 13:34 ` Tetsuo Handa
2021-02-12 15:43 ` Michal Hocko
2021-02-13 10:58 ` Dmitry Vyukov
2021-02-11 13:18 ` Dmitry Vyukov
2021-02-11 11:46 ` Jan Kara
2021-02-13 14:26 ` Tetsuo Handa
2021-02-15 12:45 ` Jan Kara
2021-02-15 14:06 ` Tetsuo Handa
2021-02-15 14:29 ` Jan Kara
2021-02-19 10:15 ` Tetsuo Handa
2021-02-19 17:22 ` harshad shirwadkar
2021-03-20 10:02 ` Tetsuo Handa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YCUr99//z8hJmnDH@dhcp22.suse.cz \
--to=mhocko@suse.com \
--cc=dvyukov@google.com \
--cc=jack@suse.com \
--cc=jack@suse.cz \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=syzbot+bfdded10ab7dcd7507ae@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
--cc=tytso@mit.edu \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).