media: v4l2-core: only zero-out ioctl-read buffers
PATCH 1/1 media: v4l2-core: only zero-out ioctl-read buffers
The memset() got moved out of the check for _IOC_NONE, so passing a made-up command number with a size but no direction would allow clearing data on user-provided pointers.
Move video_get_user() back into the _IOC_NONE check where it belongs.
Reported-by [email protected]
Fixes 6c625c01c7a6 ("media: v4l2-core: split out data copy from video_usercopy")
Signed-off-by Arnd Bergmann <[email protected]>
--- drivers/media/v4l2-core/v4l2-ioctl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/media/v4l2-core/v4l2-ioctl.c +4 -4
@@ -3208,12 +3208,12 @@ video_usercopy(struct file *file, unsigned int orig_cmd, unsigned long arg, parg = mbuf; } + err =video_get_user ((void __user *)arg, parg, orig_cmd, + &always_copy); +if (err) + goto out; } - err =video_get_user ((void __user *)arg, parg, orig_cmd, &always_copy); -if (err) - goto out; - err =check_array_args (cmd, parg, &array_size, &user_ptr, &kernel_ptr);if (err <0 ) goto out;
Signature · 1 line
2.20.0
Quoted 9 lines · Arnd Bergmann
The
memset()got moved out of the check for_IOC_NONE, so passing a made-up command number with a size but no direction would allow clearing data on user-provided pointers.Move
video_get_user()back into the_IOC_NONEcheck where it belongs.Reported-by [email protected]Fixes 6c625c01c7a6 ("media: v4l2-core: split out data copy from video_usercopy")Signed-off-by Arnd Bergmann <[email protected]>
Thanks for the fix, Arnd!
Reviewed-by Sakari Ailus <[email protected]>
Quoted 25 lines
--- drivers/media/v4l2-core/v4l2-ioctl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/media/v4l2-core/v4l2-ioctl.c +4
-4@@ -3208,12 +3208,12 @@ video_usercopy(struct file *file, unsigned int orig_cmd, unsigned long arg, parg = mbuf; } + err =video_get_user ((void __user *)arg, parg, orig_cmd, + &always_copy); +if (err) + goto out; } - err =video_get_user ((void __user *)arg, parg, orig_cmd, &always_copy); -if (err) - goto out; - err =check_array_args (cmd, parg, &array_size, &user_ptr, &kernel_ptr);if (err <0 ) goto out;
Signature · 2 lines
Sakari Ailus [email protected]