[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20121214110110.8181.70783.stgit@zurg>
Date: Fri, 14 Dec 2012 15:01:10 +0400
From: Konstantin Khlebnikov <khlebnikov@...nvz.org>
To: linux-kernel@...r.kernel.org
Cc: Andrew Morton <akpm@...ux-foundation.org>,
Andi Kleen <andi@...stfloor.org>,
Hugh Dickins <hughd@...gle.com>
Subject: [PATCH] mm/swap: abort swapoff after disk error
Content of non-uptodate pages completely random, we cannot expose them into
userspace. This leads to information leak and will crash userspace for sure.
Probably we can reuse hwpoison entries here, but tmpfs already too complex.
Signed-off-by: Konstantin Khlebnikov <khlebnikov@...nvz.org>
Original-patch-by: Alexey Kuznetsov <kuznet@....inr.ac.ru>
Cc: Andrew Morton <akpm@...ux-foundation.org>
Cc: Hugh Dickins <hughd@...gle.com>
Cc: Andi Kleen <andi@...stfloor.org>
---
mm/swapfile.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/mm/swapfile.c b/mm/swapfile.c
index e97a0e5..98fc2fd 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -1127,6 +1127,22 @@ int try_to_unuse(unsigned int type, bool frontswap,
wait_on_page_writeback(page);
/*
+ * If read failed we cannot map not-uptodate page to
+ * user space. Actually, we are in serious troubles,
+ * we do not even know what process to kill. So, the only
+ * variant remains: to stop swapoff() and allow someone
+ * to kill processes to zap invalid pages.
+ *
+ * TODO replace page with hwpoison entry in pte and shmem.
+ */
+ if (unlikely(!PageUptodate(page))) {
+ unlock_page(page);
+ page_cache_release(page);
+ retval = -EIO;
+ break;
+ }
+
+ /*
* Remove all references to entry.
*/
swcount = *swap_map;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists