From nobody Wed Dec 27 15:15:02 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4T0ZvB6xy0z55nlj; Wed, 27 Dec 2023 15:15:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4T0ZvB6HHTz3J8C; Wed, 27 Dec 2023 15:15:02 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1703690102; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=HVEyC/Low9VHZrHWzRfII5P2Pmt8Y7c3+1L0jHDQjPo=; b=VDBDhhOo+iNPoh6ntdwg5v1cOzE+qSKvrXZL3UrR0DKiJ/YjPGAHUjZLTQwBEAvar7bh1Z KJD8hhCTU9Zxd3038HcLbvRmOH+gTZQtV3Dj7TBO6sQSKHuZXXlh6vGeuojI603ywN6Zpv ItKHaUlV91N6QiZAIacoB6D+OOYq0rdTaHG7W+/BbR3r76jwD/gM0DUfjn+cUlWG6a1Wrf 2pPTmIYiGoz3D5HqbotvUHa+G3R0cb6uTdbAN4vDlkFBSDuz9ibYafocmtVrlPVhDRaDFg jS7mP4qTlzLzYHHiaVhkHSFC1muFfBe7VUlQzw9NLGrIakTb0qEANHiCVORxkA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1703690102; a=rsa-sha256; cv=none; b=RjAV3zQ0E1wgrl6j1QS+am9aSztvdwaIW7EfJAmuhrYbTLYmks2+nuG1wgi5dMK6Wx3sfD QiABDMEG0/TSUZdNDWtG1i76h8YkKcWfO5xNGbt+Hy8FEOgLpe81pttcKqLMRbvk25Ztej YzWMZ3p8jzE+W/XRf0oArYNmps1nXd7DWRkR1bYTYmrarYSjuLBlXK3zIbxth1JaKnKy/H MwtIuCsCywz/Ap3bcF9nCIi43HlB2C9CA00sF2fvcve92uSvPl5claTgHfQiqR3jcoFvvR +Q37tOFVAhzO9bubzuYReGmt1peqhJsf3lxWf2fv6m+XNzBjKvMYr9E5/23Xeg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1703690102; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=HVEyC/Low9VHZrHWzRfII5P2Pmt8Y7c3+1L0jHDQjPo=; b=cqQc0vSdvzeZEQckN6KsbJoWgKdMWqPNJeiPmWhTkibVAu39oqxmJpCo3lFp/NXNQVeBTZ QiKNcGsXN32bShVpNNfXFe5Hdmo9fXuXPYWUjK76+e7PbtI1aWIbnB31ERa5D3kprlQGda 4vZjqmGTlmgULBm5Z9M/YyXKqINQl2qj3nBOh67yI/w8ZhTOqVhAdxrt1JrHMRjJtO6y9C zvjaTsqBRKy5+7XL5pOTZv6PCGC8AOZb+PdHwep+PfuvQtD+8aSb3gntBuautoa9PDE4/u JA6cYQrPqpbcqRHboREWhBgcTIadk+HRYdnO6+9s2zaOmMt8VD4/KhZwKcbejg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4T0ZvB5NkLzjm0; Wed, 27 Dec 2023 15:15:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3BRFF2bG047663; Wed, 27 Dec 2023 15:15:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3BRFF2Lr047660; Wed, 27 Dec 2023 15:15:02 GMT (envelope-from git) Date: Wed, 27 Dec 2023 15:15:02 GMT Message-Id: <202312271515.3BRFF2Lr047660@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: b9924c202fc3 - main - linux: Check for copyout errors in ioctl handlers List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b9924c202fc34004d4164cdc50f88d8fcef26279 Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=b9924c202fc34004d4164cdc50f88d8fcef26279 commit b9924c202fc34004d4164cdc50f88d8fcef26279 Author: Mark Johnston AuthorDate: 2023-12-27 15:13:15 +0000 Commit: Mark Johnston 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(<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);