platform/x86/amd/pmc: Use flex array when calling amd_pmc_stb_debugfs_open_v2()
authorShyam Sundar S K <Shyam-sundar.S-k@amd.com>
Tue, 10 Oct 2023 14:50:01 +0000 (20:20 +0530)
committerIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Thu, 12 Oct 2023 13:40:09 +0000 (16:40 +0300)
commitd9f421da6b9287000f8253628d54cf89b0c14da5
treeb4eb58c21dff4e5dc37f82cc3500688b1670c811
parent5a026767275ef0ba6d7aba37629d9ec638aabb7d
platform/x86/amd/pmc: Use flex array when calling amd_pmc_stb_debugfs_open_v2()

Currently in amd_pmc_stb_debugfs_open_v2() the buffer size is assumed to
be fixed and a second call to amd_pmc_stb_debugfs_open_v2() may race with
a process holding open another fd. This could change "fsize" to a
bigger size causing an out of bounds read.

Instead create a struct with a flexarray to solve this.

Suggested-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sanket Goswami <Sanket.Goswami@amd.com>
Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
Link: https://lore.kernel.org/r/20231010145003.139932-1-Shyam-sundar.S-k@amd.com
[ij: renamed flex_arr -> stb_data_arr]
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
drivers/platform/x86/amd/pmc/pmc.c