commit | 2efa33fc7f6ec94a3a538c1a264273c889be2b36 | [log] [tgz] |
---|---|---|
author | Miaohe Lin <[email protected]> | Mon Jun 28 19:36:57 2021 -0700 |
committer | Linus Torvalds <[email protected]> | Tue Jun 29 10:53:49 2021 -0700 |
tree | 157a2f728b920ea9b66548012371f74e2ad590cd | |
parent | 5c046235a826370d528a29c44e0ce05f9685d8b4 [diff] |
mm/shmem: fix shmem_swapin() race with swapoff When I was investigating the swap code, I found the below possible race window: CPU 1 CPU 2 ----- ----- shmem_swapin swap_cluster_readahead if (likely(si->flags & (SWP_BLKDEV | SWP_FS_OPS))) { swapoff .. si->swap_file = NULL; .. struct inode *inode = si->swap_file->f_mapping->host;[oops!] Close this race window by using get/put_swap_device() to guard against concurrent swapoff. Link: https://lkml.kernel.org/r/[email protected] Fixes: 8fd2e0b505d1 ("mm: swap: check if swap backing device is congested or not") Signed-off-by: Miaohe Lin <[email protected]> Reviewed-by: "Huang, Ying" <[email protected]> Cc: Dennis Zhou <[email protected]> Cc: Tim Chen <[email protected]> Cc: Hugh Dickins <[email protected]> Cc: Johannes Weiner <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Joonsoo Kim <[email protected]> Cc: Alex Shi <[email protected]> Cc: Matthew Wilcox <[email protected]> Cc: Minchan Kim <[email protected]> Cc: Wei Yang <[email protected]> Cc: Yang Shi <[email protected]> Cc: David Hildenbrand <[email protected]> Cc: Yu Zhao <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>