public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: jeffy <jeffy.chen@rock-chips.com>
To: Jeffy Chen <jeffy.chen@rock-chips.com>, linux-kernel@vger.kernel.org
Cc: briannorris@chromium.org, dianders@chromium.org,
	Daniel Vetter <daniel.vetter@intel.com>,
	Jani Nikula <jani.nikula@linux.intel.com>,
	dri-devel@lists.freedesktop.org, David Airlie <airlied@linux.ie>,
	Sean Paul <seanpaul@chromium.org>
Subject: Re: drm: Add missing field copy in compat_drm_version
Date: Thu, 13 Jul 2017 10:20:20 +0800	[thread overview]
Message-ID: <5966D8E4.3050907@rock-chips.com> (raw)
In-Reply-To: <1499840312-23418-1-git-send-email-jeffy.chen@rock-chips.com>

Hi guys,

i was testing this on arm64 base chromeos(with arm32 userspace).

and the libdrm crashed:
     drmVersionPtr drmGetVersion(int fd)
     {
     ...
         memclear(*version);

         if (drmIoctl(fd, DRM_IOCTL_VERSION, version)) {
     ...
         if (version->name_len)
             version->name    = drmMalloc(version->name_len + 1); <-- 
rely on the lengths updated by kernel
         if (version->date_len)
             version->date    = drmMalloc(version->date_len + 1);
         if (version->desc_len)
             version->desc    = drmMalloc(version->desc_len + 1);
     ...
         if (version->name_len) version->name[version->name_len] = '\0'; 
<-- crashed here, since the name_len would always be zero, so 
version->name would be nullptr.


On 07/12/2017 02:18 PM, Jeffy Chen wrote:
> DRM_IOCTL_VERSION is supposed to update the name_len/date_len/desc_len
> fields to user.
>
> Fixes: 012c6741c6aa("switch compat_drm_version() to drm_ioctl_kernel()")
> Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
> ---
>
>   drivers/gpu/drm/drm_ioc32.c | 3 +++
>   1 file changed, 3 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
> index 94acf51..2789356 100644
> --- a/drivers/gpu/drm/drm_ioc32.c
> +++ b/drivers/gpu/drm/drm_ioc32.c
> @@ -112,6 +112,9 @@ static int compat_drm_version(struct file *file, unsigned int cmd,
>   	v32.version_major = v.version_major;
>   	v32.version_minor = v.version_minor;
>   	v32.version_patchlevel = v.version_patchlevel;
> +	v32.name_len = v.name_len;
> +	v32.date_len = v.date_len;
> +	v32.desc_len = v.desc_len;
>   	if (copy_to_user((void __user *)arg, &v32, sizeof(v32)))
>   		return -EFAULT;
>   	return 0;
>
>

  reply	other threads:[~2017-07-13  2:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-12  6:18 [PATCH] drm: Add missing field copy in compat_drm_version Jeffy Chen
2017-07-13  2:20 ` jeffy [this message]
2017-07-13 12:36 ` Daniel Vetter
2017-07-14  1:39   ` Al Viro

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=5966D8E4.3050907@rock-chips.com \
    --to=jeffy.chen@rock-chips.com \
    --cc=airlied@linux.ie \
    --cc=briannorris@chromium.org \
    --cc=daniel.vetter@intel.com \
    --cc=dianders@chromium.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jani.nikula@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=seanpaul@chromium.org \
    /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