linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: gchen chen <gchen.guomin@gmail.com>
To: Michal Hocko <mhocko@kernel.org>
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
	Jason Wang <jasowang@redhat.com>,
	Christoph Hellwig <hch@infradead.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	"Luis R. Rodriguez" <mcgrof@kernel.org>,
	gchen <guominchen@tencent.com>,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	Dominik Brodowski <linux@dominikbrodowski.net>,
	Arnd Bergmann <arnd@arndb.de>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH] Fix mm->owner point to a tsk that has been free
Date: Wed, 19 Dec 2018 00:21:27 +0800	[thread overview]
Message-ID: <CAEEwsfRb-FDCLp-b3-n2+vvgWttv6FQhjkLxpJwA==_+89iY=w@mail.gmail.com> (raw)
In-Reply-To: <20181218095226.GD17870@dhcp22.suse.cz>

[-- Attachment #1: Type: text/plain, Size: 2228 bytes --]

Oh, yes, the patch 39af176 has been skip the kthread
on mm_update_next_owner .
Thanks for your tips.

thanks and regards


Michal Hocko <mhocko@kernel.org> 于2018年12月18日周二 下午5:52写道:

> On Tue 18-12-18 13:24:44, gchen.guomin@gmail.com wrote:
> > From: guomin chen <gchen.guomin@gmail.com>
> >
> > When mm->owner is modified by exit_mm, if the new owner directly calls
> > unuse_mm to exit, it will cause Use-After-Free. Due to the unuse_mm()
> > directly sets tsk->mm=NULL.
> >
> >  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.
> >
> > The current issue flow is as follows: (Process A,B,C use the same mm)
> > Process C              Process A         Process B
> > qemu-system-x86_64:     kernel:vhost_net  kernel: vhost_net
> > open /dev/vhost-net
> >   VHOST_SET_OWNER   create kthread vhost-%d  create kthread vhost-%d
> >   network init           use_mm()          use_mm()
> >    ...                   ...
> >    Abnormal exited
> >    ...
> >   do_exit
> >   exit_mm()
> >   update mm->owner to A
> >   exit_files()
> >    close_files()
> >    kthread_should_stop() unuse_mm()
> >     Stop Process A       tsk->mm=NULL
> >                          do_exit()
> >                          can't update owner
> >                          A exit completed  vhost-%d  rcv first package
> >                                            vhost-%d build rcv buffer for
> vq
> >                                            page fault
> >                                            access mm & mm->owner
> >                                            NOW,mm->owner still pointer A
> >                                            kernel UAF
> >     stop Process B
> >
> > Although I am having this issue on vhost_net,But it affects all users of
> > unuse_mm.
>
> I am confused. How can we ever assign the owner to a kernel thread. We
> skip those explicitly. It simply doesn't make any sense to have an owner
> a kernel thread.
> --
> Michal Hocko
> SUSE Labs
>

[-- Attachment #2: Type: text/html, Size: 3213 bytes --]

  reply	other threads:[~2018-12-18 16:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-18  5:24 gchen.guomin
2018-12-18  9:52 ` Michal Hocko
2018-12-18 16:21   ` gchen chen [this message]
2018-12-18 16:31     ` Matthew Wilcox

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='CAEEwsfRb-FDCLp-b3-n2+vvgWttv6FQhjkLxpJwA==_+89iY=w@mail.gmail.com' \
    --to=gchen.guomin@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=ebiederm@xmission.com \
    --cc=guominchen@tencent.com \
    --cc=hch@infradead.org \
    --cc=jasowang@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux@dominikbrodowski.net \
    --cc=mcgrof@kernel.org \
    --cc=mhocko@kernel.org \
    --cc=mst@redhat.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