In the Linux kernel, the following vulnerability has been resolved:
regulator: da9121: Fix uninit-value in da9121assignchip_model()
KASAN report slab-out-of-bounds in _regmapinit as follows:
BUG: KASAN: slab-out-of-bounds in _regmapinit drivers/base/regmap/regmap.c:841 Read of size 1 at addr ffff88803678cdf1 by task xrun/9137
CPU: 0 PID: 9137 Comm: xrun Tainted: G W 5.18.0-rc2 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1.1 04/01/2014 Call Trace: <TASK> dumpstacklvl+0xe8/0x15a lib/dumpstack.c:88 printreport.cold+0xcd/0x69b mm/kasan/report.c:313 kasan_report+0x8e/0xc0 mm/kasan/report.c:491 __regmap_init+0x4540/0x4ba0 drivers/base/regmap/regmap.c:841 __devmregmapinit+0x7a/0x100 drivers/base/regmap/regmap.c:1266 _devmregmapiniti2c+0x65/0x80 drivers/base/regmap/regmap-i2c.c:394 da9121i2cprobe+0x386/0x6d1 drivers/regulator/da9121-regulator.c:1039 i2cdeviceprobe+0x959/0xac0 drivers/i2c/i2c-core-base.c:563
This happend when da9121 device is probe by da9121i2cid, but with invalid dts. Thus, chip->subvariantid is set to -EINVAL, and later da9121assignchipmodel() will access 'regmap' without init it.
Fix it by return -EINVAL from da9121assignchipmodel() if 'chip->subvariantid' is invalid.
{
"osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2022/49xxx/CVE-2022-49507.json",
"cna_assigner": "Linux"
}"https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2022-49507.json"
[
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@60f21eda69f1b5727a97d2077da766eb27fcc21f",
"deprecated": false,
"signature_version": "v1",
"id": "CVE-2022-49507-7e803e5f",
"digest": {
"threshold": 0.9,
"line_hashes": [
"140913568925713312745434157648582484565",
"66869105530153617401220177190139622437",
"111871284861921487041757793089610972212",
"60892550607398445800053056816870079073"
]
},
"signature_type": "Line",
"target": {
"file": "drivers/regulator/da9121-regulator.c"
}
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@bab76514aca36bc513224525d5598da676938218",
"deprecated": false,
"signature_version": "v1",
"id": "CVE-2022-49507-b1c36f5e",
"digest": {
"length": 1382.0,
"function_hash": "178393370998132346987360542962850892091"
},
"signature_type": "Function",
"target": {
"file": "drivers/regulator/da9121-regulator.c",
"function": "da9121_assign_chip_model"
}
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@bab76514aca36bc513224525d5598da676938218",
"deprecated": false,
"signature_version": "v1",
"id": "CVE-2022-49507-ea279565",
"digest": {
"threshold": 0.9,
"line_hashes": [
"140913568925713312745434157648582484565",
"66869105530153617401220177190139622437",
"111871284861921487041757793089610972212",
"60892550607398445800053056816870079073"
]
},
"signature_type": "Line",
"target": {
"file": "drivers/regulator/da9121-regulator.c"
}
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@60f21eda69f1b5727a97d2077da766eb27fcc21f",
"deprecated": false,
"signature_version": "v1",
"id": "CVE-2022-49507-ffdd147d",
"digest": {
"length": 1382.0,
"function_hash": "178393370998132346987360542962850892091"
},
"signature_type": "Function",
"target": {
"file": "drivers/regulator/da9121-regulator.c",
"function": "da9121_assign_chip_model"
}
}
]