* [RFC PATCH] drm/amdgpu: fix EFAULT return value for debugfs ctrl parse data
@ 2022-04-29 21:29 Niels Dossche
0 siblings, 0 replies; only message in thread
From: Niels Dossche @ 2022-04-29 21:29 UTC (permalink / raw)
To: amd-gfx; +Cc: Alex Deucher, Pan, Xinhui, Niels Dossche, Christian König
amdgpu_ras_debugfs_ctrl_parse_data is reachable from a debug fs write.
A write is supposed to return EFAULT when the user buffer is outside
the address space. Right now it returns EINVAL.
Change the EINVAL to EFAULT.
Fixes: 96ebb3073275 ("drm/amdgpu: add human readable debugfs control support (v2)")
Signed-off-by: Niels Dossche <dossche.niels@gmail.com>
---
I found this issue using static analysis to find inconsistent error
handling regarding kernel APIs. Found on v5.17.4.
As I do not have the necessary hardware, I only managed to compile test
this on x86_64. I put this as an RFC as I'm a bit worried about possible
userspace API breakage that might rely on the EINVAL behaviour.
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
index 424c22a841f4..9bbdf0519c31 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
@@ -253,7 +253,7 @@ static int amdgpu_ras_debugfs_ctrl_parse_data(struct file *f,
memset(data, 0, sizeof(*data));
if (copy_from_user(str, buf, s))
- return -EINVAL;
+ return -EFAULT;
if (sscanf(str, "disable %32s", block_name) == 1)
op = 0;
@@ -308,7 +308,7 @@ static int amdgpu_ras_debugfs_ctrl_parse_data(struct file *f,
return -EINVAL;
if (copy_from_user(data, buf, sizeof(*data)))
- return -EINVAL;
+ return -EFAULT;
}
return 0;
--
2.35.2
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2022-05-02 13:00 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-29 21:29 [RFC PATCH] drm/amdgpu: fix EFAULT return value for debugfs ctrl parse data Niels Dossche
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox