Files
android_kernel_fxtec_sm6115/include/linux
Jan Kara a86a8247a7 quota: Fix race of dquot_scan_active() with quota deactivation
[ Upstream commit e93ab401da4b2e2c1b8ef2424de2f238d51c8b2d ]

dquot_scan_active() can race with quota deactivation in
quota_release_workfn() like:

  CPU0 (quota_release_workfn)         CPU1 (dquot_scan_active)
  ==============================      ==============================
  spin_lock(&dq_list_lock);
  list_replace_init(
    &releasing_dquots, &rls_head);
    /* dquot X on rls_head,
       dq_count == 0,
       DQ_ACTIVE_B still set */
  spin_unlock(&dq_list_lock);
  synchronize_srcu(&dquot_srcu);
                                      spin_lock(&dq_list_lock);
                                      list_for_each_entry(dquot,
                                          &inuse_list, dq_inuse) {
                                        /* finds dquot X */
                                        dquot_active(X) -> true
                                        atomic_inc(&X->dq_count);
                                      }
                                      spin_unlock(&dq_list_lock);
  spin_lock(&dq_list_lock);
  dquot = list_first_entry(&rls_head);
  WARN_ON_ONCE(atomic_read(&dquot->dq_count));

The problem is not only a cosmetic one as under memory pressure the
caller of dquot_scan_active() can end up working on freed dquot.

Fix the problem by making sure the dquot is removed from releasing list
when we acquire a reference to it.

Fixes: 869b6ea1609f ("quota: Fix slow quotaoff")
Reported-by: Sam Sun <samsun1006219@gmail.com>
Link: https://lore.kernel.org/all/CAEkJfYPTt3uP1vAYnQ5V2ZWn5O9PLhhGi5HbOcAzyP9vbXyjeg@mail.gmail.com
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Ulrich Hecht <uli@kernel.org>
2026-06-29 10:46:03 +02:00
..
2026-04-09 14:44:43 +08:00
2024-02-23 08:12:39 +01:00
2023-08-08 19:49:17 +02:00
2023-12-20 15:38:01 +01:00
2021-12-08 08:50:13 +01:00
2025-12-22 04:34:05 +01:00
2024-04-13 12:50:14 +02:00
2026-01-29 12:09:34 +08:00
2022-10-26 13:19:35 +02:00
2022-08-25 11:15:23 +02:00
2023-09-23 10:47:59 +02:00
2021-06-30 08:48:18 -04:00
2023-06-21 15:39:57 +02:00
2023-02-22 12:47:17 +01:00
2025-09-16 13:55:10 +02:00
2023-11-28 16:46:33 +00:00
2023-10-25 11:16:20 +02:00
2021-12-14 10:18:04 +01:00
2024-07-05 09:00:35 +02:00
2024-02-23 08:12:39 +01:00
2021-12-14 10:18:06 +01:00