From: Konstantin Khlebnikov <khlebnikov@openvz.org>
To: linux-kernel@vger.kernel.org
Cc: Andrew Morton <akpm@linux-foundation.org>,
Andi Kleen <andi@firstfloor.org>, Hugh Dickins <hughd@google.com>
Subject: [PATCH] mm/swap: abort swapoff after disk error
Date: Fri, 14 Dec 2012 15:01:10 +0400 [thread overview]
Message-ID: <20121214110110.8181.70783.stgit@zurg> (raw)
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;
next reply other threads:[~2012-12-14 11:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-14 11:01 Konstantin Khlebnikov [this message]
2012-12-18 4:24 ` [PATCH] mm/swap: abort swapoff after disk error Hugh Dickins
2012-12-18 9:40 ` Konstantin Khlebnikov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20121214110110.8181.70783.stgit@zurg \
--to=khlebnikov@openvz.org \
--cc=akpm@linux-foundation.org \
--cc=andi@firstfloor.org \
--cc=hughd@google.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox