linux/drivers/gpu/drm/amd/include
Nathan Chancellor e4d0ef7520 drm/amdgpu: Fix type of second parameter in odn_edit_dpm_table() callback
With clang's kernel control flow integrity (kCFI, CONFIG_CFI_CLANG),
indirect call targets are validated against the expected function
pointer prototype to make sure the call target is valid to help mitigate
ROP attacks. If they are not identical, there is a failure at run time,
which manifests as either a kernel panic or thread getting killed. A
proposed warning in clang aims to catch these at compile time, which
reveals:

  drivers/gpu/drm/amd/amdgpu/../pm/swsmu/amdgpu_smu.c:3008:29: error: incompatible function pointer types initializing 'int (*)(void *, uint32_t, long *, uint32_t)' (aka 'int (*)(void *, unsigned int, long *, unsigned int)') with an expression of type 'int (void *, enum PP_OD_DPM_TABLE_COMMAND, long *, uint32_t)' (aka 'int (void *, enum PP_OD_DPM_TABLE_COMMAND, long *, unsigned int)') [-Werror,-Wincompatible-function-pointer-types-strict]
          .odn_edit_dpm_table      = smu_od_edit_dpm_table,
                                     ^~~~~~~~~~~~~~~~~~~~~
  1 error generated.

There are only two implementations of ->odn_edit_dpm_table() in 'struct
amd_pm_funcs': smu_od_edit_dpm_table() and pp_odn_edit_dpm_table(). One
has a second parameter type of 'enum PP_OD_DPM_TABLE_COMMAND' and the
other uses 'u32'. Ultimately, smu_od_edit_dpm_table() calls
->od_edit_dpm_table() from 'struct pptable_funcs' and
pp_odn_edit_dpm_table() calls ->odn_edit_dpm_table() from 'struct
pp_hwmgr_func', which both have a second parameter type of 'enum
PP_OD_DPM_TABLE_COMMAND'.

Update the type parameter in both the prototype in 'struct amd_pm_funcs'
and pp_odn_edit_dpm_table() to 'enum PP_OD_DPM_TABLE_COMMAND', which
cleans up the warning.

Link: https://github.com/ClangBuiltLinux/linux/issues/1750
Reported-by: Sami Tolvanen <samitolvanen@google.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2022-11-04 16:05:53 -04:00
..
asic_reg drm/amdgpu: Update umc v8_10_0 headers 2022-10-11 11:05:35 -04:00
ivsrcid drm/amdgpu/vcn: Add vcn ras poison consumption event handling 2022-05-10 17:53:13 -04:00
aldebaran_ip_offset.h
amd_acpi.h
amd_pcie.h
amd_pcie_helpers.h
amd_shared.h drm/amd/display: Add dcdebugmask option for disabling MPO 2022-07-25 09:31:03 -04:00
arct_ip_offset.h
atom-bits.h
atom-names.h
atom-types.h
atombios.h drm/amdgpu: Replace one-element array with flexible-array member 2022-11-04 16:05:53 -04:00
atomfirmware.h drm/amd: Add atomfirmware.h definitions needed for DCN32/321 2022-06-03 16:43:36 -04:00
atomfirmwareid.h
beige_goby_ip_offset.h
cgs_common.h
cik_structs.h
cyan_skillfish_ip_offset.h
dimgrey_cavefish_ip_offset.h
discovery.h drm/amdgpu: update latest IP discovery table structures 2022-04-28 17:46:31 -04:00
displayobject.h
dm_pp_interface.h
kgd_kfd_interface.h drm/amdkfd: Fix type of reset_type parameter in hqd_destroy() callback 2022-10-17 17:41:21 -04:00
kgd_pp_interface.h drm/amdgpu: Fix type of second parameter in odn_edit_dpm_table() callback 2022-11-04 16:05:53 -04:00
mes_api_def.h drm/amd: Fix spelling typo in comments 2022-06-03 16:43:36 -04:00
mes_v11_api_def.h drm/amdgpu: pass queue size and is_aql_queue to MES 2022-09-29 09:41:44 -04:00
navi10_enum.h
navi10_ip_offset.h
navi12_ip_offset.h
navi14_ip_offset.h
pptable.h
renoir_ip_offset.h
sienna_cichlid_ip_offset.h
soc15_hw_ip.h drm/amdgpu: add lsdma block 2022-05-10 17:53:11 -04:00
soc15_ih_clientid.h drm/amdgpu: add soc21 ih clientid definition 2022-05-04 09:52:59 -04:00
soc21_enum.h drm/amdgpu: add soc21 chip enum header v8 2022-05-04 10:02:18 -04:00
v9_structs.h
v10_structs.h
v11_structs.h drm/amdgpu: add gfx11 mqd structures 2022-05-04 10:02:27 -04:00
vangogh_ip_offset.h
vega10_enum.h
vega10_ip_offset.h
vega20_ip_offset.h
vi_structs.h
yellow_carp_offset.h