mm-do-not-free-shared-swap-slots.patch removed from -mm tree
The patch titled
Subject: mm/page_io.c: do not free shared swap slots
has been removed from the -mm tree. Its filename was
mm-do-not-free-shared-swap-slots.patch
This patch was dropped because it was merged into mainline or a subsystem tree
------------------------------------------------------
From: Vinayak Menon <[email protected]>
Subject: mm/page_io.c: do not free shared swap slots
The following race is observed due to which a processes faulting on a swap entry, finds the page neither in swapcache nor swap. This causes zram to give a zero filled page that gets mapped to the process, resulting in a user space crash later.
Consider parent and child processes Pa and Pb sharing the same swap slot with swap_count 2. Swap is on zram with SWP_SYNCHRONOUS_IO set. Virtual address 'VA' of Pa and Pb points to the shared swap entry.
Pa Pb
fault on VA fault on VA do_swap_page do_swap_page lookup_swap_cache fails lookup_swap_cache fails
Pb scheduled outswapin_readahead (deletes zram entry)swap_free (makes swap_count 1)
Pb scheduled in swap_readpage (swap_count == 1) Takes SWP_SYNCHRONOUS_IO path zram enrty absent zram gives a zero filled page
Fix this by making sure that swap slot is freed only when swap count drops down to one.
---
mm/page_io.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
mm/page_io.c renamed from mm/page_io.c~mm-do-not-free-shared-swap-slots +3 -3
@@ -73,6 +73,7 @@ static void swap_slot_free_notify(struct {struct swap_info_struct *sis;struct gendisk *disk; +swp_entry_t entry;/* * There is no guarantee that the page is in swap cache - the software
@@ -104,11 +105,10 @@ static void swap_slot_free_notify(struct* we again wish to reclaim it. */ disk = sis->bdev->bd_disk; -if (disk->fops->swap_slot_free_notify) { -swp_entry_t entry; + entry.val =page_private (page); +if (disk->fops->swap_slot_free_notify &&__swap_count (entry) ==1 ) {unsigned long offset; - entry.val =page_private (page); offset =swp_offset (entry);SetPageDirty (page);
_
Patches currently in -mm which might be from [email protected] are