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: <20230626130957.kvfli23djxc2opkq@quack3>
Date:   Mon, 26 Jun 2023 15:09:57 +0200
From:   Jan Kara <jack@...e.cz>
To:     Baokun Li <libaokun1@...wei.com>
Cc:     Jan Kara <jack@...e.cz>, linux-fsdevel@...r.kernel.org,
        linux-ext4@...r.kernel.org, linux-kernel@...r.kernel.org,
        yi.zhang@...wei.com, yangerkun@...wei.com, chengzhihao1@...wei.com,
        yukuai3@...wei.com
Subject: Re: [PATCH] quota: fix race condition between dqput() and
 dquot_mark_dquot_dirty()

Hello!

On Sun 25-06-23 15:56:10, Baokun Li wrote:
> > > I think we can simply focus on the race between the DQ_ACTIVE_B flag and
> > > the DQ_MOD_B flag, which is the core problem, because the same quota
> > > should not have both flags. These two flags are protected by dq_list_lock
> > > and dquot->dq_lock respectively, so it makes sense to add a
> > > wait_on_dquot() to ensure the accuracy of DQ_ACTIVE_B.
> > But the fundamental problem is not only the race with DQ_MOD_B setting. The
> > dquot structure can be completely freed by the time
> > dquot_claim_space_nodirty() calls dquot_mark_dquot_dirty() on it. That's
> > why I think making __dquot_transfer() obey dquot_srcu rules is the right
> > solution.
> Yes, now I also think that making __dquot_transfer() obey dquot_srcu
> rules is a better solution. But with inode->i_lock protection, why would
> the dquot structure be completely freed?

Well, when dquot_claim_space_nodirty() calls mark_all_dquot_dirty() it does
not hold any locks (only dquot_srcu). So nothing prevents dquot_transfer()
to go, swap dquot structure pointers and drop dquot references and after
that mark_all_dquot_dirty() can use a stale pointer to call
mark_dquot_dirty() on already freed memory.

								Honza
-- 
Jan Kara <jack@...e.com>
SUSE Labs, CR

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ