From: Andy Walls <awalls@md.metrocast.net>
To: Tom Lyon <pugs@cisco.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] VFIO V4: VFIO driver: Non-privileged user level PCI drivers
Date: Thu, 23 Sep 2010 08:58:01 -0400 [thread overview]
Message-ID: <1285246681.6715.11.camel@morgan.silverblock.net> (raw)
> +ssize_t vfio_io_readwrite(
> + int write,
> + struct vfio_dev *vdev,
> + char __user *buf,
> + size_t count,
> + loff_t *ppos)
> +{
> + struct pci_dev *pdev = vdev->pdev;
> + size_t done = 0;
> + resource_size_t end;
> + void __iomem *io;
> + loff_t pos;
> + int pci_space;
> + int unit;
> +
> + pci_space = vfio_offset_to_pci_space(*ppos);
> + pos = vfio_offset_to_pci_offset(*ppos);
> +
> + if (!pci_resource_start(pdev, pci_space))
> + return -EINVAL;
> + end = pci_resource_len(pdev, pci_space);
> + if (pos + count > end)
> + return -EINVAL;
> + if (vdev->barmap[pci_space] == NULL)
> + vdev->barmap[pci_space] = pci_iomap(pdev, pci_space, 0);
Hi Tom,
pci_iomap() can possibly return NULL here and also in
vfio_mem_readwrite(). Even if there are no security implications
(unintended access to low I/O ports?), I think you still have potential
for an Oops in the code below.
... unless there's a reason why pci_iomap() can't possibly return NULL
in these instances. Maybe I'm missing something.
Regards,
Andy
> + io = vdev->barmap[pci_space];
> +
> + while (count > 0) {
> + if ((pos % 4) == 0 && count >= 4) {
> + u32 val;
> +
> + if (write) {
> + if (copy_from_user(&val, buf, 4))
> + return -EFAULT;
> + iowrite32(val, io + pos);
> + } else {
> + val = ioread32(io + pos);
> + if (copy_to_user(buf, &val, 4))
> + return -EFAULT;
> + }
> + unit = 4;
> + } else if ((pos % 2) == 0 && count >= 2) {
next reply other threads:[~2010-09-23 12:57 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-23 12:58 Andy Walls [this message]
2010-09-23 19:33 ` Tom Lyon
-- strict thread matches above, loose matches on Subject: below --
2010-09-22 21:18 Tom Lyon
2010-09-26 14:54 ` Michael S. Tsirkin
2010-09-30 21:43 ` Tom Lyon
2010-10-03 12:27 ` Michael S. Tsirkin
2010-09-27 11:54 ` Michael S. Tsirkin
2010-09-27 20:57 ` Alex Williamson
2010-09-28 10:14 ` Michael S. Tsirkin
2010-09-30 23:09 ` Tom Lyon
2010-10-03 13:02 ` Michael S. Tsirkin
2010-09-27 20:41 ` Alex Williamson
2010-10-15 22:29 ` Tom Lyon
2010-09-27 20:46 ` Alex Williamson
2010-09-28 10:09 ` Michael S. Tsirkin
2010-09-28 14:26 ` Alex Williamson
2010-09-28 14:40 ` Michael S. Tsirkin
2010-09-28 17:10 ` Alex Williamson
2010-09-28 17:36 ` 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=1285246681.6715.11.camel@morgan.silverblock.net \
--to=awalls@md.metrocast.net \
--cc=linux-kernel@vger.kernel.org \
--cc=pugs@cisco.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
Powered by JetHome