drm/amdgpu/mmhub2.0: add bounds checking for cid
Subsystems (2)
Alex Deucher
maintainerPATCH 1/7 drm/amdgpu/mmhub2.0: add bounds checking for cid
The value should never exceed the array size as those are the only values the hardware is expected to return, but add checks anyway.
--- drivers/gpu/drm/amd/amdgpu/mmhub_v2_0.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/mmhub_v2_0.c +6 -3
@@ -154,14 +154,17 @@ mmhub_v2_0_print_l2_protection_fault_status(struct amdgpu_device *adev,switch (amdgpu_ip_version (adev,MMHUB_HWIP ,0 )) {case IP_VERSION (2 ,0 ,0 ):case IP_VERSION (2 ,0 ,2 ): - mmhub_cid = mmhub_client_ids_navi1x[cid][rw]; + mmhub_cid = cid <ARRAY_SIZE (mmhub_client_ids_navi1x) ? + mmhub_client_ids_navi1x[cid][rw] :NULL ;break ;case IP_VERSION (2 ,1 ,0 ):case IP_VERSION (2 ,1 ,1 ): - mmhub_cid = mmhub_client_ids_sienna_cichlid[cid][rw]; + mmhub_cid = cid <ARRAY_SIZE (mmhub_client_ids_sienna_cichlid) ? + mmhub_client_ids_sienna_cichlid[cid][rw] :NULL ;break ;case IP_VERSION (2 ,1 ,2 ): - mmhub_cid = mmhub_client_ids_beige_goby[cid][rw]; + mmhub_cid = cid <ARRAY_SIZE (mmhub_client_ids_beige_goby) ? + mmhub_client_ids_beige_goby[cid][rw] :NULL ;break ;default : mmhub_cid =NULL ;
Signature · 1 line
2.53.0
Alex Deucher
maintainerPATCH 2/7 drm/amdgpu/mmhub2.3: add bounds checking for cid
The value should never exceed the array size as those are the only values the hardware is expected to return, but add checks anyway.
--- drivers/gpu/drm/amd/amdgpu/mmhub_v2_3.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/mmhub_v2_3.c +2 -1
@@ -96,7 +96,8 @@ mmhub_v2_3_print_l2_protection_fault_status(struct amdgpu_device *adev,case IP_VERSION (2 ,3 ,0 ):case IP_VERSION (2 ,4 ,0 ):case IP_VERSION (2 ,4 ,1 ): - mmhub_cid = mmhub_client_ids_vangogh[cid][rw]; + mmhub_cid = cid <ARRAY_SIZE (mmhub_client_ids_vangogh) ? + mmhub_client_ids_vangogh[cid][rw] :NULL ;break ;default : mmhub_cid =NULL ;
Signature · 1 line
2.53.0
Alex Deucher
maintainerPATCH 3/7 drm/amdgpu/mmhub3.0.1: add bounds checking for cid
In reply to Alex DeucherThe value should never exceed the array size as those are the only values the hardware is expected to return, but add checks anyway.
--- drivers/gpu/drm/amd/amdgpu/mmhub_v3_0_1.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/mmhub_v3_0_1.c +2 -1
@@ -117,7 +117,8 @@ mmhub_v3_0_1_print_l2_protection_fault_status(struct amdgpu_device *adev,switch (amdgpu_ip_version (adev,MMHUB_HWIP ,0 )) {case IP_VERSION (3 ,0 ,1 ): - mmhub_cid = mmhub_client_ids_v3_0_1[cid][rw]; + mmhub_cid = cid <ARRAY_SIZE (mmhub_client_ids_v3_0_1) ? + mmhub_client_ids_v3_0_1[cid][rw] :NULL ;break ;default : mmhub_cid =NULL ;
Signature · 1 line
2.53.0
Alex Deucher
maintainerPATCH 4/7 drm/amdgpu/mmhub3.0.2: add bounds checking for cid
In reply to Alex DeucherThe value should never exceed the array size as those are the only values the hardware is expected to return, but add checks anyway.
--- drivers/gpu/drm/amd/amdgpu/mmhub_v3_0_2.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/mmhub_v3_0_2.c +2 -1
@@ -108,7 +108,8 @@ mmhub_v3_0_2_print_l2_protection_fault_status(struct amdgpu_device *adev,"MMVM_L2_PROTECTION_FAULT_STATUS:0x%08X\n" , status); - mmhub_cid = mmhub_client_ids_v3_0_2[cid][rw]; + mmhub_cid = cid <ARRAY_SIZE (mmhub_client_ids_v3_0_2) ? + mmhub_client_ids_v3_0_2[cid][rw] :NULL ;dev_err (adev->dev,"\t Faulty UTCL2 client ID: %s (0x%x)\n" , mmhub_cid ? mmhub_cid :"unknown" , cid); dev_err(adev->dev, "\t MORE_FAULTS: 0x%lx\n",
Signature · 1 line
2.53.0
Alex Deucher
maintainerPATCH 5/7 drm/amdgpu/mmhub3.0: add bounds checking for cid
In reply to Alex DeucherThe value should never exceed the array size as those are the only values the hardware is expected to return, but add checks anyway.
--- drivers/gpu/drm/amd/amdgpu/mmhub_v3_0.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/mmhub_v3_0.c +2 -1
@@ -110,7 +110,8 @@ mmhub_v3_0_print_l2_protection_fault_status(struct amdgpu_device *adev,switch (amdgpu_ip_version (adev,MMHUB_HWIP ,0 )) {case IP_VERSION (3 ,0 ,0 ):case IP_VERSION (3 ,0 ,1 ): - mmhub_cid = mmhub_client_ids_v3_0_0[cid][rw]; + mmhub_cid = cid <ARRAY_SIZE (mmhub_client_ids_v3_0_0) ? + mmhub_client_ids_v3_0_0[cid][rw] :NULL ;break ;default : mmhub_cid =NULL ;
Signature · 1 line
2.53.0
Alex Deucher
maintainerPATCH 6/7 drm/amdgpu/mmhub4.1.0: add bounds checking for cid
In reply to Alex DeucherThe value should never exceed the array size as those are the only values the hardware is expected to return, but add checks anyway.
--- drivers/gpu/drm/amd/amdgpu/mmhub_v4_1_0.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/mmhub_v4_1_0.c +2 -1
@@ -102,7 +102,8 @@ mmhub_v4_1_0_print_l2_protection_fault_status(struct amdgpu_device *adev, status);switch (amdgpu_ip_version (adev,MMHUB_HWIP ,0 )) {case IP_VERSION (4 ,1 ,0 ): - mmhub_cid = mmhub_client_ids_v4_1_0[cid][rw]; + mmhub_cid = cid <ARRAY_SIZE (mmhub_client_ids_v4_1_0) ? + mmhub_client_ids_v4_1_0[cid][rw] :NULL ;break ;default : mmhub_cid =NULL ;
Signature · 1 line
2.53.0
Alex Deucher
maintainerPATCH 7/7 drm/amdgpu/mmhub4.2.0: add bounds checking for cid
In reply to Alex DeucherThe value should never exceed the array size as those are the only values the hardware is expected to return, but add checks anyway.
--- drivers/gpu/drm/amd/amdgpu/mmhub_v4_2_0.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/mmhub_v4_2_0.c +2 -1
@@ -688,7 +688,8 @@ mmhub_v4_2_0_print_l2_protection_fault_status(struct amdgpu_device *adev, status);switch (amdgpu_ip_version (adev,MMHUB_HWIP ,0 )) {case IP_VERSION (4 ,2 ,0 ): - mmhub_cid = mmhub_client_ids_v4_2_0[cid][rw]; + mmhub_cid = cid <ARRAY_SIZE (mmhub_client_ids_v4_2_0) ? + mmhub_client_ids_v4_2_0[cid][rw] :NULL ;break ;default : mmhub_cid =NULL ;
Signature · 1 line
2.53.0
Quoted 14 lines · Alex Deucher
The value should never exceed the array size as those are the only values the hardware is expected to return, but add checks anyway.
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/mmhub_v2_0.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/mmhub_v2_0.c +0
-0
drivers/gpu/drm/amd/amdgpu/mmhub_v2_0.c mmhub_v2_0_print_l2_protection_fault_status(struct amdgpu_device *adev, · line 157
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/mmhub_v2_0.c +1
-1@@ -154,14 +154,17 @@ mmhub_v2_0_print_l2_protection_fault_status(struct amdgpu_device *adev,switch (amdgpu_ip_version (adev,MMHUB_HWIP ,0 )) {case IP_VERSION (2 ,0 ,0 ):case IP_VERSION (2 ,0 ,2 ): - mmhub_cid = mmhub_client_ids_navi1x[cid][rw]; + mmhub_cid = cid < ARRAY_SIZE(mmhub_client_ids_navi1x) ?
Does this introduce speculation and requirement to use array_index_nospec?
Thanks,
Lijo
Quoted 15 lines
drivers/gpu/drm/amd/amdgpu/mmhub_v2_0.c +5
-2+ mmhub_client_ids_navi1x[cid][rw] : NULL;break ;case IP_VERSION (2 ,1 ,0 ):case IP_VERSION (2 ,1 ,1 ): - mmhub_cid = mmhub_client_ids_sienna_cichlid[cid][rw]; + mmhub_cid = cid <ARRAY_SIZE (mmhub_client_ids_sienna_cichlid) ? + mmhub_client_ids_sienna_cichlid[cid][rw] :NULL ;break ;case IP_VERSION (2 ,1 ,2 ): - mmhub_cid = mmhub_client_ids_beige_goby[cid][rw]; + mmhub_cid = cid <ARRAY_SIZE (mmhub_client_ids_beige_goby) ? + mmhub_client_ids_beige_goby[cid][rw] :NULL ;break ;default : mmhub_cid =NULL ;
Quoted 13 lines · Lijo
Quoted 9 lines · Alex Deucher
The value should never exceed the array size as those are the only values the hardware is expected to return, but add checks anyway.
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/mmhub_v2_0.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/mmhub_v2_0.c mmhub_v2_0_print_l2_protection_fault_status(struct amdgpu_device *adev, · line 157
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/mmhub_v2_0.c +1
-1@@ -154,14 +154,17 @@ mmhub_v2_0_print_l2_protection_fault_status(struct amdgpu_device *adev,switch (amdgpu_ip_version (adev,MMHUB_HWIP ,0 )) {case IP_VERSION (2 ,0 ,0 ):case IP_VERSION (2 ,0 ,2 ): - mmhub_cid = mmhub_client_ids_navi1x[cid][rw]; + mmhub_cid = cid < ARRAY_SIZE(mmhub_client_ids_navi1x) ?Does this introduce speculation and requirement to use
array_index_nospec?
I don't think so, but I'm not really an expert on side channel attacks.
Alex
Quoted 20 lines
Thanks,
LijoQuoted 15 lines
drivers/gpu/drm/amd/amdgpu/mmhub_v2_0.c +5
-2+ mmhub_client_ids_navi1x[cid][rw] : NULL;break ;case IP_VERSION (2 ,1 ,0 ):case IP_VERSION (2 ,1 ,1 ): - mmhub_cid = mmhub_client_ids_sienna_cichlid[cid][rw]; + mmhub_cid = cid <ARRAY_SIZE (mmhub_client_ids_sienna_cichlid) ? + mmhub_client_ids_sienna_cichlid[cid][rw] :NULL ;break ;case IP_VERSION (2 ,1 ,2 ): - mmhub_cid = mmhub_client_ids_beige_goby[cid][rw]; + mmhub_cid = cid <ARRAY_SIZE (mmhub_client_ids_beige_goby) ? + mmhub_client_ids_beige_goby[cid][rw] :NULL ;break ;default : mmhub_cid =NULL ;
Ping on this series.
Alex
Quoted 52 lines · Alex Deucher
Quoted 13 lines · Lijo
Quoted 9 lines · Alex Deucher
The value should never exceed the array size as those are the only values the hardware is expected to return, but add checks anyway.
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/mmhub_v2_0.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/mmhub_v2_0.c mmhub_v2_0_print_l2_protection_fault_status(struct amdgpu_device *adev, · line 157
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/mmhub_v2_0.c +1
-1@@ -154,14 +154,17 @@ mmhub_v2_0_print_l2_protection_fault_status(struct amdgpu_device *adev,switch (amdgpu_ip_version (adev,MMHUB_HWIP ,0 )) {case IP_VERSION (2 ,0 ,0 ):case IP_VERSION (2 ,0 ,2 ): - mmhub_cid = mmhub_client_ids_navi1x[cid][rw]; + mmhub_cid = cid < ARRAY_SIZE(mmhub_client_ids_navi1x) ?Does this introduce speculation and requirement to use
array_index_nospec?I don't think so, but I'm not really an expert on side channel attacks.
Alex
Quoted 20 lines
Thanks,
LijoQuoted 15 lines
drivers/gpu/drm/amd/amdgpu/mmhub_v2_0.c +5
-2+ mmhub_client_ids_navi1x[cid][rw] : NULL;break ;case IP_VERSION (2 ,1 ,0 ):case IP_VERSION (2 ,1 ,1 ): - mmhub_cid = mmhub_client_ids_sienna_cichlid[cid][rw]; + mmhub_cid = cid <ARRAY_SIZE (mmhub_client_ids_sienna_cichlid) ? + mmhub_client_ids_sienna_cichlid[cid][rw] :NULL ;break ;case IP_VERSION (2 ,1 ,2 ): - mmhub_cid = mmhub_client_ids_beige_goby[cid][rw]; + mmhub_cid = cid <ARRAY_SIZE (mmhub_client_ids_beige_goby) ? + mmhub_client_ids_beige_goby[cid][rw] :NULL ;break ;default : mmhub_cid =NULL ;
Benjamin Cheng
Reviewed-byQuoted 24 lines · Alex Deucher
Quoted 12 lines · Lijo
Quoted 9 lines · Alex Deucher
The value should never exceed the array size as those are the only values the hardware is expected to return, but add checks anyway.
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/mmhub_v2_0.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/mmhub_v2_0.c mmhub_v2_0_print_l2_protection_fault_status(struct amdgpu_device *adev, · line 157
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/mmhub_v2_0.c +1
-1@@ -154,14 +154,17 @@ mmhub_v2_0_print_l2_protection_fault_status(struct amdgpu_device *adev,switch (amdgpu_ip_version (adev,MMHUB_HWIP ,0 )) {case IP_VERSION (2 ,0 ,0 ):case IP_VERSION (2 ,0 ,2 ): - mmhub_cid = mmhub_client_ids_navi1x[cid][rw]; + mmhub_cid = cid < ARRAY_SIZE(mmhub_client_ids_navi1x) ?Does this introduce speculation and requirement to use
array_index_nospec?
Quoted 3 lines
I don't think so, but I'm not really an expert on side channel attacks.
Alex
Also not an expert here but I don't think this can be used as an exploit. The cid is read from HW and is not controllable by users.
This series is:
Quoted 19 lines
Quoted 19 lines
Thanks,
LijoQuoted 15 lines
drivers/gpu/drm/amd/amdgpu/mmhub_v2_0.c +5
-2+ mmhub_client_ids_navi1x[cid][rw] : NULL;break ;case IP_VERSION (2 ,1 ,0 ):case IP_VERSION (2 ,1 ,1 ): - mmhub_cid = mmhub_client_ids_sienna_cichlid[cid][rw]; + mmhub_cid = cid <ARRAY_SIZE (mmhub_client_ids_sienna_cichlid) ? + mmhub_client_ids_sienna_cichlid[cid][rw] :NULL ;break ;case IP_VERSION (2 ,1 ,2 ): - mmhub_cid = mmhub_client_ids_beige_goby[cid][rw]; + mmhub_cid = cid <ARRAY_SIZE (mmhub_client_ids_beige_goby) ? + mmhub_client_ids_beige_goby[cid][rw] :NULL ;break ;default : mmhub_cid =NULL ;