From nobody Tue Jan 02 01:12:57 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 4T3vwn53Txz563CG; Tue, 2 Jan 2024 01:12:57 +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 4T3vwn21bXz3ZWc; Tue, 2 Jan 2024 01:12:57 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704157977; 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=V/pX2PfffrPeBZJlMHQQtGVBioEhiqG6r8DXwslvh/g=; b=rF3DYc6vHawBFnLurzCDYNhZR7CSozzDvtWObqeG0vX2WV1Hdz+BhiqtkMJkXHoAYCjWPk yeOtbgoi3a02/ytprxU7Na2uzoWiUCoQVMWxSBJGSesoKqXZugCB0fwi6eby2JdoqqUvpQ 1e+ask0c5tH1IZS4/1O3o9Ktki9LRF/YOk6SGw2ZEOmTUxregpP3xr+QXl8laW57iXqe6w FnBTlCrA3CWMyY/UcsdHZ4bMJ2smBMcRFHMHTuoj+f0DJm4t6/6knlEaUfjivxOge3RZAj b7198hUUk2W74LNgcj6OXl70aKktvWmUwgnKQZ/P2jzdzYv5I5Eg/QvlMSD7NQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1704157977; a=rsa-sha256; cv=none; b=Ty0tSL6BbeOmwEqyeHk9P9pIl3FP+cbQMUfTpt//iieQtjtBZjfwV7USPPuwadsiwrOeCs 6MbycgJi7Yt8Lcry/3L+ZibxV7UG+WWZEf1ux7Y5yNmFb4kmoDxdKPVWGhm/hrEnwjL8DR vx6uW+JpCBQXpKEv0hm8F/ll5IvQ1wdRO0AU/04BhmY3/9wukX8Vnuaa2SpKmNG4ha5rns hTUUXFU9xRQ73AR2vIqCjAepXnzTsLhUq4Z48ly722ij3fvTtBhpH6jwtWIF1GOfAf7+TK Rt/gsWMvItmWJQXSe3ieT+A+xQI0Z4xgBh1lN/CcTHs1z4C9VoDlDZ+ZVXsNJA== 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=1704157977; 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=V/pX2PfffrPeBZJlMHQQtGVBioEhiqG6r8DXwslvh/g=; b=Obsyu9K6eV/n1I1Xc0SZSIDyu0xjn3t5D3YbObCHrJMEqnH3Qoj1/YFYKBNaBE7BpI/kcD 8anzyp2TGuNkb8FPS6XtajfizCQt0oV02kMm6Z0vC5TX1v399dFat01zhk9/m4xi7n6VUG 0UCpnQBwLlRseOkAWRCWLWr/HZG7qRKGwq7YPELiPu030f7BCzMcJKRH+y14XAJaq0ALlD wEsuQ0dHXwBKR7ODetxAx65iw1/CrxNg/pmmBLo0/ndzZ0YyjQmoONRPQnwTwc+LelMYNR 40JmOvkH3T3fTK0/dfmAle81a6ehPHkvOuCg2NGuncf7n2EqecZiYVgbBSY3FQ== 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 4T3vwn17WRzgdj; Tue, 2 Jan 2024 01:12:57 +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 4021Cv41054677; Tue, 2 Jan 2024 01:12:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 4021CvuY054674; Tue, 2 Jan 2024 01:12:57 GMT (envelope-from git) Date: Tue, 2 Jan 2024 01:12:57 GMT Message-Id: <202401020112.4021CvuY054674@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: 517a81cdb40b - stable/13 - uhid: Check for errors from copyin() 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/13 X-Git-Reftype: branch X-Git-Commit: 517a81cdb40b5d17774d97a1ee1135a35a97be07 Auto-Submitted: auto-generated The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=517a81cdb40b5d17774d97a1ee1135a35a97be07 commit 517a81cdb40b5d17774d97a1ee1135a35a97be07 Author: Mark Johnston AuthorDate: 2023-12-26 01:38:04 +0000 Commit: Mark Johnston CommitDate: 2024-01-02 01:12:44 +0000 uhid: Check for errors from copyin() in ioctl handlers This is in preparation for annotating copyin() and related functions with __result_use_check. Reviewed by: wulf MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D43103 (cherry picked from commit b2caed2f8d699d6dc59ecf8810d945cdea148c44) --- sys/dev/usb/input/uhid.c | 14 ++++++++------ sys/dev/usb/input/uhid_snes.c | 14 ++++++++------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/sys/dev/usb/input/uhid.c b/sys/dev/usb/input/uhid.c index 8ead8f0b86d4..f6447dd0d3c6 100644 --- a/sys/dev/usb/input/uhid.c +++ b/sys/dev/usb/input/uhid.c @@ -634,9 +634,10 @@ uhid_ioctl(struct usb_fifo *fifo, u_long cmd, void *addr, return (EINVAL); } if (id != 0) - copyin(ugd->ugd_data, &id, 1); - error = uhid_get_report(sc, ugd->ugd_report_type, id, - NULL, ugd->ugd_data, imin(ugd->ugd_maxlen, size)); + error = copyin(ugd->ugd_data, &id, 1); + if (error == 0) + error = uhid_get_report(sc, ugd->ugd_report_type, id, + NULL, ugd->ugd_data, imin(ugd->ugd_maxlen, size)); break; case USB_SET_REPORT: @@ -661,9 +662,10 @@ uhid_ioctl(struct usb_fifo *fifo, u_long cmd, void *addr, return (EINVAL); } if (id != 0) - copyin(ugd->ugd_data, &id, 1); - error = uhid_set_report(sc, ugd->ugd_report_type, id, - NULL, ugd->ugd_data, imin(ugd->ugd_maxlen, size)); + error = copyin(ugd->ugd_data, &id, 1); + if (error == 0) + error = uhid_set_report(sc, ugd->ugd_report_type, id, + NULL, ugd->ugd_data, imin(ugd->ugd_maxlen, size)); break; case USB_GET_REPORT_ID: diff --git a/sys/dev/usb/input/uhid_snes.c b/sys/dev/usb/input/uhid_snes.c index 4931c6239b39..b46454867cf3 100644 --- a/sys/dev/usb/input/uhid_snes.c +++ b/sys/dev/usb/input/uhid_snes.c @@ -359,9 +359,10 @@ uhid_snes_ioctl(struct usb_fifo *fifo, u_long cmd, void *data, int fflags) return (EINVAL); } if (id != 0) - copyin(ugd->ugd_data, &id, 1); - error = uhid_get_report(sc, ugd->ugd_report_type, id, - NULL, ugd->ugd_data, imin(ugd->ugd_maxlen, size)); + error = copyin(ugd->ugd_data, &id, 1); + if (error == 0) + error = uhid_get_report(sc, ugd->ugd_report_type, id, + NULL, ugd->ugd_data, imin(ugd->ugd_maxlen, size)); break; case USB_SET_REPORT: @@ -386,9 +387,10 @@ uhid_snes_ioctl(struct usb_fifo *fifo, u_long cmd, void *data, int fflags) return (EINVAL); } if (id != 0) - copyin(ugd->ugd_data, &id, 1); - error = uhid_set_report(sc, ugd->ugd_report_type, id, - NULL, ugd->ugd_data, imin(ugd->ugd_maxlen, size)); + error = copyin(ugd->ugd_data, &id, 1); + if (error == 0) + error = uhid_set_report(sc, ugd->ugd_report_type, id, + NULL, ugd->ugd_data, imin(ugd->ugd_maxlen, size)); break; case USB_GET_REPORT_ID: