From: Kees Cook <keescook@chromium.org>
To: Yan Zhao <yan.y.zhao@intel.com>
Cc: alex.williamson@redhat.com, cohuck@redhat.com,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] vfio: checking of validity of user vaddr in vfio_dma_rw
Date: Wed, 8 Apr 2020 09:59:44 -0700 [thread overview]
Message-ID: <202004080959.8C71F8DF7@keescook> (raw)
In-Reply-To: <20200408071121.25645-1-yan.y.zhao@intel.com>
On Wed, Apr 08, 2020 at 03:11:21AM -0400, Yan Zhao wrote:
> instead of calling __copy_to/from_user(), use copy_to_from_user() to
> ensure vaddr range is a valid user address range before accessing them.
>
> Cc: Kees Cook <keescook@chromium.org>
>
> Fixes: 8d46c0cca5f4 ("vfio: introduce vfio_dma_rw to read/write a range of IOVAs")
> Signed-off-by: Yan Zhao <yan.y.zhao@intel.com>
Thanks!
Reported-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
-Kees
> ---
> drivers/vfio/vfio_iommu_type1.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
> index 3aefcc8e2933..fbc58284b333 100644
> --- a/drivers/vfio/vfio_iommu_type1.c
> +++ b/drivers/vfio/vfio_iommu_type1.c
> @@ -2345,10 +2345,10 @@ static int vfio_iommu_type1_dma_rw_chunk(struct vfio_iommu *iommu,
> vaddr = dma->vaddr + offset;
>
> if (write)
> - *copied = __copy_to_user((void __user *)vaddr, data,
> + *copied = copy_to_user((void __user *)vaddr, data,
> count) ? 0 : count;
> else
> - *copied = __copy_from_user(data, (void __user *)vaddr,
> + *copied = copy_from_user(data, (void __user *)vaddr,
> count) ? 0 : count;
> if (kthread)
> unuse_mm(mm);
> --
> 2.17.1
>
--
Kees Cook
prev parent reply other threads:[~2020-04-08 16:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-08 7:11 [PATCH] vfio: checking of validity of user vaddr in vfio_dma_rw Yan Zhao
2020-04-08 16:59 ` Kees Cook [this message]
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=202004080959.8C71F8DF7@keescook \
--to=keescook@chromium.org \
--cc=alex.williamson@redhat.com \
--cc=cohuck@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=yan.y.zhao@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.