Skip to contentSkip to conversation

drm/amdgpu: fix out of bounds write

PATCH Guenter Roeck 2 participants 3 messages Oct 27, 2021

lore
Share & tools
lore
#0 lore raw
Quoted 5 lines · Thelford Williams

Size can be any value and is user controlled resulting in overwriting the 40 byte array wr_buf with an arbitrary length of data from buf.

The fix works, but unless I am missing something it is incomplete. parse_write_buffer_into_params() is called several times, and the size parameter is always wrong. This patch only fixes one of several instances of the problem.

Guenter

Quoted 19 lines
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c +1 -1
index 814f67d86a3c..9b3ad56607bb 100644
@@ -264,7 +264,7 @@ static ssize_t dp_link_settings_write(struct file *f, const char __user *buf,
 	if (!wr_buf)
 		return -ENOSPC;
 
-	if (parse_write_buffer_into_params(wr_buf, size,
+	if (parse_write_buffer_into_params(wr_buf, wr_buf_size,
 					   (long *)param, buf,
 					   max_param_num,
 					   &param_nums)) {
Signature · 1 line
2.33.0
#1 lore raw
Quoted 4 lines · Guenter Roeck
Quoted 3 lines · Thelford Williams

Size can be any value and is user controlled resulting in overwriting the 40 byte array wr_buf with an arbitrary length of data from buf.

Quoted 8 lines
Quoted 2 lines

The fix works, but unless I am missing something it is incomplete. parse_write_buffer_into_params() is called several times, and the size parameter is always wrong. This patch only fixes one of several instances of the problem.

Patrik sent a patch that covers all cases:
https://patchwork.freedesktop.org/patch/461554/?series=96341&rev=2

Harry

Quoted 21 lines

Guenter

Quoted 19 lines
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c +1 -1
index 814f67d86a3c..9b3ad56607bb 100644
@@ -264,7 +264,7 @@ static ssize_t dp_link_settings_write(struct file *f, const char __user *buf,
 	if (!wr_buf)
 		return -ENOSPC;
 
-	if (parse_write_buffer_into_params(wr_buf, size,
+	if (parse_write_buffer_into_params(wr_buf, wr_buf_size,
 					   (long *)param, buf,
 					   max_param_num,
 					   &param_nums)) {
Signature · 1 line
2.33.0
#2 lore raw
Quoted 14 lines · Harry Wentland
Quoted 4 lines · Guenter Roeck
Quoted 3 lines · Thelford Williams

Size can be any value and is user controlled resulting in overwriting the 40 byte array wr_buf with an arbitrary length of data from buf.

Quoted 8 lines
Quoted 2 lines

The fix works, but unless I am missing something it is incomplete. parse_write_buffer_into_params() is called several times, and the size parameter is always wrong. This patch only fixes one of several instances of the problem.

Quoted 5 lines

Patrik sent a patch that covers all cases:
https://patchwork.freedesktop.org/patch/461554/?series=96341&rev=2

Harry

Thanks!

Guenter

Quoted 22 lines
Quoted 21 lines

Guenter

Quoted 19 lines
---
  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c +1 -1
index 814f67d86a3c..9b3ad56607bb 100644
@@ -264,7 +264,7 @@ static ssize_t dp_link_settings_write(struct file *f, const char __user *buf,
  	if (!wr_buf)
  		return -ENOSPC;
 
-	if (parse_write_buffer_into_params(wr_buf, size,
+	if (parse_write_buffer_into_params(wr_buf, wr_buf_size,
  					   (long *)param, buf,
  					   max_param_num,
  					   &param_nums)) {
Signature · 1 line
2.33.0