xfs: raw block device data leak in XFS_IOC_ALLOCSP IOCTL
CVE: CVE-2021-4155
Component: kernel
CWE: CWE-131
Severity: Important
CVSS v3: 5.6/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N
Release date: 2021-01-01T00:00:00+00:00

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.


Remediation:
For details on how to apply this update, which includes the changes described in this advisory, refer to:

https://access.redhat.com/articles/11258

The system must be rebooted for this update to take effect.
For details on how to apply this update, which includes the changes described in this advisory, refer to:

https://access.redhat.com/articles/11258

The system must be rebooted for this update to take effect.
For details on how to apply this update, which includes the changes described in this advisory, refer to:

https://access.redhat.com/articles/11258

The system must be rebooted for this update to take effect.
For details on how to apply this update, which includes the changes described in this advisory, refer to:

https://access.redhat.com/articles/11258

The system must be rebooted for this update to take effect.
For details on how to apply this update, which includes the changes described in this advisory, refer to:

https://access.redhat.com/articles/11258

The system must be rebooted for this update to take effect.
For details on how to apply this update, which includes the changes described in this advisory, refer to:

https://access.redhat.com/articles/11258

The system must be rebooted for this update to take effect.
For details on how to apply this update, which includes the changes described in this advisory, refer to:

https://access.redhat.com/articles/11258

The system must be rebooted for this update to take effect.
For details on how to apply this update, which includes the changes described in this advisory, refer to:

https://access.redhat.com/articles/2974891
For details on how to apply this update, which includes the changes described in this advisory, refer to:

https://access.redhat.com/articles/2974891
For details on how to apply this update, which includes the changes described in this advisory, refer to:

https://access.redhat.com/articles/11258

The system must be rebooted for this update to take effect.
For details on how to apply this update, which includes the changes described in this advisory, refer to:

https://access.redhat.com/articles/11258

The system must be rebooted for this update to take effect.
For details on how to apply this update, which includes the changes described in this advisory, refer to:

https://access.redhat.com/articles/11258

The system must be rebooted for this update to take effect.
For details on how to apply this update, which includes the changes described in this advisory, refer to:

https://access.redhat.com/articles/11258

The system must be rebooted for this update to take effect.
For details on how to apply this update, which includes the changes described in this advisory, refer to:

https://access.redhat.com/articles/11258

The system must be rebooted for this update to take effect.
For details on how to apply this update, which includes the changes described in this advisory, refer to:

https://access.redhat.com/articles/11258

The system must be rebooted for this update to take effect.
For details on how to apply this update, which includes the changes described in this advisory, refer to:

https://access.redhat.com/articles/11258

The system must be rebooted for this update to take effect.
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