[PATCH] drm/amdgpu/eeprom: fix possible read overflow in memcpy

Alex Deucher alexdeucher at gmail.com
Tue Apr 7 14:54:31 UTC 2020


The size could be up to 32 bytes and we start from index 2.

In file included from ./include/linux/uuid.h:12,
                 from ./include/linux/mod_devicetable.h:13,
                 from ./include/linux/pci.h:27,
                 from drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c:23:
In function ‘memcpy’,
    inlined from ‘amdgpu_fru_get_product_info’ at drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c:137:2:
./include/linux/string.h:376:4: error: call to ‘__read_overflow2’ declared with attribute error: detected read beyond size of object passed as 2nd parameter
  376 |    __read_overflow2();
      |    ^~~~~~~~~~~~~~~~~~
make[4]: *** [scripts/Makefile.build:266: drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.o] Error 1

Signed-off-by: Alex Deucher <alexander.deucher at amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c
index 9d17761721de..c7e55fe170bd 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c
@@ -85,7 +85,7 @@ int amdgpu_fru_read_eeprom(struct amdgpu_device *adev, uint32_t addrptr,
 
 int amdgpu_fru_get_product_info(struct amdgpu_device *adev)
 {
-	unsigned char buff[32];
+	unsigned char buff[34];
 	int addrptr = 0, size = 0;
 
 	if (!is_fru_eeprom_supported(adev))
-- 
2.25.1



More information about the amd-gfx mailing list