Lucene search

K
cve416baaa9-dc9f-4396-8d5f-8c081fb06d67CVE-2021-47460
HistoryMay 22, 2024 - 7:15 a.m.

CVE-2021-47460

2024-05-2207:15:10
416baaa9-dc9f-4396-8d5f-8c081fb06d67
web.nvd.nist.gov
30
linux kernel
ocfs2
data corruption

7 High

AI Score

Confidence

High

0.0004 Low

EPSS

Percentile

10.3%

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

ocfs2: fix data corruption after conversion from inline format

Commit 6dbf7bb55598 (“fs: Don’t invalidate page buffers in
block_write_full_page()”) uncovered a latent bug in ocfs2 conversion
from inline inode format to a normal inode format.

The code in ocfs2_convert_inline_data_to_extents() attempts to zero out
the whole cluster allocated for file data by grabbing, zeroing, and
dirtying all pages covering this cluster. However these pages are
beyond i_size, thus writeback code generally ignores these dirty pages
and no blocks were ever actually zeroed on the disk.

This oversight was fixed by commit 693c241a5f6a (“ocfs2: No need to zero
pages past i_size.”) for standard ocfs2 write path, inline conversion
path was apparently forgotten; the commit log also has a reasoning why
the zeroing actually is not needed.

After commit 6dbf7bb55598, things became worse as writeback code stopped
invalidating buffers on pages beyond i_size and thus these pages end up
with clean PageDirty bit but with buffers attached to these pages being
still dirty. So when a file is converted from inline format, then
writeback triggers, and then the file is grown so that these pages
become valid, the invalid dirtiness state is preserved,
mark_buffer_dirty() does nothing on these pages (buffers are already
dirty) but page is never written back because it is clean. So data
written to these pages is lost once pages are reclaimed.

Simple reproducer for the problem is:

xfs_io -f -c “pwrite 0 2000” -c “pwrite 2000 2000” -c “fsync”
-c “pwrite 4000 2000” ocfs2_file

After unmounting and mounting the fs again, you can observe that end of
‘ocfs2_file’ has lost its contents.

Fix the problem by not doing the pointless zeroing during conversion
from inline format similarly as in the standard write path.

[[email protected]: fix whitespace, per Joseph]

Affected configurations

Vulners
Node
linuxlinux_kernelRange5.104.9.288
OR
linuxlinux_kernelRange4.10.04.14.253
OR
linuxlinux_kernelRange4.15.04.19.214
OR
linuxlinux_kernelRange4.20.05.4.156
OR
linuxlinux_kernelRange5.5.05.10.76
OR
linuxlinux_kernelRange5.11.05.14.15
OR
linuxlinux_kernelRange5.15.0

CNA Affected

[
  {
    "product": "Linux",
    "vendor": "Linux",
    "defaultStatus": "unaffected",
    "repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git",
    "programFiles": [
      "fs/ocfs2/alloc.c"
    ],
    "versions": [
      {
        "version": "acef5107e2ea",
        "lessThan": "560edd14de2b",
        "status": "affected",
        "versionType": "git"
      },
      {
        "version": "7ed80e77c908",
        "lessThan": "8e6bfb4f7016",
        "status": "affected",
        "versionType": "git"
      },
      {
        "version": "7ce2b16bad2c",
        "lessThan": "a3a089c241cd",
        "status": "affected",
        "versionType": "git"
      },
      {
        "version": "f8a6a2ed4b7d",
        "lessThan": "b05caf023b14",
        "status": "affected",
        "versionType": "git"
      },
      {
        "version": "6dbf7bb55598",
        "lessThan": "f1b98569e81c",
        "status": "affected",
        "versionType": "git"
      },
      {
        "version": "6dbf7bb55598",
        "lessThan": "fa9b6b6c953e",
        "status": "affected",
        "versionType": "git"
      },
      {
        "version": "6dbf7bb55598",
        "lessThan": "5314454ea3ff",
        "status": "affected",
        "versionType": "git"
      }
    ]
  },
  {
    "product": "Linux",
    "vendor": "Linux",
    "defaultStatus": "affected",
    "repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git",
    "programFiles": [
      "fs/ocfs2/alloc.c"
    ],
    "versions": [
      {
        "version": "5.10",
        "status": "affected"
      },
      {
        "version": "0",
        "lessThan": "5.10",
        "status": "unaffected",
        "versionType": "custom"
      },
      {
        "version": "4.9.288",
        "lessThanOrEqual": "4.9.*",
        "status": "unaffected",
        "versionType": "custom"
      },
      {
        "version": "4.14.253",
        "lessThanOrEqual": "4.14.*",
        "status": "unaffected",
        "versionType": "custom"
      },
      {
        "version": "4.19.214",
        "lessThanOrEqual": "4.19.*",
        "status": "unaffected",
        "versionType": "custom"
      },
      {
        "version": "5.4.156",
        "lessThanOrEqual": "5.4.*",
        "status": "unaffected",
        "versionType": "custom"
      },
      {
        "version": "5.10.76",
        "lessThanOrEqual": "5.10.*",
        "status": "unaffected",
        "versionType": "custom"
      },
      {
        "version": "5.14.15",
        "lessThanOrEqual": "5.14.*",
        "status": "unaffected",
        "versionType": "custom"
      },
      {
        "version": "5.15",
        "lessThanOrEqual": "*",
        "status": "unaffected",
        "versionType": "original_commit_for_fix"
      }
    ]
  }
]

7 High

AI Score

Confidence

High

0.0004 Low

EPSS

Percentile

10.3%