Clamp the buffer postion to write by setting the bin attribute
to the maximum buffer size so that VFS layer will block the
out-of-bounds accessing.

Signed-off-by: Shiwu Zhang <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
index f88df51a2558..576372ead63e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
@@ -5022,7 +5022,7 @@ static const struct bin_attribute psp_vbflash_bin_attr = {
 static struct bin_attribute psp_vbflash_bin_attr = {
 #endif
        .attr = {.name = "psp_vbflash", .mode = 0660},
-       .size = 0,
+       .size = AMD_VBIOS_FILE_MAX_SIZE_B,
        .write = amdgpu_psp_vbflash_write,
        .read = amdgpu_psp_vbflash_read,
 };
-- 
2.43.0

Reply via email to