In the Linux kernel, the following vulnerability has been resolved:
sh: push-switch: Reorder cleanup operations to avoid use-after-free bug
The original code puts flushwork() before timershutdownsync() in switchdrvremove(). Although we use flushwork() to stop the worker, it could be rescheduled in switch_timer(). As a result, a use-after-free bug can occur. The details are shown below:
(cpu 0) | (cpu 1)
switchdrvremove() | flushwork() | ... | switchtimer // timer | schedulework(&psw->work) timershutdownsync() | ... | switchwork_handler // worker kfree(psw) // free | | psw->state = 0 // use
This patch puts timershutdownsync() before flush_work() to mitigate the bugs. As a result, the worker and timer will be stopped safely before the deallocate operations.
{ "vanir_signatures": [ { "signature_version": "v1", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@246f80a0b17f8f582b2c0996db02998239057c65", "signature_type": "Function", "target": { "function": "switch_drv_remove", "file": "arch/sh/drivers/push-switch.c" }, "deprecated": false, "digest": { "length": 376.0, "function_hash": "198084318561655263968227835202983640150" }, "id": "CVE-2023-52629-e8b2701b" }, { "signature_version": "v1", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@246f80a0b17f8f582b2c0996db02998239057c65", "signature_type": "Line", "target": { "file": "arch/sh/drivers/push-switch.c" }, "deprecated": false, "digest": { "line_hashes": [ "229391386863480221789501490782657012873", "178445102420290387429056741149008395100", "78414093074277735789184272763052946661", "227171198054308315665916387348708334160", "63662214958282882943028158234001809124" ], "threshold": 0.9 }, "id": "CVE-2023-52629-e9e87944" } ] }