In the Linux kernel, the following vulnerability has been resolved:
floppy: Fix memory leak in dofloppyinit()
A memory leak was reported when floppyallocdisk() failed in dofloppyinit().
unreferenced object 0xffff888115ed25a0 (size 8): comm "modprobe", pid 727, jiffies 4295051278 (age 25.529s) hex dump (first 8 bytes): 00 ac 67 5b 81 88 ff ff ..g[.... backtrace: [<000000007f457abb>] _kmallocnode+0x4c/0xc0 [<00000000a87bfa9e>] blkmqrealloctagsettags.part.0+0x6f/0x180 [<000000006f02e8b1>] blkmqalloctagset+0x573/0x1130 [<0000000066007fd7>] 0xffffffffc06b8b08 [<0000000081f5ac40>] dooneinitcall+0xd0/0x4f0 [<00000000e26d04ee>] doinitmodule+0x1a4/0x680 [<000000001bb22407>] loadmodule+0x6249/0x7110 [<00000000ad31ac4d>] _dosysfinitmodule+0x140/0x200 [<000000007bddca46>] dosyscall64+0x35/0x80 [<00000000b5afec39>] entrySYSCALL64afterhwframe+0x46/0xb0 unreferenced object 0xffff88810fc30540 (size 32): comm "modprobe", pid 727, jiffies 4295051278 (age 25.529s) hex dump (first 32 bytes): 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ backtrace: [<000000007f457abb>] _kmallocnode+0x4c/0xc0 [<000000006b91eab4>] blkmqalloctagset+0x393/0x1130 [<0000000066007fd7>] 0xffffffffc06b8b08 [<0000000081f5ac40>] dooneinitcall+0xd0/0x4f0 [<00000000e26d04ee>] doinitmodule+0x1a4/0x680 [<000000001bb22407>] loadmodule+0x6249/0x7110 [<00000000ad31ac4d>] _dosysfinitmodule+0x140/0x200 [<000000007bddca46>] dosyscall64+0x35/0x80 [<00000000b5afec39>] entrySYSCALL64after_hwframe+0x46/0xb0
If the floppyallocdisk() failed, disks of current drive will not be set, thus the lastest allocated set->tag cannot be freed in the error handling path. A simple call graph shown as below:
floppymoduleinit() floppyinit() dofloppyinit() for (drive = 0; drive < NDRIVE; drive++) blkmqalloctagset() blkmqalloctagsettags() blkmqrealloctagsettags() # set->tag allocated floppyallocdisk() blkmqalloc_disk() # error occurred, disks failed to allocated
->out_put_disk:
for (drive = 0; drive < N_DRIVE; drive++)
if (!disks[drive][0]) # the last disks is not set and loop break
break;
blk_mq_free_tag_set() # the latest allocated set->tag leaked
Fix this problem by free the set->tag of current drive before jump to error handling path.
[efremov: added stable list, changed title]
{ "vanir_signatures": [ { "signature_version": "v1", "signature_type": "Function", "target": { "file": "drivers/block/floppy.c", "function": "do_floppy_init" }, "id": "CVE-2022-50342-5d0ea130", "digest": { "length": 4539.0, "function_hash": "95036006152951452699034620765678175886" }, "deprecated": false, "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@55b3c66a0d441cd37154ae95e44d0b82ccfd580e" }, { "signature_version": "v1", "signature_type": "Line", "target": { "file": "drivers/block/floppy.c" }, "id": "CVE-2022-50342-aa24f7fc", "digest": { "line_hashes": [ "67848557447942636291193858229372977125", "115959486394345030792438457967964851272", "97809557335104574017849962875971403372", "258667378882176373524977509586121696471", "172404939029695379938738331184128591693" ], "threshold": 0.9 }, "deprecated": false, "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@f36d8c8651506aea5f09899f5356ece5d1384f50" }, { "signature_version": "v1", "signature_type": "Function", "target": { "file": "drivers/block/floppy.c", "function": "do_floppy_init" }, "id": "CVE-2022-50342-aeecb187", "digest": { "length": 4539.0, "function_hash": "95036006152951452699034620765678175886" }, "deprecated": false, "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@75d8c8851a4da0190c2480e84315b5fd3d0356c5" }, { "signature_version": "v1", "signature_type": "Line", "target": { "file": "drivers/block/floppy.c" }, "id": "CVE-2022-50342-cb93ed4d", "digest": { "line_hashes": [ "67848557447942636291193858229372977125", "115959486394345030792438457967964851272", "97809557335104574017849962875971403372", "258667378882176373524977509586121696471", "172404939029695379938738331184128591693" ], "threshold": 0.9 }, "deprecated": false, "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@55b3c66a0d441cd37154ae95e44d0b82ccfd580e" }, { "signature_version": "v1", "signature_type": "Function", "target": { "file": "drivers/block/floppy.c", "function": "do_floppy_init" }, "id": "CVE-2022-50342-f371541d", "digest": { "length": 4497.0, "function_hash": "65752096565146118648127834644192829894" }, "deprecated": false, "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@f36d8c8651506aea5f09899f5356ece5d1384f50" }, { "signature_version": "v1", "signature_type": "Line", "target": { "file": "drivers/block/floppy.c" }, "id": "CVE-2022-50342-fccfc7e6", "digest": { "line_hashes": [ "67848557447942636291193858229372977125", "115959486394345030792438457967964851272", "97809557335104574017849962875971403372", "258667378882176373524977509586121696471", "172404939029695379938738331184128591693" ], "threshold": 0.9 }, "deprecated": false, "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@75d8c8851a4da0190c2480e84315b5fd3d0356c5" } ] }