The branch main has been updated by markj:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=b9924c202fc34004d4164cdc50f88d8fcef26279

commit b9924c202fc34004d4164cdc50f88d8fcef26279
Author:     Mark Johnston <ma...@freebsd.org>
AuthorDate: 2023-12-27 15:13:15 +0000
Commit:     Mark Johnston <ma...@freebsd.org>
CommitDate: 2023-12-27 15:13:15 +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
---
 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(&lth, (void *)args->arg, sizeof(lth));
+                       error = copyout(&lth, (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);
 

Reply via email to