In the Linux kernel, the following vulnerability has been resolved:
watchdog: Fix kmemleak in watchdogcdevregister
kmemleak reports memory leaks in watchdogdevregister, as follows: unreferenced object 0xffff888116233000 (size 2048): comm ""modprobe"", pid 28147, jiffies 4353426116 (age 61.741s) hex dump (first 32 bytes): 80 fa b9 05 81 88 ff ff 08 30 23 16 81 88 ff ff .........0#..... 08 30 23 16 81 88 ff ff 00 00 00 00 00 00 00 00 .0#............. backtrace: [<000000007f001ffd>] _kmemcacheallocnode+0x157/0x220 [<000000006a389304>] kmalloctrace+0x21/0x110 [<000000008d640eea>] watchdogdevregister+0x4e/0x780 [watchdog] [<0000000053c9f248>] _watchdogregisterdevice+0x4f0/0x680 [watchdog] [<00000000b2979824>] watchdogregisterdevice+0xd2/0x110 [watchdog] [<000000001f730178>] 0xffffffffc10880ae [<000000007a1a8bcc>] dooneinitcall+0xcb/0x4d0 [<00000000b98be325>] doinitmodule+0x1ca/0x5f0 [<0000000046d08e7c>] load_module+0x6133/0x70f0 ...
unreferenced object 0xffff888105b9fa80 (size 16): comm ""modprobe"", pid 28147, jiffies 4353426116 (age 61.741s) hex dump (first 16 bytes): 77 61 74 63 68 64 6f 67 31 00 b9 05 81 88 ff ff watchdog1....... backtrace: [<000000007f001ffd>] _kmemcacheallocnode+0x157/0x220 [<00000000486ab89b>] _kmallocnodetrackcaller+0x44/0x1b0 [<000000005a39aab0>] kvasprintf+0xb5/0x140 [<0000000024806f85>] kvasprintfconst+0x55/0x180 [<000000009276cb7f>] kobjectsetnamevargs+0x56/0x150 [<00000000a92e820b>] devsetname+0xab/0xe0 [<00000000cec812c6>] watchdogdevregister+0x285/0x780 [watchdog] [<0000000053c9f248>] _watchdogregisterdevice+0x4f0/0x680 [watchdog] [<00000000b2979824>] watchdogregisterdevice+0xd2/0x110 [watchdog] [<000000001f730178>] 0xffffffffc10880ae [<000000007a1a8bcc>] dooneinitcall+0xcb/0x4d0 [<00000000b98be325>] doinitmodule+0x1ca/0x5f0 [<0000000046d08e7c>] loadmodule+0x6133/0x70f0 ...
The reason is that putdevice is not be called if cdevdevice_add fails and wdd->id != 0.
watchdogcdevregister wddata = kzalloc [1] err = devsetname [2] .. err = cdevdevice_add if (err) { if (wdd->id == 0) { // wdd->id != 0 .. } return err; // [1],[2] would be leaked
To fix it, call put_device in all wdd->id cases.
[
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@bf26b0e430ce34261f45959989edaf680b64d538",
"deprecated": false,
"signature_version": "v1",
"signature_type": "Line",
"digest": {
"threshold": 0.9,
"line_hashes": [
"203334233816328410031583138344763108940",
"78106306351430730249524450188502339548",
"209061981589835101449623552957237543128",
"35512475718556658807159095342520336405",
"322582273554571543766080922298640162515"
]
},
"target": {
"file": "drivers/watchdog/watchdog_dev.c"
},
"id": "CVE-2023-53234-29f818fe"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@c5a21a5501508ae3afa2fe6d5a3e74a37fa48df3",
"deprecated": false,
"signature_version": "v1",
"signature_type": "Function",
"digest": {
"function_hash": "311632920651588615982285934565914700643",
"length": 2069.0
},
"target": {
"file": "drivers/watchdog/watchdog_dev.c",
"function": "watchdog_cdev_register"
},
"id": "CVE-2023-53234-74d1e65e"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@c5a21a5501508ae3afa2fe6d5a3e74a37fa48df3",
"deprecated": false,
"signature_version": "v1",
"signature_type": "Line",
"digest": {
"threshold": 0.9,
"line_hashes": [
"203334233816328410031583138344763108940",
"78106306351430730249524450188502339548",
"209061981589835101449623552957237543128",
"35512475718556658807159095342520336405",
"322582273554571543766080922298640162515"
]
},
"target": {
"file": "drivers/watchdog/watchdog_dev.c"
},
"id": "CVE-2023-53234-93b86b7d"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@bf26b0e430ce34261f45959989edaf680b64d538",
"deprecated": false,
"signature_version": "v1",
"signature_type": "Function",
"digest": {
"function_hash": "313314128669020853711463083838001539799",
"length": 1850.0
},
"target": {
"file": "drivers/watchdog/watchdog_dev.c",
"function": "watchdog_cdev_register"
},
"id": "CVE-2023-53234-bd7a59f8"
}
]