Commit 815c528
mm: swap: fix potential buffer overflow in setup_clusters()
commit 152c133 upstream.
In setup_swap_map(), we only ensure badpages are in range (0, last_page].
As maxpages might be < last_page, setup_clusters() will encounter a buffer
overflow when a badpage is >= maxpages.
Only call inc_cluster_info_page() for badpage which is < maxpages to fix
the issue.
Link: https://lkml.kernel.org/r/[email protected]
Fixes: b843786 ("mm: swapfile: fix SSD detection with swapfile on btrfs")
Signed-off-by: Kemeng Shi <[email protected]>
Reviewed-by: Baoquan He <[email protected]>
Cc: Johannes Weiner <[email protected]>
Cc: Kairui Song <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>1 parent bc9e95b commit 815c528
1 file changed
Lines changed: 7 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3208 | 3208 | | |
3209 | 3209 | | |
3210 | 3210 | | |
3211 | | - | |
3212 | | - | |
3213 | | - | |
| 3211 | + | |
| 3212 | + | |
| 3213 | + | |
| 3214 | + | |
| 3215 | + | |
| 3216 | + | |
| 3217 | + | |
3214 | 3218 | | |
3215 | 3219 | | |
3216 | 3220 | | |
| |||
0 commit comments