PG_swap_entry bug in recent kernels

Ben LaHaise
2000-04-03T22:22:25Z

The following one-liner is a painful bug present in recent kernels: swap
cache pages left in the LRU lists and subsequently reclaimed by
shrink_mmap were resulting in new pages having the PG_swap_entry bit set.
This leads to invalid swap entries being put into users page tables if the
page is eventually swapped out. This was nasty to track down.

-ben

diff -ur 2.3.99-pre4-3/mm/swap_state.c test-pre4-3/mm/swap_state.c
--- 2.3.99-pre4-3/mm/swap_state.c Mon Dec 6 13:19:45 1999
+++ test-pre4-3/mm/swap_state.c Mon Apr 3 17:59:30 2000
@@ -80,6 +80,7 @@
#endif
remove_from_swap_cache(page);
swap_free(entry);
+ clear_bit(PG_swap_entry, &page->flags);
}

/*