lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CACOAw_yupuz+Xx-z9V0UaExuARHd8H9rruWCa2yj5-mgkeuUtQ@mail.gmail.com>
Date:   Thu, 21 Oct 2021 09:44:33 -0700
From:   Daeho Jeong <daeho43@...il.com>
To:     Chao Yu <chao@...nel.org>
Cc:     linux-kernel@...r.kernel.org,
        linux-f2fs-devel@...ts.sourceforge.net, kernel-team@...roid.com,
        Daeho Jeong <daehojeong@...gle.com>
Subject: Re: [f2fs-dev] [PATCH] f2fs: remove circular locking between
 sb_internal and fs_reclaim

There is a deadlock between sb_internal lock (sb_start_intwrite()) and
dquot related lock.
It's because we call f2fs_truncate(), which eventually calls
dquot_initialize(), while holding sb_internal lock.
So, I called dquot_initialize() in advance to make the 2nd calling of
it in f2fs_truncate() ineffective.
This is similar with the thing in f2fs_evict_inode() in inode.c

Thanks,

On Thu, Oct 21, 2021 at 5:11 AM Chao Yu <chao@...nel.org> wrote:
>
> On 2021/10/15 3:05, Daeho Jeong wrote:
> > From: Daeho Jeong <daehojeong@...gle.com>
> >
> > We detected the below circular locking dependency between sb_internal
> > and fs_reclaim. So, removed it by calling dquot_initialize() before
> > sb_start_intwrite().
> >
> >   ======================================================
> >   WARNING: possible circular locking dependency detected
> >   ------------------------------------------------------
> >   kswapd0/133 is trying to acquire lock:
> > ffffff80d5fb9680 (sb_internal#2){.+.+}-{0:0}, at: evict+0xd4/0x2f8
> >
> > but task is already holding lock:
> > ffffffda597c93a8 (fs_reclaim){+.+.}-{0:0}, at:
> > __fs_reclaim_acquire+0x4/0x50
> >
> > which lock already depends on the new lock.
> > ...
> > other info that might help us debug this:
> >
> >   Chain exists of:
> >
> > sb_internal#2 --> &s->s_dquot.dqio_sem --> fs_reclaim
> >
> >    Possible unsafe locking scenario:
> >
> >          CPU0                    CPU1
> >          ----                    ----
> >     lock(fs_reclaim);
> >                                  lock(&s->s_dquot.dqio_sem);
> >                                  lock(fs_reclaim);
> >     lock(sb_internal#2);
>
> Sorry, I still didn't get the root cause of this deadlock issue, could
> you please explain more about this?
>
> And why calling dquot_initialize() in drop_inode() could break the
> circular locking dependency?
>
> Thanks,
>
> >
> > Signed-off-by: Daeho Jeong <daehojeong@...gle.com>
> > ---
> >   fs/f2fs/super.c | 2 ++
> >   1 file changed, 2 insertions(+)
> >
> > diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
> > index 86eeb019cc52..a133932333c5 100644
> > --- a/fs/f2fs/super.c
> > +++ b/fs/f2fs/super.c
> > @@ -1370,6 +1370,8 @@ static int f2fs_drop_inode(struct inode *inode)
> >                       /* should remain fi->extent_tree for writepage */
> >                       f2fs_destroy_extent_node(inode);
> >
> > +                     dquot_initialize(inode);
> > +
> >                       sb_start_intwrite(inode->i_sb);
> >                       f2fs_i_size_write(inode, 0);
> >
> >

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ