Skip to contentSkip to conversation

drm/amdgpu: Validate TA binary size

PATCH In review Candice Li 2 participants 2 messages Aug 15, 2024

Subsystems (2)
lore
Share & tools
lore

Candice Li

author
#0 lore raw

PATCH 1/1 drm/amdgpu: Validate TA binary size

Add TA binary size validation to avoid OOB write.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c +3 -0
index 0c856005df6b95..38face981c3e38 100644
@@ -166,6 +166,9 @@ static ssize_t ta_if_load_debugfs_write(struct file *fp, const char *buf, size_t
 	if (ret)
 		return -EFAULT;
 
+	if (ta_bin_len > PSP_1_MEG)
+		return -EINVAL;
+
 	copy_pos += sizeof(uint32_t);
 
 	ta_bin = kzalloc(ta_bin_len, GFP_KERNEL);
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw

[AMD Official Use Only - AMD Internal Distribution Only]

Regards,
Hawking
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Candice Li
Sent: Thursday, August 15, 2024 15:06
To: [email protected]
Cc: Li, Candice <[email protected]>
Subject: [PATCH] drm/amdgpu: Validate TA binary size

Add TA binary size validation to avoid OOB write.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c +3 -0
index 0c856005df6b95..38face981c3e38 100644
@@ -166,6 +166,9 @@ static ssize_t ta_if_load_debugfs_write(struct file *fp, const char *buf, size_t
        if (ret)
                return -EFAULT;
 
+       if (ta_bin_len > PSP_1_MEG)
+               return -EINVAL;
+
        copy_pos += sizeof(uint32_t);
 
        ta_bin = kzalloc(ta_bin_len, GFP_KERNEL);

--
2.25.1