CVE-2021-4155

Description

A data leak flaw was found in the way XFS_IOC_ALLOCSP IOCTL in the XFS filesystem allowed for size increase of files with unaligned size. A local attacker could use this flaw to leak data on the XFS filesystem otherwise not accessible to them.

Mitigation

This issue can be mitigated by ensuring xfs_alloc_file_space is not called with "0" as an argument.

This can be done with a SystemTap script (which resets "0" with XFS_BMAPI_PREALLOC), below are the steps:

1) Save the following script in a 'CVE-2021-4155.stp' file

--- On Red Hat Enterprise Linux 6 ---
probe module("xfs").function("xfs_alloc_file_space") {
if ($alloc_type == 0)
$alloc_type = 0x40; # XFS_BMAPI_PREALLOC
}
--- On Red Hat Enterprise Linux 6 ---

--- On Red Hat Enterprise Linux 7 onwards ---
probe module("xfs").function("xfs_alloc_file_space") {
if ($alloc_type == 0)
$alloc_type = 0x8; # XFS_BMAPI_PREALLOC
}
--- On Red Hat Enterprise Linux 7 onwards ---

2) Install systemtap package and its dependencies

     # yum install -y systemtap systemtap-runtime
     # yum install -y kernel-devel kernel-debuginfo

3) Build the mitigation kernel module as root.

    # stap -r `uname -r` -m cve_2021_4155.ko -g CVE-2021-4155.stp -p4

4) Load the mitigation module as root

    # staprun -L cve_2021_4155.ko

What is SystemTap and how to use it?
https://access.redhat.com/solutions/5441

Common Vulnerability Scoring System (CVSS) Score Details

Info alert:Important note

CVSS scores for open source components depend on vendor-specific factors (e.g. version or build chain). Therefore, Red Hat's score and impact rating can be different from NVD and other vendors. Red Hat remains the authoritative CVE Naming Authority (CNA) source for its products and services (see Red Hat classifications).

CVSS v3 Score Breakdown

Red HatNVDcve.org
Base Score5.55.5N/A
Attack VectorLocalLocalN/A
Attack ComplexityLowLowN/A
Privileges RequiredLowLowN/A
User InteractionNoneNoneN/A
ScopeUnchangedUnchangedN/A
ConfidentialityHighHighN/A
Integrity ImpactNoneNoneN/A
Availability ImpactNoneNoneN/A

Vector

Red Hat: CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N

NVD: CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N

Understanding the Weakness (CWE)

Integrity,Availability,Confidentiality

Technical Impact: DoS: Crash, Exit, or Restart; Execute Unauthorized Code or Commands; Read Memory; Modify Memory

If the incorrect calculation is used in the context of memory allocation, then the software may create a buffer that is smaller or larger than expected. If the allocated buffer is smaller than expected, this could lead to an out-of-bounds read or write (CWE-119), possibly causing a crash, allowing arbitrary code execution, or exposing sensitive data.

Acknowledgements

Red Hat would like to thank Kirill Tkhai (Virtuozzo Kernel team) for reporting this issue.

Frequently Asked Questions

Want to get errata notifications? Sign up here.