From: Jason Gunthorpe <jgg@nvidia.com>
To: "Tian, Kevin" <kevin.tian@intel.com>
Cc: Alex Williamson <alex.williamson@redhat.com>,
Cornelia Huck <cohuck@redhat.com>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
Xiao Guangrong <guangrong.xiao@linux.intel.com>,
Jike Song <jike.song@intel.com>,
Kirti Wankhede <kwankhede@nvidia.com>,
Nicolin Chen <nicolinc@nvidia.com>,
Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH 1/6] vfio: Add missing locking for struct vfio_group::kvm
Date: Fri, 13 May 2022 10:16:21 -0300 [thread overview]
Message-ID: <20220513131621.GA1457796@nvidia.com> (raw)
In-Reply-To: <BN9PR11MB5276C75E8FDB277D5BD6A42C8CCA9@BN9PR11MB5276.namprd11.prod.outlook.com>
On Fri, May 13, 2022 at 09:08:06AM +0000, Tian, Kevin wrote:
> > From: Jason Gunthorpe <jgg@nvidia.com>
> > Sent: Friday, May 6, 2022 8:25 AM
> >
> > Without locking userspace can trigger a UAF by racing
> > KVM_DEV_VFIO_GROUP_DEL with VFIO_GROUP_GET_DEVICE_FD:
> >
> > CPU1 CPU2
> > ioctl(KVM_DEV_VFIO_GROUP_DEL)
> > ioctl(VFIO_GROUP_GET_DEVICE_FD)
> > vfio_group_get_device_fd
> > open_device()
> > intel_vgpu_open_device()
> > vfio_register_notifier()
> > vfio_register_group_notifier()
> > blocking_notifier_call_chain(&group->notifier,
> > VFIO_GROUP_NOTIFY_SET_KVM, group->kvm);
> >
> > set_kvm()
> > group->kvm = NULL
> > close()
> > kfree(kvm)
> >
> > intel_vgpu_group_notifier()
> > vdev->kvm = data
> > [..]
> > kvmgt_guest_init()
> > kvm_get_kvm(info->kvm);
> > // UAF!
> >
>
> this doesn't match the latest code since kvmgt_guest_init() has
> been removed.
>
> With the new code UAF will occur in an earlier place:
>
> ret = -ESRCH;
> if (!vgpu->kvm || vgpu->kvm->mm != current->mm) {
> gvt_vgpu_err("KVM is required to use Intel vGPU\n");
> goto undo_register;
> }
>
> ...
> kvm_get_kvm(vgpu->kvm);
Right thanks
I just dropped the kvmgt_guest_init() since it is all in the same
function now.
This needs fixing as Christoph suggested by making the KVM some
integral part of the VFIO so it can't just randomly disappear under a
VFIO driver that requires it.
Jason
next prev parent reply other threads:[~2022-05-13 13:16 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-06 0:25 [PATCH 0/6] Fully lock the container members of struct vfio_group Jason Gunthorpe
2022-05-06 0:25 ` [PATCH 1/6] vfio: Add missing locking for struct vfio_group::kvm Jason Gunthorpe
2022-05-13 9:08 ` Tian, Kevin
2022-05-13 13:16 ` Jason Gunthorpe [this message]
2022-05-06 0:25 ` [PATCH 2/6] vfio: Change struct vfio_group::opened from an atomic to bool Jason Gunthorpe
2022-05-13 9:10 ` Tian, Kevin
2022-05-06 0:25 ` [PATCH 3/6] vfio: Split up vfio_group_get_device_fd() Jason Gunthorpe
2022-05-10 19:59 ` Alex Williamson
2022-05-10 23:48 ` Jason Gunthorpe
2022-05-13 9:40 ` Tian, Kevin
2022-05-06 0:25 ` [PATCH 4/6] vfio: Fully lock struct vfio_group::container Jason Gunthorpe
2022-05-13 9:53 ` Tian, Kevin
2022-05-13 13:29 ` Jason Gunthorpe
2022-05-06 0:25 ` [PATCH 5/6] vfio: Simplify the life cycle of the group FD Jason Gunthorpe
2022-05-10 19:59 ` Alex Williamson
2022-05-12 23:35 ` Jason Gunthorpe
2022-05-13 9:57 ` Tian, Kevin
2022-05-06 0:25 ` [PATCH 6/6] vfio: Change struct vfio_group::container_users to a non-atomic int Jason Gunthorpe
2022-05-13 10:01 ` Tian, Kevin
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=20220513131621.GA1457796@nvidia.com \
--to=jgg@nvidia.com \
--cc=alex.williamson@redhat.com \
--cc=cohuck@redhat.com \
--cc=guangrong.xiao@linux.intel.com \
--cc=jike.song@intel.com \
--cc=kevin.tian@intel.com \
--cc=kvm@vger.kernel.org \
--cc=kwankhede@nvidia.com \
--cc=nicolinc@nvidia.com \
--cc=pbonzini@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