Skip to contentSkip to conversation

drm/amdgpu/eeprom: fix possible read overflow in memcpy

PATCH In review Alex Deucher 2 participants 2 messages Apr 7, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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

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

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c +1 -1
index 9d17761721de..c7e55fe170bd 100644
@@ -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))
Signature · 6 lines
2.25.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Reviewed-by on v1 1/1
#1 lore raw

[AMD Official Use Only - Internal Distribution Only]

Thanks Alex

Quoted 46 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Tuesday, April 7, 2020 10:55 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: [PATCH] drm/amdgpu/eeprom: fix possible read overflow in memcpy

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

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c +1 -2
index 9d17761721de..c7e55fe170bd 100644
@@ -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

Quoted 9 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.fr
eedesktop.org%2Fmailman%2Flistinfo%2Famd- gfx&amp;data=02%7C01%7Ckent.russell%40amd.com%7Cac36574b1634468f2 61a08d7db039cb0%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C6 37218680938415164&amp;sdata=uaxSwz129HVKb1A3rG7yxzobsiQANnr6eWT IaxVijYM%3D&amp;reserved=0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx