Skip to content

CVE-2024-50022 device-dax: correct pgoff align in dax_set_mapping()

MediumCVSS 5.5 EPSS 0.27%
Published
Updated
Exploit status
No public exploit known
CISA SSVC
No known exploitation · automatable: no · technical impact: partial
Technology
Linux KernelUbuntuDebian

Description

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

device-dax: correct pgoff align in dax_set_mapping()

pgoff should be aligned using ALIGN_DOWN() instead of ALIGN(). Otherwise,
vmf->address not aligned to fault_size will be aligned to the next
alignment, that can result in memory failure getting the wrong address.

It's a subtle situation that only can be observed in
page_mapped_in_vma() after the page is page fault handled by
dev_dax_huge_fault. Generally, there is little chance to perform
page_mapped_in_vma in dev-dax's page unless in specific error injection
to the dax device to trigger an MCE - memory-failure. In that case,
page_mapped_in_vma() will be triggered to determine which task is
accessing the failure address and kill that task in the end.

We used self-developed dax device (which is 2M aligned mapping) , to
perform error injection to random address. It turned out that error
injected to non-2M-aligned address was causing endless MCE until panic.
Because page_mapped_in_vma() kept resulting wrong address and the task
accessing the failure address was never killed properly:

[ 3783.719419] Memory failure: 0x200c9742: recovery action for dax page:
Recovered
[ 3784.049006] mce: Uncorrected hardware memory error in user-access at
200c9742380
[ 3784.049190] Memory failure: 0x200c9742: recovery action for dax page:
Recovered
[ 3784.448042] mce: Uncorrected hardware memory error in user-access at
200c9742380
[ 3784.448186] Memory failure: 0x200c9742: recovery action for dax page:
Recovered
[ 3784.792026] mce: Uncorrected hardware memory error in user-access at
200c9742380
[ 3784.792179] Memory failure: 0x200c9742: recovery action for dax page:
Recovered
[ 3785.162502] mce: Uncorrected hardware memory error in user-access at
200c9742380
[ 3785.162633] Memory failure: 0x200c9742: recovery action for dax page:
Recovered
[ 3785.461116] mce: Uncorrected hardware memory error in user-access at
200c9742380
[ 3785.461247] Memory failure: 0x200c9742: recovery action for dax page:
Recovered
[ 3785.764730] mce: Uncorrected hardware memory error in user-access at
200c9742380
[ 3785.764859] Memory failure: 0x200c9742: recovery action for dax page:
Recovered
[ 3786.042128] mce: Uncorrected hardware memory error in user-access at
200c9742380
[ 3786.042259] Memory failure: 0x200c9742: recovery action for dax page:
Recovered
[ 3786.464293] mce: Uncorrected hardware memory error in user-access at
200c9742380
[ 3786.464423] Memory failure: 0x200c9742: recovery action for dax page:
Recovered
[ 3786.818090] mce: Uncorrected hardware memory error in user-access at
200c9742380
[ 3786.818217] Memory failure: 0x200c9742: recovery action for dax page:
Recovered
[ 3787.085297] mce: Uncorrected hardware memory error in user-access at
200c9742380
[ 3787.085424] Memory failure: 0x200c9742: recovery action for dax page:
Recovered

It took us several weeks to pinpoint this problem,  but we eventually
used bpftrace to trace the page fault and mce address and successfully
identified the issue.

Joao added:

; Likely we never reproduce in production because we always pin
: device-dax regions in the region align they provide (Qemu does
: similarly with prealloc in hugetlb/file backed memory). I think this
: bug requires that we touch unpinned device-dax regions unaligned to
: the device-dax selected alignment (page size i.e. 4K/2M/1G)

Upgrade path

7 packages: 7 fixed.

PackageAffectedFixed inStatus
debian/linux(Debian 12) < 6.1.115-1; = 6.1.27-1; = 6.1.37-1; = 6.1.38-1 +27 more 6.1.115-1 Fixed
debian/linux(Debian 13) < 6.11.4-1 6.11.4-1 Fixed
debian/linux(Debian 14) < 6.11.4-1 6.11.4-1 Fixed
Linux kernel < 6.1.113; < 6.6.57; < 6.11.4; < 6.12 +10 more 6.1.113, 6.6.57, 6.11.4, 6.12, 7fcbd9785d4c17ea533c42f20a9083a83f301fa6, 9c4198dfdca818c5ce19c764d90eabd156bbc6da, b822007e8db341d6f175c645ed79866db501ad86, e877427d218159ac29c9326100920d24330c9ee6 Fixed
Microsoft azure linux < 6.6.57.1-1 6.6.57.1-1 Fixed
ubuntu/linux(Ubuntu 24.04) < 6.8.0-56.58 6.8.0-56.58 Fixed
ubuntu/linux-raspi(Ubuntu 24.04) < 6.8.0-1028.32 6.8.0-1028.32 Fixed

Affected products

ProductAffected versionsFixed in
Microsoft azure linux < 6.6.57.1-1 6.6.57.1-1
debian/linux(Debian:12) < 6.1.115-1 6.1.115-1
debian/linux(Debian:12) = 6.1.106-1 No fix listed
debian/linux(Debian:12) = 6.1.106-2 No fix listed
debian/linux(Debian:12) = 6.1.106-3 No fix listed
debian/linux(Debian:12) = 6.1.112-1 No fix listed
debian/linux(Debian:12) = 6.1.27-1 No fix listed
debian/linux(Debian:12) = 6.1.37-1 No fix listed
debian/linux(Debian:12) = 6.1.38-1 No fix listed
debian/linux(Debian:12) = 6.1.38-2 No fix listed
debian/linux(Debian:12) = 6.1.38-2~bpo11+1 No fix listed
debian/linux(Debian:12) = 6.1.38-3 No fix listed
debian/linux(Debian:12) = 6.1.38-4 No fix listed
debian/linux(Debian:12) = 6.1.38-4~bpo11+1 No fix listed
debian/linux(Debian:12) = 6.1.52-1 No fix listed
debian/linux(Debian:12) = 6.1.55-1 No fix listed
debian/linux(Debian:12) = 6.1.55-1~bpo11+1 No fix listed
debian/linux(Debian:12) = 6.1.64-1 No fix listed
debian/linux(Debian:12) = 6.1.66-1 No fix listed
debian/linux(Debian:12) = 6.1.67-1 No fix listed
debian/linux(Debian:12) = 6.1.69-1 No fix listed
debian/linux(Debian:12) = 6.1.69-1~bpo11+1 No fix listed
debian/linux(Debian:12) = 6.1.76-1 No fix listed
debian/linux(Debian:12) = 6.1.76-1~bpo11+1 No fix listed
debian/linux(Debian:12) = 6.1.82-1 No fix listed
Show 25 more
ProductAffected versionsFixed in
debian/linux(Debian:12) = 6.1.85-1 No fix listed
debian/linux(Debian:12) = 6.1.90-1 No fix listed
debian/linux(Debian:12) = 6.1.90-1~bpo11+1 No fix listed
debian/linux(Debian:12) = 6.1.94-1 No fix listed
debian/linux(Debian:12) = 6.1.94-1~bpo11+1 No fix listed
debian/linux(Debian:12) = 6.1.98-1 No fix listed
debian/linux(Debian:12) = 6.1.99-1 No fix listed
debian/linux(Debian:13) < 6.11.4-1 6.11.4-1
debian/linux(Debian:14) < 6.11.4-1 6.11.4-1
Linux kernel >= b9b5777f09be84d0de472ded2253d2f5101427f2, < 9c4198dfdca818c5ce19c764d90eabd156bbc6da 9c4198dfdca818c5ce19c764d90eabd156bbc6da
Linux kernel >= b9b5777f09be84d0de472ded2253d2f5101427f2, < b822007e8db341d6f175c645ed79866db501ad86 b822007e8db341d6f175c645ed79866db501ad86
Linux kernel >= b9b5777f09be84d0de472ded2253d2f5101427f2, < e877427d218159ac29c9326100920d24330c9ee6 e877427d218159ac29c9326100920d24330c9ee6
Linux kernel >= b9b5777f09be84d0de472ded2253d2f5101427f2, < 7fcbd9785d4c17ea533c42f20a9083a83f301fa6 7fcbd9785d4c17ea533c42f20a9083a83f301fa6
Linux kernel = 5.17 No fix listed
Linux kernel < 6.1.113 6.1.113
Linux kernel < 6.6.57 6.6.57
Linux kernel < 6.11.4 6.11.4
Linux kernel < 6.12 6.12
ubuntu/linux(Ubuntu:24.04) < 6.8.0-56.58 6.8.0-56.58
ubuntu/linux-raspi(Ubuntu:24.04) < 6.8.0-1028.32 6.8.0-1028.32
Linux kernel >= 5.17, < 6.1.113 6.1.113
Linux kernel >= 6.2, < 6.6.57 6.6.57
Linux kernel >= 6.7, < 6.11.4 6.11.4
Linux kernel = 6.12-rc1 No fix listed
Linux kernel = 6.12-rc2 No fix listed

References