In the Linux kernel, the following vulnerability has been resolved:
mtd: core: fix possible resource leak in init_mtd()
I got the error report while inject fault in init_mtd():
sysfs: cannot create duplicate filename '/devices/virtual/bdi/mtd-0' Call Trace: <TASK> dumpstacklvl+0x67/0x83 sysfswarndup+0x60/0x70 sysfscreatedirns+0x109/0x120 kobjectaddinternal+0xce/0x2f0 kobjectadd+0x98/0x110 deviceadd+0x179/0xc00 devicecreategroupsvargs+0xf4/0x100 devicecreate+0x7b/0xb0 bdiregisterva.part.13+0x58/0x2d0 bdiregister+0x9b/0xb0 initmtd+0x62/0x171 [mtd] dooneinitcall+0x6c/0x3c0 doinitmodule+0x58/0x222 loadmodule+0x268e/0x27d0 _dosysfinitmodule+0xd5/0x140 dosyscall64+0x37/0x90 entrySYSCALL64afterhwframe+0x63/0xcd </TASK> kobjectaddinternal failed for mtd-0 with -EEXIST, don't try to register things with the same name in the same directory. Error registering mtd class or bdi: -17
If initmtdchar() fails in initmtd(), mtdbdi will not be unregistered, as a result, we can't load the mtd module again, to fix this by calling bdiunregister(mtdbdi) after outprocfs label.
[
{
"id": "CVE-2022-50304-12a5d03d",
"digest": {
"line_hashes": [
"273466872945363888813254581481581011706",
"191300094265581746725289560733790487249",
"88821837628929492503105031877108599460",
"193730914804821569951781298094794133951"
],
"threshold": 0.9
},
"deprecated": false,
"signature_type": "Line",
"target": {
"file": "drivers/mtd/mtdcore.c"
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@1aadf01e5076b9ab6bf294b9622335c651314895",
"signature_version": "v1"
},
{
"id": "CVE-2022-50304-397b4331",
"digest": {
"line_hashes": [
"273466872945363888813254581481581011706",
"191300094265581746725289560733790487249",
"88821837628929492503105031877108599460",
"193730914804821569951781298094794133951"
],
"threshold": 0.9
},
"deprecated": false,
"signature_type": "Line",
"target": {
"file": "drivers/mtd/mtdcore.c"
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@26c304a3f136009c5a2a04e2bf3ac6aa25aabcb4",
"signature_version": "v1"
},
{
"id": "CVE-2022-50304-477fd5c6",
"digest": {
"function_hash": "221032657181777640185600319194056967373",
"length": 667.0
},
"deprecated": false,
"signature_type": "Function",
"target": {
"function": "init_mtd",
"file": "drivers/mtd/mtdcore.c"
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@78816504100cbd8e6836df9f58cc4fbb8b262f1c",
"signature_version": "v1"
},
{
"id": "CVE-2022-50304-8828f926",
"digest": {
"line_hashes": [
"273466872945363888813254581481581011706",
"191300094265581746725289560733790487249",
"88821837628929492503105031877108599460",
"193730914804821569951781298094794133951"
],
"threshold": 0.9
},
"deprecated": false,
"signature_type": "Line",
"target": {
"file": "drivers/mtd/mtdcore.c"
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@78816504100cbd8e6836df9f58cc4fbb8b262f1c",
"signature_version": "v1"
},
{
"id": "CVE-2022-50304-f9a48b5f",
"digest": {
"function_hash": "221032657181777640185600319194056967373",
"length": 667.0
},
"deprecated": false,
"signature_type": "Function",
"target": {
"function": "init_mtd",
"file": "drivers/mtd/mtdcore.c"
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@1aadf01e5076b9ab6bf294b9622335c651314895",
"signature_version": "v1"
},
{
"id": "CVE-2022-50304-fb3ac0a4",
"digest": {
"function_hash": "221032657181777640185600319194056967373",
"length": 667.0
},
"deprecated": false,
"signature_type": "Function",
"target": {
"function": "init_mtd",
"file": "drivers/mtd/mtdcore.c"
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@26c304a3f136009c5a2a04e2bf3ac6aa25aabcb4",
"signature_version": "v1"
}
]