kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/radeon: fix copy of uninitialized variable back to userspace
@ 2021-03-03  0:27 Colin King
  2021-03-03  7:42 ` Christian König
  0 siblings, 1 reply; 4+ messages in thread
From: Colin King @ 2021-03-03  0:27 UTC (permalink / raw)
  To: Alex Deucher, Christian König, David Airlie, Daniel Vetter,
	Marek Olšák, amd-gfx, dri-devel
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

Currently the ioctl command RADEON_INFO_SI_BACKEND_ENABLED_MASK can
copy back uninitialised data in value_tmp that pointer *value points
to. This can occur when rdev->family is less than CHIP_BONAIRE and
less than CHIP_TAHITI.  Fix this by adding in a missing -EINVAL
so that no invalid value is copied back to userspace.

Addresses-Coverity: ("Uninitialized scalar variable)
Cc: stable@vger.kernel.org # 3.13+
Fixes: 439a1cfffe2c ("drm/radeon: expose render backend mask to the userspace")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/gpu/drm/radeon/radeon_kms.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c
index 2479d6ab7a36..58876bb4ef2a 100644
--- a/drivers/gpu/drm/radeon/radeon_kms.c
+++ b/drivers/gpu/drm/radeon/radeon_kms.c
@@ -518,6 +518,7 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
 			*value = rdev->config.si.backend_enable_mask;
 		} else {
 			DRM_DEBUG_KMS("BACKEND_ENABLED_MASK is si+ only!\n");
+			return -EINVAL;
 		}
 		break;
 	case RADEON_INFO_MAX_SCLK:
-- 
2.30.0


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

* Re: [PATCH] drm/radeon: fix copy of uninitialized variable back to userspace
  2021-03-03  0:27 [PATCH] drm/radeon: fix copy of uninitialized variable back to userspace Colin King
@ 2021-03-03  7:42 ` Christian König
  2021-03-03 15:03   ` Alex Deucher
  2021-03-11 13:10   ` Daniel Vetter
  0 siblings, 2 replies; 4+ messages in thread
From: Christian König @ 2021-03-03  7:42 UTC (permalink / raw)
  To: Colin King, Alex Deucher, David Airlie, Daniel Vetter,
	Marek Olšák, amd-gfx, dri-devel
  Cc: kernel-janitors, linux-kernel

Am 03.03.21 um 01:27 schrieb Colin King:
> From: Colin Ian King <colin.king@canonical.com>
>
> Currently the ioctl command RADEON_INFO_SI_BACKEND_ENABLED_MASK can
> copy back uninitialised data in value_tmp that pointer *value points
> to. This can occur when rdev->family is less than CHIP_BONAIRE and
> less than CHIP_TAHITI.  Fix this by adding in a missing -EINVAL
> so that no invalid value is copied back to userspace.
>
> Addresses-Coverity: ("Uninitialized scalar variable)
> Cc: stable@vger.kernel.org # 3.13+
> Fixes: 439a1cfffe2c ("drm/radeon: expose render backend mask to the userspace")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Reviewed-by: Christian König <christian.koenig@amd.com>

Let's hope that this doesn't break UAPI.

Christian.

> ---
>   drivers/gpu/drm/radeon/radeon_kms.c | 1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c
> index 2479d6ab7a36..58876bb4ef2a 100644
> --- a/drivers/gpu/drm/radeon/radeon_kms.c
> +++ b/drivers/gpu/drm/radeon/radeon_kms.c
> @@ -518,6 +518,7 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
>   			*value = rdev->config.si.backend_enable_mask;
>   		} else {
>   			DRM_DEBUG_KMS("BACKEND_ENABLED_MASK is si+ only!\n");
> +			return -EINVAL;
>   		}
>   		break;
>   	case RADEON_INFO_MAX_SCLK:


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

* Re: [PATCH] drm/radeon: fix copy of uninitialized variable back to userspace
  2021-03-03  7:42 ` Christian König
@ 2021-03-03 15:03   ` Alex Deucher
  2021-03-11 13:10   ` Daniel Vetter
  1 sibling, 0 replies; 4+ messages in thread
From: Alex Deucher @ 2021-03-03 15:03 UTC (permalink / raw)
  To: Christian König
  Cc: Colin King, Alex Deucher, David Airlie, Daniel Vetter,
	Marek Olšák, amd-gfx list,
	Maling list - DRI developers, kernel-janitors, LKML

Applied.  Thanks!

Alex

On Wed, Mar 3, 2021 at 2:42 AM Christian König <christian.koenig@amd.com> wrote:
>
> Am 03.03.21 um 01:27 schrieb Colin King:
> > From: Colin Ian King <colin.king@canonical.com>
> >
> > Currently the ioctl command RADEON_INFO_SI_BACKEND_ENABLED_MASK can
> > copy back uninitialised data in value_tmp that pointer *value points
> > to. This can occur when rdev->family is less than CHIP_BONAIRE and
> > less than CHIP_TAHITI.  Fix this by adding in a missing -EINVAL
> > so that no invalid value is copied back to userspace.
> >
> > Addresses-Coverity: ("Uninitialized scalar variable)
> > Cc: stable@vger.kernel.org # 3.13+
> > Fixes: 439a1cfffe2c ("drm/radeon: expose render backend mask to the userspace")
> > Signed-off-by: Colin Ian King <colin.king@canonical.com>
>
> Reviewed-by: Christian König <christian.koenig@amd.com>
>
> Let's hope that this doesn't break UAPI.
>
> Christian.
>
> > ---
> >   drivers/gpu/drm/radeon/radeon_kms.c | 1 +
> >   1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c
> > index 2479d6ab7a36..58876bb4ef2a 100644
> > --- a/drivers/gpu/drm/radeon/radeon_kms.c
> > +++ b/drivers/gpu/drm/radeon/radeon_kms.c
> > @@ -518,6 +518,7 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
> >                       *value = rdev->config.si.backend_enable_mask;
> >               } else {
> >                       DRM_DEBUG_KMS("BACKEND_ENABLED_MASK is si+ only!\n");
> > +                     return -EINVAL;
> >               }
> >               break;
> >       case RADEON_INFO_MAX_SCLK:
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

* Re: [PATCH] drm/radeon: fix copy of uninitialized variable back to userspace
  2021-03-03  7:42 ` Christian König
  2021-03-03 15:03   ` Alex Deucher
@ 2021-03-11 13:10   ` Daniel Vetter
  1 sibling, 0 replies; 4+ messages in thread
From: Daniel Vetter @ 2021-03-11 13:10 UTC (permalink / raw)
  To: Christian König
  Cc: Colin King, Alex Deucher, David Airlie, Daniel Vetter,
	Marek Olšák, amd-gfx, dri-devel, kernel-janitors,
	linux-kernel

On Wed, Mar 03, 2021 at 08:42:31AM +0100, Christian König wrote:
> Am 03.03.21 um 01:27 schrieb Colin King:
> > From: Colin Ian King <colin.king@canonical.com>
> > 
> > Currently the ioctl command RADEON_INFO_SI_BACKEND_ENABLED_MASK can
> > copy back uninitialised data in value_tmp that pointer *value points
> > to. This can occur when rdev->family is less than CHIP_BONAIRE and
> > less than CHIP_TAHITI.  Fix this by adding in a missing -EINVAL
> > so that no invalid value is copied back to userspace.
> > 
> > Addresses-Coverity: ("Uninitialized scalar variable)
> > Cc: stable@vger.kernel.org # 3.13+
> > Fixes: 439a1cfffe2c ("drm/radeon: expose render backend mask to the userspace")
> > Signed-off-by: Colin Ian King <colin.king@canonical.com>
> 
> Reviewed-by: Christian König <christian.koenig@amd.com>
> 
> Let's hope that this doesn't break UAPI.

If it does I think the only difference would be errno userspace sees
(aside from the stack garbage, which we could also emulate). Switching to
return 0; is easy. So no worries this would be a problem :-)
-Daniel

> 
> Christian.
> 
> > ---
> >   drivers/gpu/drm/radeon/radeon_kms.c | 1 +
> >   1 file changed, 1 insertion(+)
> > 
> > diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c
> > index 2479d6ab7a36..58876bb4ef2a 100644
> > --- a/drivers/gpu/drm/radeon/radeon_kms.c
> > +++ b/drivers/gpu/drm/radeon/radeon_kms.c
> > @@ -518,6 +518,7 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
> >   			*value = rdev->config.si.backend_enable_mask;
> >   		} else {
> >   			DRM_DEBUG_KMS("BACKEND_ENABLED_MASK is si+ only!\n");
> > +			return -EINVAL;
> >   		}
> >   		break;
> >   	case RADEON_INFO_MAX_SCLK:
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

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

end of thread, other threads:[~2021-03-11 13:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-03  0:27 [PATCH] drm/radeon: fix copy of uninitialized variable back to userspace Colin King
2021-03-03  7:42 ` Christian König
2021-03-03 15:03   ` Alex Deucher
2021-03-11 13:10   ` Daniel Vetter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).