public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm/swap: abort swapoff after disk error
@ 2012-12-14 11:01 Konstantin Khlebnikov
  2012-12-18  4:24 ` Hugh Dickins
  0 siblings, 1 reply; 3+ messages in thread
From: Konstantin Khlebnikov @ 2012-12-14 11:01 UTC (permalink / raw)
  To: linux-kernel; +Cc: Andrew Morton, Andi Kleen, Hugh Dickins

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@openvz.org>
Original-patch-by: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Hugh Dickins <hughd@google.com>
Cc: Andi Kleen <andi@firstfloor.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;


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-12-18 10:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-14 11:01 [PATCH] mm/swap: abort swapoff after disk error Konstantin Khlebnikov
2012-12-18  4:24 ` Hugh Dickins
2012-12-18  9:40   ` Konstantin Khlebnikov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox