From nobody Thu Jan 04 13:47:59 2024 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 4T5Sb36SWgz56R03; Thu, 4 Jan 2024 13:47:59 +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 4T5Sb35RD1z45cL; Thu, 4 Jan 2024 13:47:59 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704376079; 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=t/9bAOY3kxxnzJVExvo5ma4MPpOW22OuzHo9KCnAGVk=; b=XW/AV03dsHl9rMo+6p9pol3ZEsn7z/7PTKp0VhS6CG2Ewvj7hGrVEI4sWX1RTAPBE5qzoJ hJSnIs8DCviqKL+vjGX5a2UlZOFoVogEjihYG/RS4ZbA4NbfqK+DL26AYVdEJ8Fj4ux0eE faM7SiEmhFPOMGOb1hCwisGq2y3gym7DuLzYE6WYL01mbyCRROPzTWKTN9z6pHXUk1ef0n WCl7/0bvJA3781WVusG3e70sY8fAtqpxlSykJHZid944sLAl2zoG+WB4fOQZoHK9+vVCnC krviqg6z0zDNLPf+eV5OCFF7QJEWPDVpuPfli7UpHupsxMUGMAX8EPUyXaP19w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704376079; 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=t/9bAOY3kxxnzJVExvo5ma4MPpOW22OuzHo9KCnAGVk=; b=QgGVDyM6E7N3mR4Y1l79nEVg72rMWfxt7YTBcC2VFCoFb7XFmSExNjg1H3YRNWhtgPbH/6 i/aGleYyIizkKnwYl/x+0F90OjXHIWV4lsdoAiAwvu3xZ2AG1UhE/kBZemcMtpFxcqKG2v 2Ot7mCs2kzsUbiyYy5XoRxFs2Cr3AunY03+1vYDXreiFahKWTetZHmiONVFiqWo5yfojCW QgqrzAOJmdt4DCtsCxnsJP3M6JNTVp9YwEVqhRHFmfmmObr6jNh1WFUUGspsMu5kJMQwje nxW6zO5ZNKdbtH1n6NTeva35w8CSeGuzxz6Yxnz+DOHxEuQ/DUN9hAhm+jguig== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1704376079; a=rsa-sha256; cv=none; b=X637E2KOIeT2rKQOu6cW9QnvV/EHG/aUL3QZMsr0vIy7DjDFl941/rEkqq1YMrxXs5bzWE hOfLNCwDLfLmz1R4P6h76P5n8ki+sIfOdxnFMQdZ5T1iZAbjqIVVOusrGNbs1XvsyZPTQm fHYQyoVCn6Gu97D3zDbFkxe8nzCDFKJTb86vzVsoUwYE7zd6U6LotU5QLqnY5ARiTZWG0D L4Y/lnZOOKurJAUaGRYvEMmnRBNIsjfXcv3Dzdowwq1CTeRyS/JXhgU2eqIiC02vEMjTaf eSnrFcx/Prn/aP8/AtFVM1nhbFaylYHBNBFcnZlNj9lOm8gADjjmmALLuGKAEA== 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 4T5Sb34Bt1zGLy; Thu, 4 Jan 2024 13:47:59 +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 404Dlx5g049573; Thu, 4 Jan 2024 13:47:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 404DlxXx049568; Thu, 4 Jan 2024 13:47:59 GMT (envelope-from git) Date: Thu, 4 Jan 2024 13:47:59 GMT Message-Id: <202401041347.404DlxXx049568@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 0328de3def9c - stable/14 - 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/stable/14 X-Git-Reftype: branch X-Git-Commit: 0328de3def9cf24590b7e5262d35bde3a5e42447 Auto-Submitted: auto-generated The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=0328de3def9cf24590b7e5262d35bde3a5e42447 commit 0328de3def9cf24590b7e5262d35bde3a5e42447 Author: Mark Johnston AuthorDate: 2023-12-27 15:13:15 +0000 Commit: Mark Johnston 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);