mm/mempolicy: fix memory leaks in weighted_interleave_auto_store()
Linux
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
| No fix yet |
| Linux Linux |
|
|
Linux
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
| No fix yet |
| Linux Linux |
|
|
6.18.277.0.47.1In the Linux kernel, the following vulnerability has been resolved:
mm/mempolicy: fix memory leaks in weighted_interleave_auto_store()
weighted_interleave_auto_store() fetches old_wi_state inside the if (!input) block only. This causes two memory leaks:
1. When a user writes "false" and the current mode is already manual, the function returns early without freeing the freshly allocated new_wi_state.
2. When a user writes "true", old_wi_state stays NULL because the fetch is skipped entirely. The old state is then overwritten by rcu_assign_pointer() but never freed, since the cleanup path is gated on old_wi_state being non-NULL. A user can trigger this repeatedly by writing "1" in a loop.
Fix both leaks by moving the old_wi_state fetch before the input check, making it unconditional. This also allows a unified early return for both "true" and "false" when the requested mode matches the current mode.
Reviewed by: Donet Tom <donettom@linux.ibm.com>
From the CVE record · Linux
The Linux kernel’s weighted_interleave_auto_store() can leak memory when a user writes to the weighted interleave setting. A local user can trigger a leak by repeatedly writing "1"; writing "false" also leaks memory when the mode is already manual.
Anyone running a Linux kernel with the affected weighted_interleave_auto_store() implementation should check their version; affected versions were not specified.