From: "Martin Krastev (VMware)" <martinkrastev768@gmail.com>
To: Dawei Li <set_pte_at@outlook.com>,
zackr@vmware.com, airlied@gmail.com, daniel@ffwll.ch
Cc: krastevm@vmware.com, linux-graphics-maintainer@vmware.com,
linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v3] drm/vmwgfx: Fix race issue calling pin_user_pages
Date: Wed, 9 Nov 2022 17:55:22 +0200 [thread overview]
Message-ID: <42515e33-3f99-83d5-d14b-3b8e00d97b4a@gmail.com> (raw)
In-Reply-To: <TYWP286MB23193621CB443E1E1959A00BCA3E9@TYWP286MB2319.JPNP286.PROD.OUTLOOK.COM>
From: Martin Krastev <krastevm@vmware.com>
Looks great!
Reviewed-by: Martin Krastev <krastevm@vmware.com>
Regards,
Martin
On 9.11.22 г. 17:37 ч., Dawei Li wrote:
> pin_user_pages() is unsafe without protection of mmap_lock,
> fix it by calling pin_user_pages_fast().
>
> Fixes: 7a7a933edd6c ("drm/vmwgfx: Introduce VMware mks-guest-stats")
> Signed-off-by: Dawei Li <set_pte_at@outlook.com>
> ---
> v1:
> https://lore.kernel.org/all/TYCP286MB23235C9A9FCF85C045F95EA7CA4F9@TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM/
>
> v1->v2:
> Rebased to latest vmwgfx/drm-misc-fixes.
>
> v2->v3
> Replace pin_user_pages() with pin_user_pages_fast().
> ---
> drivers/gpu/drm/vmwgfx/vmwgfx_msg.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
> index 089046fa21be..50fa3df0bc0c 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
> @@ -1085,21 +1085,21 @@ int vmw_mksstat_add_ioctl(struct drm_device *dev, void *data,
> reset_ppn_array(pdesc->strsPPNs, ARRAY_SIZE(pdesc->strsPPNs));
>
> /* Pin mksGuestStat user pages and store those in the instance descriptor */
> - nr_pinned_stat = pin_user_pages(arg->stat, num_pages_stat, FOLL_LONGTERM, pages_stat, NULL);
> + nr_pinned_stat = pin_user_pages_fast(arg->stat, num_pages_stat, FOLL_LONGTERM, pages_stat);
> if (num_pages_stat != nr_pinned_stat)
> goto err_pin_stat;
>
> for (i = 0; i < num_pages_stat; ++i)
> pdesc->statPPNs[i] = page_to_pfn(pages_stat[i]);
>
> - nr_pinned_info = pin_user_pages(arg->info, num_pages_info, FOLL_LONGTERM, pages_info, NULL);
> + nr_pinned_info = pin_user_pages_fast(arg->info, num_pages_info, FOLL_LONGTERM, pages_info);
> if (num_pages_info != nr_pinned_info)
> goto err_pin_info;
>
> for (i = 0; i < num_pages_info; ++i)
> pdesc->infoPPNs[i] = page_to_pfn(pages_info[i]);
>
> - nr_pinned_strs = pin_user_pages(arg->strs, num_pages_strs, FOLL_LONGTERM, pages_strs, NULL);
> + nr_pinned_strs = pin_user_pages_fast(arg->strs, num_pages_strs, FOLL_LONGTERM, pages_strs);
> if (num_pages_strs != nr_pinned_strs)
> goto err_pin_strs;
>
next prev parent reply other threads:[~2022-11-09 15:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-09 15:37 Dawei Li
2022-11-09 15:55 ` Martin Krastev (VMware) [this message]
2022-11-28 14:56 ` Dawei Li
2022-11-29 14:47 ` Zack Rusin
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=42515e33-3f99-83d5-d14b-3b8e00d97b4a@gmail.com \
--to=martinkrastev768@gmail.com \
--cc=airlied@gmail.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=krastevm@vmware.com \
--cc=linux-graphics-maintainer@vmware.com \
--cc=linux-kernel@vger.kernel.org \
--cc=set_pte_at@outlook.com \
--cc=zackr@vmware.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
all inboxes | Powered by JetHome®