Date: Thu, 4 Jan 2024 13:47:59 GMT From: Mark Johnston <markj@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 0328de3def9c - stable/14 - linux: Check for copyout errors in ioctl handlers Message-ID: <202401041347.404DlxXx049568@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=0328de3def9cf24590b7e5262d35bde3a5e42447 commit 0328de3def9cf24590b7e5262d35bde3a5e42447 Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2023-12-27 15:13:15 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2024-01-04 13:42:13 +0000 linux: Check for copyout errors in ioctl handlers In preparation for annotating copyin() and friends with __result_use_check. Reviewed by: dchagin MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D43199 (cherry picked from commit b9924c202fc34004d4164cdc50f88d8fcef26279) --- sys/compat/linux/linux_ioctl.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/sys/compat/linux/linux_ioctl.c b/sys/compat/linux/linux_ioctl.c index d0bc8708ebf0..41c43f1ef8e6 100644 --- a/sys/compat/linux/linux_ioctl.c +++ b/sys/compat/linux/linux_ioctl.c @@ -1449,7 +1449,7 @@ linux_ioctl_cdrom(struct thread *td, struct linux_ioctl_args *args) if (!error) { lth.cdth_trk0 = th.starting_track; lth.cdth_trk1 = th.ending_track; - copyout(<h, (void *)args->arg, sizeof(lth)); + error = copyout(<h, (void *)args->arg, sizeof(lth)); } break; } @@ -1611,7 +1611,8 @@ linux_ioctl_cdrom(struct thread *td, struct linux_ioctl_args *args) if (error) { if (lda.type == LINUX_DVD_HOST_SEND_KEY2) { lda.type = LINUX_DVD_AUTH_FAILURE; - copyout(&lda, (void *)args->arg, sizeof(lda)); + (void)copyout(&lda, (void *)args->arg, + sizeof(lda)); } break; } @@ -1771,9 +1772,10 @@ linux_ioctl_sound(struct thread *td, struct linux_ioctl_args *args) struct linux_old_mixer_info info; bzero(&info, sizeof(info)); strncpy(info.id, "OSS", sizeof(info.id) - 1); - strncpy(info.name, "FreeBSD OSS Mixer", sizeof(info.name) - 1); - copyout(&info, (void *)args->arg, sizeof(info)); - return (0); + strncpy(info.name, "FreeBSD OSS Mixer", + sizeof(info.name) - 1); + return (copyout(&info, (void *)args->arg, + sizeof(info))); } default: return (ENOIOCTL); @@ -3214,7 +3216,9 @@ linux_ioctl_v4l2(struct thread *td, struct linux_ioctl_args *args) error = fo_ioctl(fp, VIDIOC_TRY_FMT, &vformat, td->td_ucred, td); bsd_to_linux_v4l2_format(&vformat, &l_vformat); - copyout(&l_vformat, (void *)args->arg, sizeof(l_vformat)); + if (error == 0) + error = copyout(&l_vformat, (void *)args->arg, + sizeof(l_vformat)); fdrop(fp, td); return (error); @@ -3283,7 +3287,9 @@ linux_ioctl_v4l2(struct thread *td, struct linux_ioctl_args *args) error = fo_ioctl(fp, VIDIOC_DQBUF, &vbuf, td->td_ucred, td); bsd_to_linux_v4l2_buffer(&vbuf, &l_vbuf); - copyout(&l_vbuf, (void *)args->arg, sizeof(l_vbuf)); + if (error == 0) + error = copyout(&l_vbuf, (void *)args->arg, + sizeof(l_vbuf)); fdrop(fp, td); return (error);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202401041347.404DlxXx049568>