git: 517a81cdb40b - stable/13 - uhid: Check for errors from copyin() in ioctl handlers
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 02 Jan 2024 01:12:57 UTC
The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=517a81cdb40b5d17774d97a1ee1135a35a97be07 commit 517a81cdb40b5d17774d97a1ee1135a35a97be07 Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2023-12-26 01:38:04 +0000 Commit: Mark Johnston <markj@FreeBSD.org> 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: