From: gchen.guomin@gmail.com
To: "Michael S. Tsirkin" <mst@redhat.com>,
Jason Wang <jasowang@redhat.com>, <guominchen@tencent.com>
Cc: guomin chen <gchen.guomin@gmail.com>,
kvm@vger.kernel.org, virtualization@lists.linux-foundation.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
"Eric W. Biederman" <ebiederm@xmission.com>,
Andrew Morton <akpm@linux-foundation.org>,
Sudip Mukherjee <sudipm.mukherjee@gmail.com>,
"Luis R. Rodriguez" <mcgrof@kernel.org>,
Dominik Brodowski <linux@dominikbrodowski.net>
Subject: [PATCH] Export mm_update_next_owner function for vhost-net
Date: Thu, 13 Dec 2018 12:47:25 +0800 [thread overview]
Message-ID: <1544676445-14897-1-git-send-email-gchen.guomin@gmail.com> (raw)
From: guomin chen <gchen.guomin@gmail.com>
Under normal circumstances,When do_exit exits, mm->owner will
be updated on exit_mm(). but when the kernel process calls
unuse_mm() and then exits,mm->owner cannot be updated. And it
will point to a task that has been released.
Below is my issue on vhost_net:
A, B are two kernel processes(such as vhost_worker),
C is a user space process(such as qemu), and all
three use the mm of the user process C.
Now, because user process C exits abnormally, the owner of this
mm becomes A. When A calls unuse_mm and exits, this mm->ower
still points to the A that has been released.
When B accesses this mm->owner again, A has been released.
Process A Process B
vhost_worker() vhost_worker()
--------- ---------
use_mm() use_mm()
...
unuse_mm()
tsk->mm=NULL
do_exit() page fault
exit_mm() access mm->owner
can't update owner kernel Oops
unuse_mm()
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Jason Wang <jasowang@redhat.com>
Cc: kvm@vger.kernel.org
Cc: virtualization@lists.linux-foundation.org
Cc: netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Cc: "Luis R. Rodriguez" <mcgrof@kernel.org>
Cc: Dominik Brodowski <linux@dominikbrodowski.net>
Signed-off-by: guomin chen <gchen.guomin@gmail.com>
---
drivers/vhost/vhost.c | 1 +
kernel/exit.c | 1 +
2 files changed, 2 insertions(+)
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index 6b98d8e..7c09087 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -368,6 +368,7 @@ static int vhost_worker(void *data)
}
}
unuse_mm(dev->mm);
+ mm_update_next_owner(dev->mm);
set_fs(oldfs);
return 0;
}
diff --git a/kernel/exit.c b/kernel/exit.c
index 0e21e6d..9e046dd 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -486,6 +486,7 @@ void mm_update_next_owner(struct mm_struct *mm)
task_unlock(c);
put_task_struct(c);
}
+EXPORT_SYMBOL(mm_update_next_owner);
#endif /* CONFIG_MEMCG */
/*
--
1.8.3.1
next reply other threads:[~2018-12-13 4:47 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-13 4:47 gchen.guomin [this message]
2018-12-13 6:30 ` [PATCH] Export mm_update_next_owner function for vhost-net Jason Wang
2018-12-13 9:13 ` 答复: [PATCH] Export mm_update_next_owner function for vhost-net(Internet mail) guominchen(陈国民)
2018-12-17 11:32 ` [PATCH] Export mm_update_next_owner function for vhost-net Christoph Hellwig
[not found] ` <CAEEwsfQ9ARxJCZxy5bY70Aa0HYqwto-gROxT8fvrduNn0MVf=A@mail.gmail.com>
2018-12-18 1:41 ` Michael S. Tsirkin
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=1544676445-14897-1-git-send-email-gchen.guomin@gmail.com \
--to=gchen.guomin@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=ebiederm@xmission.com \
--cc=guominchen@tencent.com \
--cc=jasowang@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@dominikbrodowski.net \
--cc=mcgrof@kernel.org \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=sudipm.mukherjee@gmail.com \
--cc=virtualization@lists.linux-foundation.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