* [PATCH] drm: Add missing field copy in compat_drm_version
@ 2017-07-12 6:18 Jeffy Chen
2017-07-13 2:20 ` jeffy
2017-07-13 12:36 ` [PATCH] " Daniel Vetter
0 siblings, 2 replies; 4+ messages in thread
From: Jeffy Chen @ 2017-07-12 6:18 UTC (permalink / raw)
To: linux-kernel
Cc: briannorris, dianders, Jeffy Chen, Daniel Vetter, Jani Nikula,
dri-devel, David Airlie, Sean Paul
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;
--
2.1.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: drm: Add missing field copy in compat_drm_version
2017-07-12 6:18 [PATCH] drm: Add missing field copy in compat_drm_version Jeffy Chen
@ 2017-07-13 2:20 ` jeffy
2017-07-13 12:36 ` [PATCH] " Daniel Vetter
1 sibling, 0 replies; 4+ messages in thread
From: jeffy @ 2017-07-13 2:20 UTC (permalink / raw)
To: Jeffy Chen, linux-kernel
Cc: briannorris, dianders, Daniel Vetter, Jani Nikula, dri-devel,
David Airlie, Sean Paul
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;
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] drm: Add missing field copy in compat_drm_version
2017-07-12 6:18 [PATCH] drm: Add missing field copy in compat_drm_version Jeffy Chen
2017-07-13 2:20 ` jeffy
@ 2017-07-13 12:36 ` Daniel Vetter
2017-07-14 1:39 ` Al Viro
1 sibling, 1 reply; 4+ messages in thread
From: Daniel Vetter @ 2017-07-13 12:36 UTC (permalink / raw)
To: Jeffy Chen, Linus Torvalds, Dave Airlie
Cc: linux-kernel, briannorris, dianders, dri-devel, Daniel Vetter
On Wed, Jul 12, 2017 at 02:18:32PM +0800, 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>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Linus, since Dave is a bit out with flu and this bug only exists in your
tree (not yet in drm-next), can you pls apply this directly? It's a fumble
in Al's rework. Direct mbox link from patchwork, in case you don't have
that in your archives anywhere:
https://patchwork.freedesktop.org/patch/166318/mbox/
Thanks, Daniel
>
> ---
>
> 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;
> --
> 2.1.4
>
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] drm: Add missing field copy in compat_drm_version
2017-07-13 12:36 ` [PATCH] " Daniel Vetter
@ 2017-07-14 1:39 ` Al Viro
0 siblings, 0 replies; 4+ messages in thread
From: Al Viro @ 2017-07-14 1:39 UTC (permalink / raw)
To: Jeffy Chen, Linus Torvalds, Dave Airlie, linux-kernel,
briannorris, dianders, dri-devel, Daniel Vetter
On Thu, Jul 13, 2017 at 02:36:55PM +0200, Daniel Vetter wrote:
> On Wed, Jul 12, 2017 at 02:18:32PM +0800, 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>
>
> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
>
> Linus, since Dave is a bit out with flu and this bug only exists in your
> tree (not yet in drm-next), can you pls apply this directly? It's a fumble
> in Al's rework. Direct mbox link from patchwork, in case you don't have
> that in your archives anywhere:
(Belated) ACKed-by: Al Viro <viro@zeniv.linux.org.uk>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-07-14 1:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-12 6:18 [PATCH] drm: Add missing field copy in compat_drm_version Jeffy Chen
2017-07-13 2:20 ` jeffy
2017-07-13 12:36 ` [PATCH] " Daniel Vetter
2017-07-14 1:39 ` Al Viro
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox