All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm: fix NULL pointer access by wrong ioctl
@ 2014-06-18  6:31 yes
  0 siblings, 0 replies; 4+ messages in thread
From: yes @ 2014-06-18  6:31 UTC (permalink / raw)
  To: dri-devel

From: Zhaowei Yuan <zhaowei.yuan@samsung.com>

If user uses wrong ioctl command with _IOC_NONE and argument size
greater than 0, it can cause NULL pointer access from memset of line
463. If _IOC_NONE, don't memset to 0 for kdata.

Signed-off-by: Zhaowei Yuan <zhaowei.yuan@samsung.com>
---
 drivers/gpu/drm/drm_drv.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
 mode change 100644 => 100755 drivers/gpu/drm/drm_drv.c

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
old mode 100644
new mode 100755
index 2ab782c..1a92bcb
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -459,8 +459,9 @@ long drm_ioctl(struct file *filp,
 				retcode = -EFAULT;
 				goto err_i1;
 			}
-		} else
+		} else if (cmd & IOC_OUT) {
 			memset(kdata, 0, usize);
+		}

 		if (ioctl->flags & DRM_UNLOCKED)
 			retcode = func(dev, kdata, file_priv);
--
1.7.9.5

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] drm: fix NULL pointer access by wrong ioctl
@ 2014-06-18  6:33 Zhaowei Yuan
  2014-06-20 14:25 ` David Herrmann
  2014-06-30 16:04 ` Sven Joachim
  0 siblings, 2 replies; 4+ messages in thread
From: Zhaowei Yuan @ 2014-06-18  6:33 UTC (permalink / raw)
  To: dri-devel

If user uses wrong ioctl command with _IOC_NONE and argument size
greater than 0, it can cause NULL pointer access from memset of line
463. If _IOC_NONE, don't memset to 0 for kdata.

Signed-off-by: Zhaowei Yuan <zhaowei.yuan@samsung.com>
---
 drivers/gpu/drm/drm_drv.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
 mode change 100644 => 100755 drivers/gpu/drm/drm_drv.c

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
old mode 100644
new mode 100755
index 2ab782c..1a92bcb
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -459,8 +459,9 @@ long drm_ioctl(struct file *filp,
 				retcode = -EFAULT;
 				goto err_i1;
 			}
-		} else
+		} else if (cmd & IOC_OUT) {
 			memset(kdata, 0, usize);
+		}

 		if (ioctl->flags & DRM_UNLOCKED)
 			retcode = func(dev, kdata, file_priv);
--
1.7.9.5

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm: fix NULL pointer access by wrong ioctl
  2014-06-18  6:33 [PATCH] drm: fix NULL pointer access by wrong ioctl Zhaowei Yuan
@ 2014-06-20 14:25 ` David Herrmann
  2014-06-30 16:04 ` Sven Joachim
  1 sibling, 0 replies; 4+ messages in thread
From: David Herrmann @ 2014-06-20 14:25 UTC (permalink / raw)
  To: Zhaowei Yuan, Daniel Vetter, Dave Airlie; +Cc: dri-devel@lists.freedesktop.org

Hi

On Wed, Jun 18, 2014 at 8:33 AM, Zhaowei Yuan <zhaowei.yuan@samsung.com> wrote:
> If user uses wrong ioctl command with _IOC_NONE and argument size
> greater than 0, it can cause NULL pointer access from memset of line
> 463. If _IOC_NONE, don't memset to 0 for kdata.
>
> Signed-off-by: Zhaowei Yuan <zhaowei.yuan@samsung.com>

Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
Cc: <stable@vger.kernel.org>

@Dave: Imo, this should go through stable. We initialize "kdata" to
NULL, but "usize" can be up to 2^14, so it might write to real memory
there. Most systems probably reserve the lower 64KB and the first
write on the NULL-page should kill the process and have no other
side-effects, however, who knows how memset() is implemented on
different architectures. It might start writing at the end.. or might
issue large writes.. what do I know..

Thanks
David

> ---
>  drivers/gpu/drm/drm_drv.c |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>  mode change 100644 => 100755 drivers/gpu/drm/drm_drv.c
>
> diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
> old mode 100644
> new mode 100755
> index 2ab782c..1a92bcb
> --- a/drivers/gpu/drm/drm_drv.c
> +++ b/drivers/gpu/drm/drm_drv.c
> @@ -459,8 +459,9 @@ long drm_ioctl(struct file *filp,
>                                 retcode = -EFAULT;
>                                 goto err_i1;
>                         }
> -               } else
> +               } else if (cmd & IOC_OUT) {
>                         memset(kdata, 0, usize);
> +               }
>
>                 if (ioctl->flags & DRM_UNLOCKED)
>                         retcode = func(dev, kdata, file_priv);
> --
> 1.7.9.5
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm: fix NULL pointer access by wrong ioctl
  2014-06-18  6:33 [PATCH] drm: fix NULL pointer access by wrong ioctl Zhaowei Yuan
  2014-06-20 14:25 ` David Herrmann
@ 2014-06-30 16:04 ` Sven Joachim
  1 sibling, 0 replies; 4+ messages in thread
From: Sven Joachim @ 2014-06-30 16:04 UTC (permalink / raw)
  To: Zhaowei Yuan; +Cc: dri-devel

On 2014-06-18 08:33 +0200, Zhaowei Yuan wrote:

> If user uses wrong ioctl command with _IOC_NONE and argument size
> greater than 0, it can cause NULL pointer access from memset of line
> 463. If _IOC_NONE, don't memset to 0 for kdata.
>
> Signed-off-by: Zhaowei Yuan <zhaowei.yuan@samsung.com>
> ---
>  drivers/gpu/drm/drm_drv.c |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>  mode change 100644 => 100755 drivers/gpu/drm/drm_drv.c

The mode change certainly was not intentional, was it?  Just noticed it
when I pulled 3.16-rc3 from Linus…

> diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
> old mode 100644
> new mode 100755
> index 2ab782c..1a92bcb
> --- a/drivers/gpu/drm/drm_drv.c
> +++ b/drivers/gpu/drm/drm_drv.c
> @@ -459,8 +459,9 @@ long drm_ioctl(struct file *filp,
>  				retcode = -EFAULT;
>  				goto err_i1;
>  			}
> -		} else
> +		} else if (cmd & IOC_OUT) {
>  			memset(kdata, 0, usize);
> +		}
>
>  		if (ioctl->flags & DRM_UNLOCKED)
>  			retcode = func(dev, kdata, file_priv);


Cheers,
       Sven
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-06-30 16:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-18  6:33 [PATCH] drm: fix NULL pointer access by wrong ioctl Zhaowei Yuan
2014-06-20 14:25 ` David Herrmann
2014-06-30 16:04 ` Sven Joachim
  -- strict thread matches above, loose matches on Subject: below --
2014-06-18  6:31 yes

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.