drm/amd/amdgpu: default to zero number of states if not enabled
Subsystems (2)
PATCH 1/1 drm/amd/amdgpu: default to zero number of states if not enabled
From: Colin Ian King <[email protected]>
Currently, if adev->pp_enabled is false then the pp_stats_info data is not read and hence a garbage number of states from the stack is used to dump out the number of states. Given data.nums could be any random value, this could easily lead to read outside the data.states array. Fix this by setting data.nums to zero if adev->pp_enabled is false.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +2 -0
@@ -195,6 +195,8 @@ static ssize_t amdgpu_get_pp_num_states(struct device *dev,if (adev->pp_enabled)amdgpu_dpm_get_pp_num_states (adev, &data); +else + data.nums =0 ; buf_len =snprintf (buf,PAGE_SIZE ,"states: %d\n" , data.nums);for (i =0 ; i < data.nums; i++)
Signature · 6 lines
2.9.3 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 8 lines · Colin King
From: Colin Ian King <[email protected]>
Currently, if
adev->pp_enabledis false then thepp_stats_infodata is not read and hence a garbage number of states from the stack is used to dump out the number of states. Given data.nums could be any random value, this could easily lead to read outside the data.states array. Fix this by setting data.nums to zero ifadev->pp_enabledis false.
Are you actually seeing a problem? The pp_num_states attribute only gets added in the first place if pp_enabled is true.
Alex
Quoted 22 lines
Signed-off-by Colin Ian King <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 2 ++ 1 file changed, 2 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +2
-1@@ -195,6 +195,8 @@ static ssize_t amdgpu_get_pp_num_states(struct device *dev,if (adev->pp_enabled)amdgpu_dpm_get_pp_num_states (adev, &data); +else + data.nums =0 ; buf_len =snprintf (buf,PAGE_SIZE ,"states: %d\n" , data.nums);for (i =0 ; i < data.nums; i++) --2.9.3
Quoted 4 lines
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 11 lines · Alex Deucher
Quoted 8 lines · Colin King
From: Colin Ian King <[email protected]>
Currently, if
adev->pp_enabledis false then thepp_stats_infodata is not read and hence a garbage number of states from the stack is used to dump out the number of states. Given data.nums could be any random value, this could easily lead to read outside the data.states array. Fix this by setting data.nums to zero ifadev->pp_enabledis false.Are you actually seeing a problem?
Nope.
Quoted 2 lines
The
pp_num_statesattribute only
gets added in the first place ifpp_enabledis true.
Does that mean that the check on adev->pp_enabled is redundant then?
Quoted 26 lines
Alex
Quoted 22 lines
Signed-off-by Colin Ian King <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 2 ++ 1 file changed, 2 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +2
-1@@ -195,6 +195,8 @@ static ssize_t amdgpu_get_pp_num_states(struct device *dev,if (adev->pp_enabled)amdgpu_dpm_get_pp_num_states (adev, &data); +else + data.nums =0 ; buf_len =snprintf (buf,PAGE_SIZE ,"states: %d\n" , data.nums);for (i =0 ; i < data.nums; i++) --2.9.3
Quoted 4 lines
Quoted 4 lines
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Deucher, Alexander
maintainerQuoted 22 lines
-----Original Message-----
From: Colin Ian King [mailto:[email protected]]
Sent: Thursday, October 06, 2016 3:04 PM
To: Alex Deucher
Cc: Deucher, Alexander; Koenig, Christian; David Airlie; Huang, JinHuiEric; Zhu, Rex; Zhou, Jammy; StDenis, Tom; Dan Carpenter; Maling list - DRI developers; LKML
Subject: Re: [PATCH] drm/amd/amdgpu: default to zero number of states if not enabledQuoted 1 line · Alex Deucher
On Thu, Oct 6, 2016 at 2:02 PM, Colin King <[email protected]>
Quoted 9 lines · wrote:
Quoted 8 lines
From: Colin Ian King <[email protected]>
Currently, if
adev->pp_enabledis false then thepp_stats_infodata is not read and hence a garbage number of states from the stack is used to dump out the number of states. Given data.nums could be any random value, this could easily lead to read outside the data.states array. Fix this by setting data.nums to zero ifadev->pp_enabledis false.
Quoted 8 lines
Quoted 1 line
Are you actually seeing a problem?
Nope.
Quoted 2 lines
The
pp_num_statesattribute only
gets added in the first place ifpp_enabledis true.Does that mean that the check on
adev->pp_enabledis redundant then?
Yes, I think so.
Alex
Quoted 33 lines
Quoted 6 lines
Alex
Quoted 1 line
Quoted 6 lines
Review
Quoted 6 lines
Signed-off-by Colin Ian King <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 2 ++ 1 file changed, 2 insertions(+)(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.cQuoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_pp_num_states(struct
Quoted 4 lines
index accc908..808d788 100644
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +0
-0@@ -195,6 +195,8 @@ static ssize_t amdgpu_get_pp_num_states(structdevice *dev,
Quoted 15 lines
Quoted 15 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +2
-1if (adev->pp_enabled)amdgpu_dpm_get_pp_num_states (adev, &data); +else + data.nums =0 ; buf_len =snprintf (buf,PAGE_SIZE ,"states: %d\n" , data.nums);for (i =0 ; i < data.nums; i++) --2.9.3
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 24 lines · Alexander
Quoted 24 lines
-----Original Message-----
From: Colin Ian King [mailto:[email protected]]
Sent: Thursday, October 06, 2016 3:04 PM
To: Alex Deucher
Cc: Deucher, Alexander; Koenig, Christian; David Airlie; Huang, JinHuiEric; Zhu, Rex; Zhou, Jammy; StDenis, Tom; Dan Carpenter; Maling list - DRI developers; LKML
Subject: Re: [PATCH] drm/amd/amdgpu: default to zero number of states if not enabledQuoted 1 line · Alex Deucher
On Thu, Oct 6, 2016 at 2:02 PM, Colin King <[email protected]>
Quoted 10 lines · wrote:
Quoted 8 lines
From: Colin Ian King <[email protected]>
Currently, if
adev->pp_enabledis false then thepp_stats_infodata is not read and hence a garbage number of states from the stack is used to dump out the number of states. Given data.nums could be any random value, this could easily lead to read outside the data.states array. Fix this by setting data.nums to zero ifadev->pp_enabledis false.Are you actually seeing a problem?
Quoted 8 lines
Quoted 6 lines
Nope.
Quoted 2 lines
The
pp_num_statesattribute only
gets added in the first place ifpp_enabledis true.Does that mean that the check on
adev->pp_enabledis redundant then?Yes, I think so.
OK, in which case it's probably extraneous code that could be removed.
Quoted 37 lines
Alex
Quoted 33 lines
Quoted 6 lines
Alex
Quoted 1 line
Quoted 6 lines
Review
Quoted 6 lines
Signed-off-by Colin Ian King <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 2 ++ 1 file changed, 2 insertions(+)(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.cQuoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_get_pp_num_states(struct
Quoted 4 lines
index accc908..808d788 100644
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +0
-0@@ -195,6 +195,8 @@ static ssize_t amdgpu_get_pp_num_states(structdevice *dev,
Quoted 15 lines
Quoted 15 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +2
-1if (adev->pp_enabled)amdgpu_dpm_get_pp_num_states (adev, &data); +else + data.nums =0 ; buf_len =snprintf (buf,PAGE_SIZE ,"states: %d\n" , data.nums);for (i =0 ; i < data.nums; i++) --2.9.3
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel