From: Colin Ian King <colin.king@canonical.com>
To: Alex Deucher <alexdeucher@gmail.com>
Cc: "Tom St Denis" <tom.stdenis@amd.com>,
"Jammy Zhou" <Jammy.Zhou@amd.com>,
LKML <linux-kernel@vger.kernel.org>,
"Maling list - DRI developers" <dri-devel@lists.freedesktop.org>,
"Eric Huang" <JinHuiEric.Huang@amd.com>,
"Alex Deucher" <alexander.deucher@amd.com>,
"Rex Zhu" <Rex.Zhu@amd.com>,
"Christian König" <christian.koenig@amd.com>,
"Dan Carpenter" <dan.carpenter@oracle.com>
Subject: Re: [PATCH] drm/amd/amdgpu: default to zero number of states if not enabled
Date: Thu, 6 Oct 2016 20:03:57 +0100 [thread overview]
Message-ID: <57F6A01D.10907@canonical.com> (raw)
In-Reply-To: <CADnq5_NUGhR8SS=Am6O+wcSBpZAvxq9bXGe7dzsosnxE_QLjEQ@mail.gmail.com>
On 06/10/16 19:32, Alex Deucher wrote:
> On Thu, Oct 6, 2016 at 2:02 PM, Colin King <colin.king@canonical.com> wrote:
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> 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.
>
> Are you actually seeing a problem?
Nope.
> The pp_num_states attribute only
> gets added in the first place if pp_enabled is true.
Does that mean that the check on adev->pp_enabled is redundant then?
>
> Alex
>
>>
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>> ---
>> drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
>> index accc908..808d788 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
>> @@ -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
>>
>> _______________________________________________
>> dri-devel mailing list
>> dri-devel@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
WARNING: multiple messages have this Message-ID (diff)
From: Colin Ian King <colin.king@canonical.com>
To: Alex Deucher <alexdeucher@gmail.com>
Cc: "Alex Deucher" <alexander.deucher@amd.com>,
"Christian König" <christian.koenig@amd.com>,
"David Airlie" <airlied@linux.ie>,
"Eric Huang" <JinHuiEric.Huang@amd.com>,
"Rex Zhu" <Rex.Zhu@amd.com>, "Jammy Zhou" <Jammy.Zhou@amd.com>,
"Tom St Denis" <tom.stdenis@amd.com>,
"Dan Carpenter" <dan.carpenter@oracle.com>,
"Maling list - DRI developers" <dri-devel@lists.freedesktop.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] drm/amd/amdgpu: default to zero number of states if not enabled
Date: Thu, 6 Oct 2016 20:03:57 +0100 [thread overview]
Message-ID: <57F6A01D.10907@canonical.com> (raw)
In-Reply-To: <CADnq5_NUGhR8SS=Am6O+wcSBpZAvxq9bXGe7dzsosnxE_QLjEQ@mail.gmail.com>
On 06/10/16 19:32, Alex Deucher wrote:
> On Thu, Oct 6, 2016 at 2:02 PM, Colin King <colin.king@canonical.com> wrote:
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> 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.
>
> Are you actually seeing a problem?
Nope.
> The pp_num_states attribute only
> gets added in the first place if pp_enabled is true.
Does that mean that the check on adev->pp_enabled is redundant then?
>
> Alex
>
>>
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>> ---
>> drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
>> index accc908..808d788 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
>> @@ -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
>>
>> _______________________________________________
>> dri-devel mailing list
>> dri-devel@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2016-10-06 19:04 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-06 18:02 [PATCH] drm/amd/amdgpu: default to zero number of states if not enabled Colin King
2016-10-06 18:02 ` Colin King
2016-10-06 18:32 ` Alex Deucher
2016-10-06 18:32 ` Alex Deucher
2016-10-06 19:03 ` Colin Ian King [this message]
2016-10-06 19:03 ` Colin Ian King
2016-10-06 19:04 ` Deucher, Alexander
2016-10-06 19:05 ` Colin Ian King
2016-10-06 19:05 ` Colin Ian King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=57F6A01D.10907@canonical.com \
--to=colin.king@canonical.com \
--cc=Jammy.Zhou@amd.com \
--cc=JinHuiEric.Huang@amd.com \
--cc=Rex.Zhu@amd.com \
--cc=alexander.deucher@amd.com \
--cc=alexdeucher@gmail.com \
--cc=christian.koenig@amd.com \
--cc=dan.carpenter@oracle.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tom.stdenis@amd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.