Skip to contentSkip to conversation

drm/radeon: fix copy of uninitialized variable back to userspace

PATCH Applied Colin King 4 participants 4 messages Mar 3, 2021 – Mar 11, 2021

Subsystems (3)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 drm/radeon: fix copy of uninitialized variable back to userspace

From: Colin Ian King <[email protected]>

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)

Fixes 439a1cfffe2c ("drm/radeon: expose render backend mask to the userspace")
---
 drivers/gpu/drm/radeon/radeon_kms.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/radeon/radeon_kms.c +1 -0
index 2479d6ab7a36..58876bb4ef2a 100644
@@ -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:
Signature · 6 lines
2.30.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
maintainer Reviewed-by on v1 1/1
#1 lore raw

Am 03.03.21 um 01:27 schrieb Colin King:

Quoted 8 lines

From: Colin Ian King <[email protected]>

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.

Quoted 4 lines

Addresses-Coverity: ("Uninitialized scalar variable)

Fixes 439a1cfffe2c ("drm/radeon: expose render backend mask to the userspace")

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

Christian.

Quoted 9 lines
---
  drivers/gpu/drm/radeon/radeon_kms.c | 1 +
  1 file changed, 1 insertion(+)
drivers/gpu/drm/radeon/radeon_kms.c +0 -0
index 2479d6ab7a36..58876bb4ef2a 100644

drivers/gpu/drm/radeon/radeon_kms.c int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) · line 524

Quoted 7 lines
drivers/gpu/drm/radeon/radeon_kms.c +1 -0
@@ -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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Applied
#2 lore raw

Applied. Thanks!

Alex

Quoted 34 lines · Christian König

Am 03.03.21 um 01:27 schrieb Colin King:

Quoted 8 lines

From: Colin Ian King <[email protected]>

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.

Quoted 4 lines

Addresses-Coverity: ("Uninitialized scalar variable)

Fixes 439a1cfffe2c ("drm/radeon: expose render backend mask to the userspace")

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

Christian.

Quoted 13 lines
---
  drivers/gpu/drm/radeon/radeon_kms.c | 1 +
  1 file changed, 1 insertion(+)
drivers/gpu/drm/radeon/radeon_kms.c +1 -0
index 2479d6ab7a36..58876bb4ef2a 100644
@@ -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;
Quoted 8 lines

drivers/gpu/drm/radeon/radeon_kms.c int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) · line 524

Quoted 3 lines
drivers/gpu/drm/radeon/radeon_kms.c +0 -0
              }
              break;
      case RADEON_INFO_MAX_SCLK:

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#3 lore raw
In reply to Christian König
Quoted 9 lines · Christian König

Am 03.03.21 um 01:27 schrieb Colin King:

Quoted 8 lines

From: Colin Ian King <[email protected]>

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.

Quoted 8 lines
Quoted 4 lines

Addresses-Coverity: ("Uninitialized scalar variable)

Fixes 439a1cfffe2c ("drm/radeon: expose render backend mask to the userspace")

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

Quoted 20 lines

Christian.

Quoted 16 lines
---
  drivers/gpu/drm/radeon/radeon_kms.c | 1 +
  1 file changed, 1 insertion(+)
drivers/gpu/drm/radeon/radeon_kms.c +1 -0
index 2479d6ab7a36..58876bb4ef2a 100644
@@ -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:
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx