All of lore.kernel.org
 help / color / mirror / Atom feed
* [Bug 108609] vegam_smumgr.c: accessing mvdd_voltage_table.entries[] array out of bounds in function vegam_populate_smc_mvdd_table
@ 2018-10-31  6:55 bugzilla-daemon
  2018-10-31  8:47 ` bugzilla-daemon
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: bugzilla-daemon @ 2018-10-31  6:55 UTC (permalink / raw)
  To: dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 4002 bytes --]

https://bugs.freedesktop.org/show_bug.cgi?id=108609

            Bug ID: 108609
           Summary: vegam_smumgr.c: accessing mvdd_voltage_table.entries[]
                    array out of bounds in function
                    vegam_populate_smc_mvdd_table
           Product: DRI
           Version: unspecified
          Hardware: x86-64 (AMD64)
                OS: Linux (All)
            Status: NEW
          Severity: normal
          Priority: medium
         Component: DRM/AMDgpu
          Assignee: dri-devel@lists.freedesktop.org
          Reporter: rstrube@gmail.com

Created attachment 142298
  --> https://bugs.freedesktop.org/attachment.cgi?id=142298&action=edit
Patch to fix accessing mvdd_voltage_table.entries[] array out of bounds in
vegam_smumgr.c

I believe I've discovered a small bug in the vegam_smumgr.c, specifically the
following function:

static int vegam_populate_smc_mvdd_table(struct pp_hwmgr *hwmgr,
                        SMU75_Discrete_DpmTable *table)
{
        struct smu7_hwmgr *data = (struct smu7_hwmgr *)(hwmgr->backend);
        uint32_t count, level;

        if (SMU7_VOLTAGE_CONTROL_BY_GPIO == data->mvdd_control) {
                count = data->mvdd_voltage_table.count;
                if (count > SMU_MAX_SMIO_LEVELS)
                        count = SMU_MAX_SMIO_LEVELS;
                for (level = 0; level < count; level++) {
                        table->SmioTable2.Pattern[level].Voltage =
PP_HOST_TO_SMC_US(
                                       
data->mvdd_voltage_table.entries[count].value * VOLTAGE_SCALE);
                        /* Index into DpmTable.Smio. Drive bits from Smio entry
to get this voltage level.*/
                        table->SmioTable2.Pattern[level].Smio =
                                (uint8_t) level;
                        table->Smio[level] |=
                               
data->mvdd_voltage_table.entries[level].smio_low;
                }
                table->SmioMask2 = data->mvdd_voltage_table.mask_low;

                table->MvddLevelCount = (uint32_t) PP_HOST_TO_SMC_UL(count);
        }

        return 0;
}

With the lines (within the for loop):

table->SmioTable2.Pattern[level].Voltage = PP_HOST_TO_SMC_US(
                data->mvdd_voltage_table.entries[count].value * VOLTAGE_SCALE);

If this code was executed it would try to access the
mvdd_voltage_table.entries[] array out of bounds, because count > than the max
value for level.

I believe:

data->mvdd_voltage_table.entries[count].value

should actually be:

data->mvdd_voltage_table.entries[level].value

You can see in a similar function within vegam_smumgr.c, this bug is *not*
present:

static int vegam_populate_smc_vddci_table(struct pp_hwmgr *hwmgr,
                                        struct SMU75_Discrete_DpmTable *table)
{
        uint32_t count, level;
        struct smu7_hwmgr *data = (struct smu7_hwmgr *)(hwmgr->backend);

        count = data->vddci_voltage_table.count;

        if (SMU7_VOLTAGE_CONTROL_BY_GPIO == data->vddci_control) {
                if (count > SMU_MAX_SMIO_LEVELS)
                        count = SMU_MAX_SMIO_LEVELS;
                for (level = 0; level < count; ++level) {
                        table->SmioTable1.Pattern[level].Voltage =
PP_HOST_TO_SMC_US(
                                       
data->vddci_voltage_table.entries[level].value * VOLTAGE_SCALE);
                        table->SmioTable1.Pattern[level].Smio = (uint8_t)
level;

                        table->Smio[level] |=
data->vddci_voltage_table.entries[level].smio_low;
                }
        }

        table->SmioMask1 = data->vddci_voltage_table.mask_low;

        return 0;
}

I've attached a patch for kernel 4.19, admittedly the change is trivial but I
figured I would try to do things the right way :)

Thanks!
Rob

-- 
You are receiving this mail because:
You are the assignee for the bug.

[-- Attachment #1.2: Type: text/html, Size: 5770 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [Bug 108609] vegam_smumgr.c: accessing mvdd_voltage_table.entries[] array out of bounds in function vegam_populate_smc_mvdd_table
  2018-10-31  6:55 [Bug 108609] vegam_smumgr.c: accessing mvdd_voltage_table.entries[] array out of bounds in function vegam_populate_smc_mvdd_table bugzilla-daemon
@ 2018-10-31  8:47 ` bugzilla-daemon
  2018-10-31 22:59 ` bugzilla-daemon
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: bugzilla-daemon @ 2018-10-31  8:47 UTC (permalink / raw)
  To: dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 290 bytes --]

https://bugs.freedesktop.org/show_bug.cgi?id=108609

--- Comment #1 from Michel Dänzer <michel@daenzer.net> ---
Please send the patch (generated by git format-patch) to the amd-gfx mailing
list for review.

-- 
You are receiving this mail because:
You are the assignee for the bug.

[-- Attachment #1.2: Type: text/html, Size: 1208 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [Bug 108609] vegam_smumgr.c: accessing mvdd_voltage_table.entries[] array out of bounds in function vegam_populate_smc_mvdd_table
  2018-10-31  6:55 [Bug 108609] vegam_smumgr.c: accessing mvdd_voltage_table.entries[] array out of bounds in function vegam_populate_smc_mvdd_table bugzilla-daemon
  2018-10-31  8:47 ` bugzilla-daemon
@ 2018-10-31 22:59 ` bugzilla-daemon
  2018-11-01  1:56 ` bugzilla-daemon
  2019-11-19  9:01 ` bugzilla-daemon
  3 siblings, 0 replies; 5+ messages in thread
From: bugzilla-daemon @ 2018-10-31 22:59 UTC (permalink / raw)
  To: dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 402 bytes --]

https://bugs.freedesktop.org/show_bug.cgi?id=108609

--- Comment #2 from Robert Strube <rstrube@gmail.com> ---
What repo and branch do you want the patch made against?  Does AMD have it's
own  repo for the linux kernel, or should I go against:
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master branch?

-- 
You are receiving this mail because:
You are the assignee for the bug.

[-- Attachment #1.2: Type: text/html, Size: 1318 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [Bug 108609] vegam_smumgr.c: accessing mvdd_voltage_table.entries[] array out of bounds in function vegam_populate_smc_mvdd_table
  2018-10-31  6:55 [Bug 108609] vegam_smumgr.c: accessing mvdd_voltage_table.entries[] array out of bounds in function vegam_populate_smc_mvdd_table bugzilla-daemon
  2018-10-31  8:47 ` bugzilla-daemon
  2018-10-31 22:59 ` bugzilla-daemon
@ 2018-11-01  1:56 ` bugzilla-daemon
  2019-11-19  9:01 ` bugzilla-daemon
  3 siblings, 0 replies; 5+ messages in thread
From: bugzilla-daemon @ 2018-11-01  1:56 UTC (permalink / raw)
  To: dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 374 bytes --]

https://bugs.freedesktop.org/show_bug.cgi?id=108609

--- Comment #3 from Alex Deucher <alexdeucher@gmail.com> ---
Ideally against one of these branches:
https://cgit.freedesktop.org/~agd5f/linux/log/?h=amd-staging-drm-next
https://cgit.freedesktop.org/~agd5f/linux/log/?h=drm-next-4.21-wip

-- 
You are receiving this mail because:
You are the assignee for the bug.

[-- Attachment #1.2: Type: text/html, Size: 1458 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [Bug 108609] vegam_smumgr.c: accessing mvdd_voltage_table.entries[] array out of bounds in function vegam_populate_smc_mvdd_table
  2018-10-31  6:55 [Bug 108609] vegam_smumgr.c: accessing mvdd_voltage_table.entries[] array out of bounds in function vegam_populate_smc_mvdd_table bugzilla-daemon
                   ` (2 preceding siblings ...)
  2018-11-01  1:56 ` bugzilla-daemon
@ 2019-11-19  9:01 ` bugzilla-daemon
  3 siblings, 0 replies; 5+ messages in thread
From: bugzilla-daemon @ 2019-11-19  9:01 UTC (permalink / raw)
  To: dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 805 bytes --]

https://bugs.freedesktop.org/show_bug.cgi?id=108609

Martin Peres <martin.peres@free.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |MOVED

--- Comment #4 from Martin Peres <martin.peres@free.fr> ---
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been
closed from further activity.

You can subscribe and participate further through the new bug through this link
to our GitLab instance: https://gitlab.freedesktop.org/drm/amd/issues/582.

-- 
You are receiving this mail because:
You are the assignee for the bug.

[-- Attachment #1.2: Type: text/html, Size: 2572 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

end of thread, other threads:[~2019-11-19  9:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-31  6:55 [Bug 108609] vegam_smumgr.c: accessing mvdd_voltage_table.entries[] array out of bounds in function vegam_populate_smc_mvdd_table bugzilla-daemon
2018-10-31  8:47 ` bugzilla-daemon
2018-10-31 22:59 ` bugzilla-daemon
2018-11-01  1:56 ` bugzilla-daemon
2019-11-19  9:01 ` bugzilla-daemon

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.