]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
drm/amdgpu: avoid buffer overflow attach in smu_sys_set_pp_table()
authorJiang Liu <gerry@linux.alibaba.com>
Fri, 7 Feb 2025 06:44:14 +0000 (14:44 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 13 Feb 2025 00:47:15 +0000 (19:47 -0500)
It malicious user provides a small pptable through sysfs and then
a bigger pptable, it may cause buffer overflow attack in function
smu_sys_set_pp_table().

Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
Signed-off-by: Jiang Liu <gerry@linux.alibaba.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c

index 8ca793c222ff2e9f702733ee896babdbd0598dc3..ed9dac00ebfb1805a5ab93e00f39ce7e6913a26f 100644 (file)
@@ -612,7 +612,8 @@ static int smu_sys_set_pp_table(void *handle,
                return -EIO;
        }
 
-       if (!smu_table->hardcode_pptable) {
+       if (!smu_table->hardcode_pptable || smu_table->power_play_table_size < size) {
+               kfree(smu_table->hardcode_pptable);
                smu_table->hardcode_pptable = kzalloc(size, GFP_KERNEL);
                if (!smu_table->hardcode_pptable)
                        return -ENOMEM;