linux/fs/quota
Jan Kara 1362f4ea20 quota: Fix race between dqput() and dquot_scan_active()
Currently last dqput() can race with dquot_scan_active() causing it to
call callback for an already deactivated dquot. The race is as follows:

CPU1					CPU2
  dqput()
    spin_lock(&dq_list_lock);
    if (atomic_read(&dquot->dq_count) > 1) {
     - not taken
    if (test_bit(DQ_ACTIVE_B, &dquot->dq_flags)) {
      spin_unlock(&dq_list_lock);
      ->release_dquot(dquot);
        if (atomic_read(&dquot->dq_count) > 1)
         - not taken
					  dquot_scan_active()
					    spin_lock(&dq_list_lock);
					    if (!test_bit(DQ_ACTIVE_B, &dquot->dq_flags))
					     - not taken
					    atomic_inc(&dquot->dq_count);
					    spin_unlock(&dq_list_lock);
        - proceeds to release dquot
					    ret = fn(dquot, priv);
					     - called for inactive dquot

Fix the problem by making sure possible ->release_dquot() is finished by
the time we call the callback and new calls to it will notice reference
dquot_scan_active() has taken and bail out.

CC: stable@vger.kernel.org # >= 2.6.29
Signed-off-by: Jan Kara <jack@suse.cz>
2014-02-20 21:57:04 +01:00
..
compat.c quota: split out compat_sys_quotactl support from quota.c 2010-03-05 00:20:25 +01:00
dquot.c quota: Fix race between dqput() and dquot_scan_active() 2014-02-20 21:57:04 +01:00
Kconfig quota: Make QUOTACTL config be selected by its users 2010-10-05 12:16:37 +02:00
kqid.c userns: Implement struct kqid 2012-09-18 01:01:38 -07:00
Makefile userns: Implement struct kqid 2012-09-18 01:01:38 -07:00
netlink.c genetlink: make multicast groups const, prevent abuse 2013-11-19 16:39:06 -05:00
quota_tree.c userns: Convert struct dquot dq_id to be a struct kqid 2012-09-18 01:01:41 -07:00
quota_tree.h quota: Change quota error message to print out disk and function name 2010-07-21 16:05:58 +02:00
quota_v1.c userns: Convert struct dquot dq_id to be a struct kqid 2012-09-18 01:01:41 -07:00
quota_v2.c userns: Convert struct dquot dq_id to be a struct kqid 2012-09-18 01:01:41 -07:00
quota.c quota: info leak in quota_getquota() 2013-11-04 14:16:55 +01:00
quotaio_v1.h
quotaio_v2.h quota: Implement quota format with 64-bit space and inode limits 2009-12-10 15:02:54 +01:00