mm/swap: fix swap_info_struct race between swapoff and get_swap_pages()
Linux
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
Linux
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
≥ a2468cc9bfdff6139f59ca896671e5819ff5f94a · < 85cc118ce6f1a627901b6db50c9d01f2ad78cdbf| No fix yet |
| Linux Linux |
|
|
In the Linux kernel, the following vulnerability has been resolved:
mm/swap: fix swap_info_struct race between swapoff and get_swap_pages()
The si->lock must be held when deleting the si from the available list. Otherwise, another thread can re-add the si to the available list, which can lead to memory corruption. The only place we have found where this happens is in the swapoff path. This case can be described as below:
core 0 core 1 swapoff
del_from_avail_list(si) waiting
try lock si->lock acquire swap_avail_lock and re-add si into swap_avail_head
acquire si->lock but missing si already being added again, and continuing to clear SWP_WRITEOK, etc.
It can be easily found that a massive warning messages can be triggered inside get_swap_pages() by some special cases, for example, we call madvise(MADV_PAGEOUT) on blocks of touched memory concurrently, meanwhile, run much swapon-swapoff operations (e.g. stress-ng-swap).
From the CVE record · Linux
A race between swapoff and get_swap_pages() can re-add swap information to an available list while it is being removed, leading to memory corruption and potentially a kernel panic. The issue can occur during concurrent swap operations and memory page-out activity; the input does not specify authentication requirements.
Engineers running Linux kernels should check whether their kernel is affected; the input does not identify affected versions.