All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu: fix double fetch in amdgpu_ras_debugfs_ctrl_parse_data()
@ 2019-07-16 11:11 JingYi Hou
  0 siblings, 0 replies; only message in thread
From: JingYi Hou @ 2019-07-16 11:11 UTC (permalink / raw)
  To: alexander.deucher, christian.koenig, David1.Zhou, airlied, daniel
  Cc: amd-gfx, dri-devel, linux-kernel

In amdgpu_ras_debugfs_ctrl_parse_data(), first fetch str from buf to
get op value, if op == -1 which means no command matched, fetch data
from buf again.

If change buf between two fetches may cause security problems or
unexpected behaivor. amdgpu_ras_debugfs_ctrl_parse_data() was called
by amdgpu_ras_debugfs_ctrl_write() and value of op was used later.

We should check whether data->op == -1 or not after second fetch. if
data->op != -1 means buf changed and should return -EINVAL.

Signed-off-by: JingYi Hou <houjingyi647@gmail.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
index 22bd21efe6b1..845e73e98cd7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
@@ -233,6 +233,9 @@ static int amdgpu_ras_debugfs_ctrl_parse_data(struct file *f,

 		if (copy_from_user(data, buf, sizeof(*data)))
 			return -EINVAL;
+
+		if(data->op != -1)
+			return -EINVAL;
 	}

 	return 0;
--
2.20.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2019-07-16 11:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-16 11:11 [PATCH] drm/amdgpu: fix double fetch in amdgpu_ras_debugfs_ctrl_parse_data() JingYi Hou

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.