CVE-2024-40950

Source
https://nvd.nist.gov/vuln/detail/CVE-2024-40950
Import Source
https://storage.googleapis.com/osv-test-cve-osv-conversion/osv-output/CVE-2024-40950.json
JSON Data
https://api.test.osv.dev/v1/vulns/CVE-2024-40950
Downstream
Published
2024-07-12T12:31:54Z
Modified
2025-10-17T07:50:53.414705Z
Summary
mm: huge_memory: fix misused mapping_large_folio_support() for anon folios
Details

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

mm: hugememory: fix misused mappinglargefoliosupport() for anon folios

When I did a large folios split test, a WARNING "[ 5059.122759][ T166] Cannot split file folio to non-0 order" was triggered. But the test cases are only for anonmous folios. while mappinglargefolio_support() is only reasonable for page cache folios.

In splithugepagetolisttoorder(), the folio passed to mappinglargefoliosupport() maybe anonmous folio. The foliotestanon() check is missing. So the split of the anonmous THP is failed. This is also the same for shmemmapping(). We'd better add a check for both. But the shmemmapping() in _splithugepage() is not involved, as for anonmous folios, the end parameter is set to -1, so (head[i].index >= end) is always false. shmem_mapping() is not called.

Also add a VMWARNONONCE() in mappinglargefoliosupport() for anon mapping, So we can detect the wrong use more easily.

THP folios maybe exist in the pagecache even the file system doesn't support large folio, it is because when CONFIGTRANSPARENTHUGEPAGE is enabled, khugepaged will try to collapse read-only file-backed pages to THP. But the mapping does not actually support multi order large folios properly.

Using /sys/kernel/debug/splithugepages to verify this, with this patch, large anon THP is successfully split and the warning is ceased.

References

Affected packages

Git / git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git

Affected ranges

Type
GIT
Repo
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
Events
Introduced
c010d47f107f609b9f4d6a103b6dfc53889049e9
Fixed
5df493a99fcf887133cf01d23cd4bebb6d385d3c
Type
GIT
Repo
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
Events
Introduced
c010d47f107f609b9f4d6a103b6dfc53889049e9
Fixed
6a50c9b512f7734bc356f4bd47885a6f7c98491a

Affected versions

v6.*

v6.10-rc1
v6.10-rc2
v6.10-rc3
v6.8
v6.8-rc6
v6.8-rc7
v6.9
v6.9-rc1
v6.9-rc2
v6.9-rc3
v6.9-rc4
v6.9-rc5
v6.9-rc6
v6.9-rc7
v6.9.1
v6.9.2
v6.9.3
v6.9.4
v6.9.5
v6.9.6

Database specific

vanir_signatures

[
    {
        "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@6a50c9b512f7734bc356f4bd47885a6f7c98491a",
        "deprecated": false,
        "digest": {
            "function_hash": "235932619543678913392786481932529653123",
            "length": 158.0
        },
        "signature_type": "Function",
        "id": "CVE-2024-40950-06364049",
        "signature_version": "v1",
        "target": {
            "function": "mapping_large_folio_support",
            "file": "include/linux/pagemap.h"
        }
    },
    {
        "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@6a50c9b512f7734bc356f4bd47885a6f7c98491a",
        "deprecated": false,
        "digest": {
            "function_hash": "304921075562621109816189730877251710250",
            "length": 2812.0
        },
        "signature_type": "Function",
        "id": "CVE-2024-40950-54190112",
        "signature_version": "v1",
        "target": {
            "function": "split_huge_page_to_list_to_order",
            "file": "mm/huge_memory.c"
        }
    },
    {
        "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@6a50c9b512f7734bc356f4bd47885a6f7c98491a",
        "deprecated": false,
        "digest": {
            "threshold": 0.9,
            "line_hashes": [
                "249724648496122280741530671823885010033",
                "226811834124386187225655704689972289673",
                "76119284174103609545914612710003682430",
                "113670795105653432364920646577609495626",
                "133504730386258192905434616081137371339",
                "204215438545842195937710255413181475522",
                "275112261384250443219544769480249235878",
                "152395419767381426269809684973923790666",
                "3356755849820708301931157744115605708",
                "85118108546857720036122255150405482323",
                "313234397652422833165681666053379248756",
                "8718039862204240513237675463368835534",
                "331815300068313350236067148719418240684",
                "60406836172372519410580160691598178562",
                "6982803631683942263229465366656735799",
                "316242747963554887440803273000146261713",
                "143544180506178339758533601303541729190",
                "28605856497944563615456352771974958119",
                "203724527014527076266643898948143094093",
                "84997108982352629418281564333767761132",
                "216111267660651857596930746751563293036"
            ]
        },
        "signature_type": "Line",
        "id": "CVE-2024-40950-6b61b599",
        "signature_version": "v1",
        "target": {
            "file": "mm/huge_memory.c"
        }
    },
    {
        "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@5df493a99fcf887133cf01d23cd4bebb6d385d3c",
        "deprecated": false,
        "digest": {
            "function_hash": "235932619543678913392786481932529653123",
            "length": 158.0
        },
        "signature_type": "Function",
        "id": "CVE-2024-40950-947bc9f9",
        "signature_version": "v1",
        "target": {
            "function": "mapping_large_folio_support",
            "file": "include/linux/pagemap.h"
        }
    },
    {
        "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@6a50c9b512f7734bc356f4bd47885a6f7c98491a",
        "deprecated": false,
        "digest": {
            "threshold": 0.9,
            "line_hashes": [
                "59587398470703274264564879477720701276",
                "153728172136393411043624609293954823248",
                "195718641543937203552255485309255772924",
                "98067784547547699469394871588288021914"
            ]
        },
        "signature_type": "Line",
        "id": "CVE-2024-40950-9cf53282",
        "signature_version": "v1",
        "target": {
            "file": "include/linux/pagemap.h"
        }
    },
    {
        "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@5df493a99fcf887133cf01d23cd4bebb6d385d3c",
        "deprecated": false,
        "digest": {
            "threshold": 0.9,
            "line_hashes": [
                "59587398470703274264564879477720701276",
                "153728172136393411043624609293954823248",
                "195718641543937203552255485309255772924",
                "98067784547547699469394871588288021914"
            ]
        },
        "signature_type": "Line",
        "id": "CVE-2024-40950-cae9557e",
        "signature_version": "v1",
        "target": {
            "file": "include/linux/pagemap.h"
        }
    },
    {
        "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@5df493a99fcf887133cf01d23cd4bebb6d385d3c",
        "deprecated": false,
        "digest": {
            "function_hash": "124929886629645116489182890676268948459",
            "length": 2781.0
        },
        "signature_type": "Function",
        "id": "CVE-2024-40950-cfcdadfe",
        "signature_version": "v1",
        "target": {
            "function": "split_huge_page_to_list_to_order",
            "file": "mm/huge_memory.c"
        }
    },
    {
        "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@5df493a99fcf887133cf01d23cd4bebb6d385d3c",
        "deprecated": false,
        "digest": {
            "threshold": 0.9,
            "line_hashes": [
                "249724648496122280741530671823885010033",
                "226811834124386187225655704689972289673",
                "76119284174103609545914612710003682430",
                "113670795105653432364920646577609495626",
                "133504730386258192905434616081137371339",
                "204215438545842195937710255413181475522",
                "275112261384250443219544769480249235878",
                "152395419767381426269809684973923790666",
                "3356755849820708301931157744115605708",
                "85118108546857720036122255150405482323",
                "313234397652422833165681666053379248756",
                "8718039862204240513237675463368835534",
                "331815300068313350236067148719418240684",
                "60406836172372519410580160691598178562",
                "6982803631683942263229465366656735799",
                "316242747963554887440803273000146261713",
                "143544180506178339758533601303541729190",
                "28605856497944563615456352771974958119",
                "197202057582379726107786528336387501228",
                "241911719496417461291581096085464139505",
                "196587153737436849388533410380234426961"
            ]
        },
        "signature_type": "Line",
        "id": "CVE-2024-40950-e691f48c",
        "signature_version": "v1",
        "target": {
            "file": "mm/huge_memory.c"
        }
    }
]

Linux / Kernel

Package

Name
Kernel

Affected ranges

Type
ECOSYSTEM
Events
Introduced
6.9.0
Fixed
6.9.7