Categories
CVE-2023-52896

btrfs: fix race between quota rescan and disable leading to NULL pointer deref

Summary

btrfs: fix race between quota rescan and disable leading to NULL pointer deref

Original description

The description as published by the source.

In the Linux kernel, the following vulnerability has been resolved:

btrfs: fix race between quota rescan and disable leading to NULL pointer deref

If we have one task trying to start the quota rescan worker while another
one is trying to disable quotas, we can end up hitting a race that results
in the quota rescan worker doing a NULL pointer dereference. The steps for
this are the following:

  1. Quotas are enabled;

  2. Task A calls the quota rescan ioctl and enters btrfs_qgroup_rescan().
    It calls qgroup_rescan_init() which returns 0 (success) and then joins a
    transaction and commits it;

  3. Task B calls the quota disable ioctl and enters btrfs_quota_disable().
    It clears the bit BTRFS_FS_QUOTA_ENABLED from fs_info->flags and calls
    btrfs_qgroup_wait_for_completion(), which returns immediately since the
    rescan worker is not yet running.
    Then it starts a transaction and locks fs_info->qgroup_ioctl_lock;

  4. Task A queues the rescan worker, by calling btrfs_queue_work();

  5. The rescan worker starts, and calls rescan_should_stop() at the start
    of its while loop, which results in 0 iterations of the loop, since
    the flag BTRFS_FS_QUOTA_ENABLED was cleared from fs_info->flags by
    task B at step 3);

  6. Task B sets fs_info->quota_root to NULL;

  7. The rescan worker tries to start a transaction and uses
    fs_info->quota_root as the root argument for btrfs_start_transaction().
    This results in a NULL pointer dereference down the call chain of
    btrfs_star…

Source: OSV.dev (Open Source Vulnerabilities) NVD OSV

Affected packages

Linux Kernel
[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"5.4.230"}]},{"type":"ECOSYSTEM","events":[{"introduced":"5.5.0"},{"fixed":"5.10.165"}]},{"type":"ECOSYSTEM","events":[{"introduced":"5.11.0"},{"fixed":"5.15.90"}]},{"type":"ECOSYSTEM","events":[{"introduced":"5.16.0"},{"fixed":"6.1.8"}]}]

Fix status by distribution

Fixed packages published by each distribution for this CVE

References

We use cookies for analytics and ad measurement. This setting applies to all Game co., Ltd. sites. Details