// For flags

CVE-2021-47460

ocfs2: fix data corruption after conversion from inline format

Severity Score

"-"
*CVSS v-

Exploit Likelihood

*EPSS

Affected Versions

*CPE

Public Exploits

0
*Multiple Sources

Exploited in Wild

-
*KEV

Decision

Track
*SSVC
Descriptions

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" \n -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.

[akpm@linux-foundation.org: fix whitespace, per Joseph]

En el kernel de Linux, se resolvió la siguiente vulnerabilidad: ocfs2: corrige la corrupción de datos después de la conversión desde el formato en línea. el commit 6dbf7bb55598 ("fs: No invalide los buffers de página en block_write_full_page()") descubrió un error latente en la conversión de ocfs2 desde el inodo en línea. formato a un formato de inodo normal. El código en ocfs2_convert_inline_data_to_extents() intenta poner a cero todo el clúster asignado para datos de archivos capturando, poniendo a cero y ensuciando todas las páginas que cubren este clúster. Sin embargo, estas páginas están más allá de i_size, por lo que el código de reescritura generalmente ignora estas páginas sucias y nunca se puso a cero ningún bloque en el disco. Este descuido se solucionó mediante el commit 693c241a5f6a ("ocfs2: No es necesario poner a cero las páginas después de i_size.") para la ruta de escritura estándar de ocfs2, la ruta de conversión en línea aparentemente se olvidó; el registro de confirmación también tiene un razonamiento por el cual la puesta a cero en realidad no es necesaria. Después de el commit 6dbf7bb55598, las cosas empeoraron ya que el código de reescritura dejó de invalidar los buffers en páginas más allá de i_size y, por lo tanto, estas páginas terminan con un bit PageDirty limpio pero con los búferes adjuntos a estas páginas todavía sucios. Entonces, cuando un archivo se convierte desde un formato en línea, se activa la reescritura y luego el archivo crece para que estas páginas se vuelvan válidas, se conserva el estado de suciedad no válido, mark_buffer_dirty() no hace nada en estas páginas (los búferes ya están sucios), excepto la página nunca se vuelve a escribir porque está limpio. Por lo tanto, los datos escritos en estas páginas se pierden una vez que se recuperan las páginas. El reproductor simple para el problema es: xfs_io -f -c "pwrite 0 2000" -c "pwrite 2000 2000" -c "fsync" \ -c "pwrite 4000 2000" ocfs2_file Después de desmontar y montar el fs nuevamente, puede observar que El final de 'ocfs2_file' ha perdido su contenido. Solucione el problema al no realizar la puesta a cero inútil durante la conversión desde el formato en línea de manera similar a como lo hace en la ruta de escritura estándar. [akpm@linux-foundation.org: arreglar espacios en blanco, según Joseph]

*Credits: N/A
CVSS Scores
Attack Vector
-
Attack Complexity
-
Privileges Required
-
User Interaction
-
Scope
-
Confidentiality
-
Integrity
-
Availability
-
* Common Vulnerability Scoring System
SSVC
  • Decision:Track
Exploitation
None
Automatable
No
Tech. Impact
Partial
* Organization's Worst-case Scenario
Timeline
  • 2024-05-22 CVE Reserved
  • 2024-05-22 CVE Published
  • 2024-05-22 EPSS Updated
  • 2024-08-04 CVE Updated
  • ---------- Exploited in Wild
  • ---------- KEV Due Date
  • ---------- First Exploit
CWE
CAPEC
Affected Vendors, Products, and Versions
Vendor Product Version Other Status
Vendor Product Version Other Status <-- --> Vendor Product Version Other Status
Linux
Search vendor "Linux"
Linux Kernel
Search vendor "Linux" for product "Linux Kernel"
>= 4.9.242 < 4.9.288
Search vendor "Linux" for product "Linux Kernel" and version " >= 4.9.242 < 4.9.288"
en
Affected
Linux
Search vendor "Linux"
Linux Kernel
Search vendor "Linux" for product "Linux Kernel"
>= 4.14.204 < 4.14.253
Search vendor "Linux" for product "Linux Kernel" and version " >= 4.14.204 < 4.14.253"
en
Affected
Linux
Search vendor "Linux"
Linux Kernel
Search vendor "Linux" for product "Linux Kernel"
>= 4.19.155 < 4.19.214
Search vendor "Linux" for product "Linux Kernel" and version " >= 4.19.155 < 4.19.214"
en
Affected
Linux
Search vendor "Linux"
Linux Kernel
Search vendor "Linux" for product "Linux Kernel"
>= 5.4.75 < 5.4.156
Search vendor "Linux" for product "Linux Kernel" and version " >= 5.4.75 < 5.4.156"
en
Affected
Linux
Search vendor "Linux"
Linux Kernel
Search vendor "Linux" for product "Linux Kernel"
>= 5.10 < 5.10.76
Search vendor "Linux" for product "Linux Kernel" and version " >= 5.10 < 5.10.76"
en
Affected
Linux
Search vendor "Linux"
Linux Kernel
Search vendor "Linux" for product "Linux Kernel"
>= 5.10 < 5.14.15
Search vendor "Linux" for product "Linux Kernel" and version " >= 5.10 < 5.14.15"
en
Affected
Linux
Search vendor "Linux"
Linux Kernel
Search vendor "Linux" for product "Linux Kernel"
>= 5.10 < 5.15
Search vendor "Linux" for product "Linux Kernel" and version " >= 5.10 < 5.15"
en
Affected
Linux
Search vendor "Linux"
Linux Kernel
Search vendor "Linux" for product "Linux Kernel"
5.9.5
Search vendor "Linux" for product "Linux Kernel" and version "5.9.5"
en
Affected