From: "Michael S. Tsirkin" <mst@redhat.com>
To: Michal Hocko <mhocko@kernel.org>
Cc: Oleg Nesterov <oleg@redhat.com>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
linux-mm@kvack.org, Andrew Morton <akpm@linux-foundation.org>,
Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>,
David Rientjes <rientjes@google.com>,
Vladimir Davydov <vdavydov@parallels.com>
Subject: Re: [PATCH 09/10] vhost, mm: make sure that oom_reaper doesn't reap memory read by vhost
Date: Mon, 15 Aug 2016 02:06:31 +0300 [thread overview]
Message-ID: <20160815020525-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20160814165720.wcvejj7h6k7zz72a@redhat.com>
On Sun, Aug 14, 2016 at 07:57:20PM +0300, Michael S. Tsirkin wrote:
> On Sun, Aug 14, 2016 at 10:41:52AM +0200, Michal Hocko wrote:
> > On Sat 13-08-16 03:15:00, Michael S. Tsirkin wrote:
> > > On Fri, Aug 12, 2016 at 03:21:41PM +0200, Oleg Nesterov wrote:
> > > > Whats really interesting is that I still fail to understand do we really
> > > > need this hack, iiuc you are not sure too, and Michael didn't bother to
> > > > explain why a bogus zero from anon memory is worse than other problems
> > > > caused by SIGKKILL from oom-kill.c.
> > >
> > > vhost thread will die, but vcpu thread is going on. If it's memory is
> > > corrupted because vhost read 0 and uses that as an array index, it can
> > > do things like corrupt the disk, so it can't be restarted.
> > >
> > > But I really wish we didn't need this special-casing. Can't PTEs be
> > > made invalid on oom instead of pointing them at the zero page?
> >
> > Well ptes are just made !present and the subsequent #PF will allocate
> > a fresh new page which will be a zero page as the original content is
> > gone already.
>
> Can't we set a flag to make fixups desist from faulting
> in memory?
>
>
> > But I am not really sure what you mean by an invalid
> > pte. You are in a kernel thread context, aka unkillable context. How
> > would you handle SIGBUS or whatever other signal as a result of the
> > invalid access?
>
> No need for signal - each copy from user access is already
> checked for errors.
>
> > > And then
> > > won't memory accesses trigger pagefaults instead of returning 0?
> >
> > See above. Zero page is just result of the lost memory content. We
> > cannot both reclaim and keep the original content.
>
> Isn't this what decides it's a valid address so
> we need to bring in a page (in __do_page_fault)?
>
>
> vma = find_vma(mm, address);
> if (unlikely(!vma)) {
> bad_area(regs, error_code, address);
> return;
> }
> if (likely(vma->vm_start <= address))
> goto good_area;
> if (unlikely(!(vma->vm_flags & VM_GROWSDOWN))) {
> bad_area(regs, error_code, address);
> return;
> }
>
>
> So why can't we check a flag here, and call bad_area?
> then vhost will get an error from access to userspace
> memory and can handle it correctly.
>
>
> > > That
> > > would make regular copy_from_user machinery do the right thing,
> > > making vhost stop running as appropriate.
> >
> > I must be missing something here but how would you make the kernel
> > thread context find out the invalid access. You would have to perform
> > signal handling routine after every single memory access and I fail how
> > this is any different from a special copy_from_user_mm.
>
> No because IIUC no checks are needed as long as there
> is no fault. On fault, fixups are run, at the moment
> they bring in a page, I am saying they should
> behave as if an invalid address was accessed instead.
>
>
> > --
> > Michal Hocko
> > SUSE Labs
So fundamentally, won't the following make copy to/from user
return EFAULT? If yes, vhost is already prepared to handle that.
diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
index dc80230..e5dbee5 100644
--- a/arch/x86/mm/fault.c
+++ b/arch/x86/mm/fault.c
@@ -1309,6 +1309,11 @@ retry:
might_sleep();
}
+ if (unlikely(test_bit(MMF_UNSTABLE, &mm->flags))) {
+ bad_area(regs, error_code, address);
+ return;
+ }
+
vma = find_vma(mm, address);
if (unlikely(!vma)) {
bad_area(regs, error_code, address);
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2016-08-14 23:06 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-28 19:42 [RFC PATCH 0/10] fortify oom killer even more Michal Hocko
2016-07-28 19:42 ` [PATCH 01/10] mm,oom_reaper: Reduce find_lock_task_mm() usage Michal Hocko
2016-07-28 19:42 ` [PATCH 02/10] mm,oom_reaper: Do not attempt to reap a task twice Michal Hocko
2016-07-28 19:42 ` [PATCH 03/10] oom: keep mm of the killed task available Michal Hocko
2016-07-28 19:42 ` [PATCH 04/10] mm, oom: get rid of signal_struct::oom_victims Michal Hocko
2016-07-28 19:42 ` [PATCH 05/10] kernel, oom: fix potential pgd_lock deadlock from __mmdrop Michal Hocko
2016-07-28 19:42 ` [PATCH 06/10] oom, suspend: fix oom_killer_disable vs. pm suspend properly Michal Hocko
2016-07-28 19:42 ` [PATCH 07/10] mm, oom: enforce exit_oom_victim on current task Michal Hocko
2016-07-28 19:42 ` [PATCH 08/10] exit, oom: postpone exit_oom_victim to later Michal Hocko
2016-07-30 8:20 ` Tetsuo Handa
2016-07-31 9:35 ` Michal Hocko
2016-07-31 10:19 ` Michal Hocko
2016-08-01 10:46 ` Tetsuo Handa
2016-08-01 11:33 ` Michal Hocko
2016-08-02 10:32 ` Tetsuo Handa
2016-08-02 11:31 ` Michal Hocko
2016-07-28 19:42 ` [PATCH 09/10] vhost, mm: make sure that oom_reaper doesn't reap memory read by vhost Michal Hocko
2016-07-28 20:41 ` Michael S. Tsirkin
2016-07-29 6:04 ` Michal Hocko
2016-07-29 13:14 ` Michael S. Tsirkin
2016-07-29 13:35 ` Michal Hocko
2016-07-29 17:57 ` Michael S. Tsirkin
2016-07-31 9:44 ` Michal Hocko
2016-08-12 9:42 ` Michal Hocko
2016-08-12 13:21 ` Oleg Nesterov
2016-08-12 14:41 ` Michal Hocko
2016-08-12 16:05 ` Oleg Nesterov
2016-08-12 15:57 ` Paul E. McKenney
2016-08-12 16:09 ` Oleg Nesterov
2016-08-12 16:26 ` Paul E. McKenney
2016-08-12 16:23 ` Michal Hocko
2016-08-13 0:15 ` Michael S. Tsirkin
2016-08-14 8:41 ` Michal Hocko
2016-08-14 16:57 ` Michael S. Tsirkin
2016-08-14 23:06 ` Michael S. Tsirkin [this message]
2016-08-15 9:49 ` Michal Hocko
2016-08-17 16:58 ` Michal Hocko
2016-08-22 13:03 ` Michal Hocko
2016-08-22 21:01 ` Michael S. Tsirkin
2016-08-23 7:55 ` Michal Hocko
2016-08-23 9:06 ` Michal Hocko
2016-08-23 12:54 ` Michael S. Tsirkin
2016-08-24 16:42 ` Michal Hocko
2016-08-12 9:43 ` Michal Hocko
2016-07-29 17:07 ` Oleg Nesterov
2016-07-31 9:11 ` Michal Hocko
2016-07-28 19:42 ` [PATCH 10/10] oom, oom_reaper: allow to reap mm shared by the kthreads Michal Hocko
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=20160815020525-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=oleg@redhat.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=penguin-kernel@I-love.SAKURA.ne.jp \
--cc=rientjes@google.com \
--cc=vdavydov@parallels.com \
/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