From: Thomas Hellstrom <thellstrom@vmware.com>
To: Xi Wang <xi.wang@gmail.com>
Cc: David Airlie <airlied@redhat.com>, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH -fixes] vmwgfx: fix incorrect VRAM size check in vmw_kms_fb_create()
Date: Wed, 21 Dec 2011 13:22:57 +0100 [thread overview]
Message-ID: <4EF1CFA1.9040005@vmware.com> (raw)
In-Reply-To: <4EF1B279.2090907@gmail.com>
This looks good, although I want to do a quick test to verify that it
doesn't break anything.
I'll get back as soon as possible.
/Thomas
On 12/21/2011 11:18 AM, Xi Wang wrote:
> Commit e133e737 didn't correctly fix the integer overflow issue.
>
> - unsigned int required_size;
> + u64 required_size;
> ...
> required_size = mode_cmd->pitch * mode_cmd->height;
> - if (unlikely(required_size> dev_priv->vram_size)) {
> + if (unlikely(required_size> (u64) dev_priv->vram_size)) {
>
> Note that both pitch and height are u32. Their product is still u32 and
> would overflow before being assigned to required_size. A correct way is
> to convert pitch and height to u64 before the multiplication.
>
> required_size = (u64)mode_cmd->pitch * (u64)mode_cmd->height;
>
> This patch calls the existing vmw_kms_validate_mode_vram() for
> validation.
>
> Signed-off-by: Xi Wang<xi.wang@gmail.com>
> ---
> drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 6 +++---
> 1 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> index 8aa1dbb..f94b33a 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> @@ -1093,7 +1093,6 @@ static struct drm_framebuffer *vmw_kms_fb_create(struct drm_device *dev,
> struct vmw_surface *surface = NULL;
> struct vmw_dma_buffer *bo = NULL;
> struct ttm_base_object *user_obj;
> - u64 required_size;
> int ret;
>
> /**
> @@ -1102,8 +1101,9 @@ static struct drm_framebuffer *vmw_kms_fb_create(struct drm_device *dev,
> * requested framebuffer.
> */
>
> - required_size = mode_cmd->pitch * mode_cmd->height;
> - if (unlikely(required_size> (u64) dev_priv->vram_size)) {
> + if (!vmw_kms_validate_mode_vram(dev_priv,
> + mode_cmd->pitch,
> + mode_cmd->height)) {
> DRM_ERROR("VRAM size is too small for requested mode.\n");
> return ERR_PTR(-ENOMEM);
> }
>
next prev parent reply other threads:[~2011-12-21 12:26 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-20 21:08 [PATCH RESEND] vmwgfx: fix incorrect vram size check in vmw_kms_fb_create() Xi Wang
2011-12-21 9:30 ` David Airlie
2011-12-21 9:33 ` Xi Wang
2011-12-21 10:18 ` [PATCH -fixes] vmwgfx: fix incorrect VRAM " Xi Wang
2011-12-21 12:22 ` Thomas Hellstrom [this message]
2011-12-21 21:33 ` Thomas Hellstrom
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=4EF1CFA1.9040005@vmware.com \
--to=thellstrom@vmware.com \
--cc=airlied@redhat.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=xi.wang@gmail.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.