Skip to content
Heist/ feed
Back to feed
MediumFix available

btrfs: fix deadlock between concurrent dio writes when low on free data space

Type: advisorySources: OSV

In the Linux kernel, the following vulnerability has been resolved: btrfs: fix deadlock between concurrent dio writes when low on free data space When reserving data space for a direct IO write we can end up deadlocking if we have multiple tasks attempting a write to the same file range, there are multiple extents covered by that file range, we are low on available space for data and the writes don't expand the inode's i_size. The deadlock can happen like this: 1) We have a file with an i_size of 1M, at offset 0 it has an extent with a size of 128K and at offset 128K it has another extent also with a size of 128K; 2) Task A does a direct IO write against file range [0, 256K), and because the write is within the i_size boundary, it takes the inode's lock (VFS level) in shared mode; 3) Task A locks the file range [0, 256K) at btrfs_dio_iomap_begin(), and then gets the extent map for the extent covering the range [0, 128K). At btrfs_get_blocks_direct_write(), it creates an ordered extent for that file range ([0, 128K)); 4) Before returning from btrfs_dio_iomap_begin(), it unlocks the file range [0, 256K); 5) Task A executes btrfs_dio_iomap_begin() again, this time for the file range [128K, 256K), and locks the file range [128K, 256K); 6) Task B starts a direct IO write against file range [0, 256K) as well. It also locks the inode in shared mode, as it's within the i_size limit, and then tries to lock file range [0, 256K). It is able to lock the subrange [0, 128K) but then blocks

Products
Kernel
Affected versions
Not specified
Fixed versions
5.18.3
CVEs
CVE-2022-49547
Confirmed fixed CVEs
Not specified
Updated in this feed
3 Nov 2026, 07:07 UTC · Revision 1

Source evidence

btrfs: fix deadlock between concurrent dio writes when low on free data space

core-osv · Original source

Published 26 Feb 2025, 02:13 UTC

In the Linux kernel, the following vulnerability has been resolved: btrfs: fix deadlock between concurrent dio writes when low on free data space When reserving data space for a direct IO write we can end up deadlocking if we have multiple tasks attempting a write to the same file range, there are multiple extents covered by that file range, we are low on available space for data and the writes don't expand the inode's i_size. The deadlock can happen like this: 1) We have a file with an i_size of 1M, at offset 0 it has an extent with a size of 128K and at offset 128K it has another extent also with a size of 128K; 2) Task A does a direct IO write against file range [0, 256K), and because the write is within the i_size boundary, it takes the inode's lock (VFS level) in shared mode; 3) Task A locks the file range [0, 256K) at btrfs_dio_iomap_begin(), and then gets the extent map for the extent covering the range [0, 128K). At btrfs_get_blocks_direct_write(), it creates an ordered extent for that file range ([0, 128K)); 4) Before returning from btrfs_dio_iomap_begin(), it unlocks the file range [0, 256K); 5) Task A executes btrfs_dio_iomap_begin() again, this time for the file range [128K, 256K), and locks the file range [128K, 256K); 6) Task B starts a direct IO write against file range [0, 256K) as well. It also locks the inode in shared mode, as it's within the i_size limit, and then tries to lock file range [0, 256K). It is able to lock the subrange [0, 128K) but then blocks

osv:CVE-2022-49547

Kernel

Fixed versions: 5.18.3

Complete source record
{
  "id": "b199a71328e18333ec8a275742dfb8a76b7ca90095e8abbf1fd3da3b4154ff06",
  "url": "https://osv.dev/vulnerability/CVE-2022-49547",
  "method": "structured",
  "payload": {
    "kind": "advisory",
    "title": "btrfs: fix deadlock between concurrent dio writes when low on free data space",
    "summary": "In the Linux kernel, the following vulnerability has been resolved: btrfs: fix deadlock between concurrent dio writes when low on free data space When reserving data space for a direct IO write we can end up deadlocking if we have multiple tasks attempting a write to the same file range, there are multiple extents covered by that file range, we are low on available space for data and the writes don't expand the inode's i_size. The deadlock can happen like this: 1) We have a file with an i_size of 1M, at offset 0 it has an extent with a size of 128K and at offset 128K it has another extent also with a size of 128K; 2) Task A does a direct IO write against file range [0, 256K), and because the write is within the i_size boundary, it takes the inode's lock (VFS level) in shared mode; 3) Task A locks the file range [0, 256K) at btrfs_dio_iomap_begin(), and then gets the extent map for the extent covering the range [0, 128K). At btrfs_get_blocks_direct_write(), it creates an ordered extent for that file range ([0, 128K)); 4) Before returning from btrfs_dio_iomap_begin(), it unlocks the file range [0, 256K); 5) Task A executes btrfs_dio_iomap_begin() again, this time for the file range [128K, 256K), and locks the file range [128K, 256K); 6) Task B starts a direct IO write against file range [0, 256K) as well. It also locks the inode in shared mode, as it's within the i_size limit, and then tries to lock file range [0, 256K). It is able to lock the subrange [0, 128K) but then blocks",
    "evidence": "osv:CVE-2022-49547",
    "products": [
      {
        "name": {
          "value": "Kernel",
          "evidence": "/affected/1/package/name"
        },
        "prerequisites": [],
        "fixed_versions": [
          {
            "value": "5.18.3",
            "evidence": "/affected/1/ranges"
          }
        ],
        "affected_versions": []
      }
    ],
    "severity": "medium",
    "structured": {
      "id": "CVE-2022-49547",
      "aliases": [
        "CVE-2022-49547"
      ],
      "metrics": [
        {
          "type": "CVSS_V3",
          "score": "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H"
        }
      ],
      "affected": [
        {
          "ranges": [
            {
              "repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git",
              "type": "GIT",
              "events": [
                {
                  "introduced": "f0bfa76a11e93d0fe2c896fcb566568c5e8b5d3f"
                },
                {
                  "fixed": "cfae6f765b3c40882ee90dae8fbf9325c8de9c35"
                },
                {
                  "fixed": "f5585f4f0ef5b17026bbd60fbff6fcc91b99d5bf"
                }
              ]
            },
            {
              "repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git",
              "type": "GIT",
              "events": [
                {
                  "introduced": "5.15.27"
                },
                {
                  "fixed": "5.16"
                }
              ]
            },
            {
              "repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git",
              "type": "GIT",
              "events": [
                {
                  "introduced": "5.16.13"
                },
                {
                  "fixed": "5.17"
                }
              ]
            },
            {
              "repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git",
              "type": "GIT",
              "events": [
                {
                  "introduced": "5afd80c393f4e87451f14eefb7f2f24daf434e06"
                }
              ]
            },
            {
              "repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git",
              "type": "GIT",
              "events": [
                {
                  "introduced": "96f1be29492d9e2fb97bb27f824478ab8cd3ab86"
                }
              ]
            }
          ],
          "versions": [
            "v5.15.223",
            "v5.15.222",
            "v5.15.221",
            "v5.15.220",
            "v5.15.219",
            "v5.15.218",
            "v5.15.217",
            "v5.15.216",
            "v5.15.215",
            "v5.15.214",
            "v5.15.213",
            "v5.15.212",
            "v5.15.211",
            "v5.15.210",
            "v5.15.209",
            "v5.15.208",
            "v5.15.207",
            "v5.15.206",
            "v5.15.205",
            "v5.15.204",
            "v5.15.203",
            "v5.15.202",
            "v5.15.201",
            "v5.15.200",
            "v5.15.199",
            "v5.15.198",
            "v5.15.197",
            "v5.15.196",
            "v5.15.195",
            "v5.15.194",
            "v5.15.193",
            "v5.15.192",
            "v5.15.191",
            "v5.15.190",
            "v5.15.189",
            "v5.15.188",
            "v5.15.187",
            "v5.15.186",
            "v5.15.185",
            "v5.15.184",
            "v5.15.183",
            "v5.15.182",
            "v5.15.181",
            "v5.15.180",
            "v5.15.179",
            "v5.15.178",
            "v5.15.177",
            "v5.15.176",
            "v5.15.175",
            "v5.15.174",
            "v5.15.173",
            "v5.15.172",
            "v5.15.171",
            "v5.15.170",
            "v5.15.169",
            "v5.15.168",
            "v5.15.167",
            "v5.15.166",
            "v5.15.165",
            "v5.15.164",
            "v5.15.163",
            "v5.15.162",
            "v5.15.161",
            "v5.15.160",
            "v5.15.159",
            "v5.15.158",
            "v5.15.157",
            "v5.15.156",
            "v5.15.155",
            "v5.15.154",
            "v5.15.153",
            "v5.15.152",
            "v5.15.151",
            "v5.15.150",
            "v5.15.149",
            "v5.15.148",
            "v5.15.147",
            "v5.15.146",
            "v5.15.145",
            "v5.15.144",
            "v5.15.143",
            "v5.15.142",
            "v5.15.141",
            "v5.15.140",
            "v5.15.139",
            "v5.15.138",
            "v5.15.137",
            "v5.15.136",
            "v5.15.135",
            "v5.15.134",
            "v5.15.133",
            "v5.15.132",
            "v5.15.131",
            "v5.15.130",
            "v5.15.129",
            "v5.15.128",
            "v5.15.127",
            "v5.15.126",
            "v5.15.125",
            "v5.15.124",
            "v5.15.123",
            "v5.15.122",
            "v5.15.121",
            "v5.15.120",
            "v5.15.119",
            "v5.15.118",
            "v5.15.117",
            "v5.15.116",
            "v5.15.115",
            "v5.15.114",
            "v5.15.113",
            "v5.15.112",
            "v5.15.111",
            "v5.15.110",
            "v5.15.109",
            "v5.15.108",
            "v5.15.107",
            "v5.15.106",
            "v5.15.105",
            "v5.15.104",
            "v5.15.103",
            "v5.15.102",
            "v5.15.101",
            "v5.15.100",
            "v5.15.99",
            "v5.15.98",
            "v5.15.97",
            "v5.15.96",
            "v5.15.95",
            "v5.15.94",
            "v5.15.93",
            "v5.15.92",
            "v5.15.91",
            "v5.15.90",
            "v5.15.89",
            "v5.15.88",
            "v5.15.87",
            "v5.15.86",
            "v5.15.85",
            "v5.15.84",
            "v5.15.83",
            "v5.15.82",
            "v5.15.81",
            "v5.15.80",
            "v5.15.79",
            "v5.15.78",
            "v5.15.77",
            "v5.15.76",
            "v5.15.75",
            "v5.15.74",
            "v5.15.73",
            "v5.15.72",
            "v5.15.71",
            "v5.15.70",
            "v5.15.69",
            "v5.15.68",
            "v5.15.67",
            "v5.15.66",
            "v5.15.65",
            "v5.15.64",
            "v5.15.63",
            "v5.15.62",
            "v5.15.61",
            "v5.15.60",
            "v5.15.59",
            "v5.15.58",
            "v5.15.57",
            "v5.15.56",
            "v5.15.55",
            "v5.15.54",
            "v5.15.53",
            "v5.15.52",
            "v5.15.51",
            "v5.15.50",
            "v5.15.49",
            "v5.15.48",
            "v5.15.47",
            "v5.15.46",
            "v5.15.45",
            "v5.15.44",
            "v5.15.43",
            "v5.15.42",
            "v5.15.41",
            "v5.15.40",
            "v5.15.39",
            "v5.15.38",
            "v5.15.37",
            "v5.15.36",
            "v5.15.35",
            "v5.15.34",
            "v5.15.33",
            "v5.15.32",
            "v5.15.31",
            "v5.15.30",
            "v5.15.29",
            "v5.15.28",
            "v5.15.27",
            "v5.16.20",
            "v5.16.19",
            "v5.16.18",
            "v5.16.17",
            "v5.16.16",
            "v5.16.15",
            "v5.16.14",
            "v5.16.13"
          ],
          "database_specific": {
            "source": "https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2022-49547.json"
          }
        },
        {
          "ranges": [
            {
              "type": "ECOSYSTEM",
              "events": [
                {
                  "introduced": "5.17.0"
                },
                {
                  "fixed": "5.18.3"
                }
              ]
            }
          ],
          "package": {
            "name": "Kernel",
            "ecosystem": "Linux"
          },
          "database_specific": {
            "source": "https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2022-49547.json"
          }
        }
      ],
      "modified": "2026-10-28T02:30:26.720435101Z",
      "provider": "osv",
      "references": [
        "https://git.kernel.org/stable/c/cfae6f765b3c40882ee90dae8fbf9325c8de9c35",
        "https://git.kernel.org/stable/c/f5585f4f0ef5b17026bbd60fbff6fcc91b99d5bf",
        "https://github.com/CVEProject/cvelistV5/tree/main/cves/2022/49xxx/CVE-2022-49547.json",
        "https://nvd.nist.gov/vuln/detail/CVE-2022-49547",
        "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git"
      ],
      "provider_metadata": {
        "cna_assigner": "Linux",
        "osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2022/49xxx/CVE-2022-49547.json"
      }
    },
    "related_cves": [
      {
        "value": "CVE-2022-49547",
        "evidence": "/id"
      }
    ],
    "security_relevant": true,
    "severity_evidence": "/severity/0/score"
  },
  "source_id": "core-osv",
  "document_id": 493209,
  "published_at": "2025-02-26T02:13:59.343+00:00"
}