drm/amdgpu: check the result of copy_from_user in secure display debugfs
Subsystems (2)
PATCH 1/1 drm/amdgpu: check the result of copy_from_user in secure display debugfs
Make sure the copy succeeded. Also fixes a warning.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_securedisplay.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_securedisplay.c +3 -1
@@ -101,7 +101,9 @@ static ssize_t amdgpu_securedisplay_debugfs_write(struct file *f, const char __ureturn -EINVAL ;memset (str,0 ,sizeof (str)); -copy_from_user (str, buf, size); + ret =copy_from_user (str, buf, size); +if (ret >= size) +return -EINVAL ; ret =pm_runtime_get_sync (dev->dev);if (ret <0 ) {
Signature · 6 lines
2.29.2 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Am 04.01.21 um 18:43 schrieb Alex Deucher:
Quoted 12 lines
Make sure the copy succeeded. Also fixes a warning.
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_securedisplay.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_securedisplay.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_securedisplay.c static ssize_t amdgpu_securedisplay_debugfs_write(struct file *f, const char __u · line 106
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_securedisplay.c +3
-1@@ -101,7 +101,9 @@ static ssize_t amdgpu_securedisplay_debugfs_write(struct file *f, const char __ureturn -EINVAL ;memset (str,0 ,sizeof (str)); -copy_from_user (str, buf, size); + ret =copy_from_user (str, buf, size); +if (ret >= size) +return -EINVAL ;
IIRC copy_from_user return the number of bytes which couldn't be copied.
E.g. theta should be if (ret) return -EFAULT.
Christian.
drivers/gpu/drm/amd/amdgpu/amdgpu_securedisplay.c static ssize_t amdgpu_securedisplay_debugfs_write(struct file *f, const char __u · line 109
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_securedisplay.c +0
-0ret =pm_runtime_get_sync (dev->dev);if (ret <0 ) {
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx