Re: [PATCH v3 1/3] mm/swapfile: unuse_pte can map random data if swap read fails
From: David Hildenbrand
Date: Mon Apr 25 2022 - 03:46:17 EST
On 25.04.22 03:08, HORIGUCHI NAOYA(堀口 直也) wrote:
> On Sun, Apr 24, 2022 at 05:11:03PM +0800, Miaohe Lin wrote:
>> There is a bug in unuse_pte(): when swap page happens to be unreadable,
>> page filled with random data is mapped into user address space. In case
>> of error, a special swap entry indicating swap read fails is set to the
>> page table. So the swapcache page can be freed and the user won't end up
>> with a permanently mounted swap because a sector is bad. And if the page
>> is accessed later, the user process will be killed so that corrupted data
>> is never consumed. On the other hand, if the page is never accessed, the
>> user won't even notice it.
>> Signed-off-by: Miaohe Lin <linmiaohe@xxxxxxxxxx>
>> Acked-by: David Hildenbrand <david@xxxxxxxxxx>
> Hi Miaohe,
> This bug sounds relatively serious to me, and it seems old, so is it worth
> sending to -stable?
I'm not sure if this is worth -stable, but no strong opinion.
The do_swap_page() part was added in 2005:
Author: Kirill Korotaev <dev@xxxxx>
Date: Mon May 16 21:53:50 2005 -0700
[PATCH] do_swap_page() can map random data if swap read fails
There is a bug in do_swap_page(): when swap page happens to be unreadable,
page filled with random data is mapped into user address space. The fix is
to check for PageUptodate and send SIGBUS in case of error.
Signed-Off-By: Kirill Korotaev <dev@xxxxx>
Signed-Off-By: Alexey Kuznetsov <kuznet@xxxxxxxxxxxxx>
Acked-by: Hugh Dickins <hugh@xxxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxx>
Signed-off-by: Linus Torvalds <torvalds@xxxxxxxx>
So the do_swap_page() part has been fixed for quite a while already.
David / dhildenb