From nobody Tue Dec 26 02:04:14 2023 X-Original-To: dev-commits-src-main@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 4SzdPC1HXFz55KJZ; Tue, 26 Dec 2023 02:04:15 +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 4SzdPB6xmvz4JhM; Tue, 26 Dec 2023 02:04:14 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1703556255; 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=IaEy/PEOFYg5HT5Operw1zJKf5Ts8zCVSngNyEMK/Go=; b=uE8RNv7VduyFAfWopSsX0Barwr5aiBUPsJEhevb7O0lVLpgkblZ7QY2xGVRNgmb8kzy7aR vL2GWd15BGd0fvtIaDIZnSCbA50yl+r9Za8jE12BeACCYhAIwIjSNpIro0ZLl1Bnaf10WU OHfRIPmcvVMqibXECfh0iZmsXxaDd5fipwTZK31+j0s0DhcGH2vdV53ZWJOYGu0zPLRUkU ieWNdx/wHlhonmCAsW7Q8nJyKwmuY/lIe+sKixLVlyT1QwygU22x2diNV+72o/KpjjeFeb l9Q18WQGFuQMeXZ0JGkSbnhKzBKDGORQrghtw12152sGslv/2yqLjblaWeMApw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1703556255; a=rsa-sha256; cv=none; b=A/mDqMLe3UdObsPTxrVMCJukn1BTRclOiaMEphs3RKvtRvBCZQeCDuE8c5IJi+b0RSZWul nTjIi5ml6IMSH0Cb5ZfroqwGtKB72ss1oG3xdrYJS34I5HppN/Mmf+Z47wccWfXi/IsPN4 w+7CQ76R/sCRGRtp7GjzRz9Osr21nrWdkz8oREJifHYVIP30x0Z74WONXnqnhAUo9qO1eq QsrMTq73oK8Fz7R93s/YRSo1+cCZENbN5GwqIlt8wckwqpJZhTDiEmuoH9WgIisQFb/uUS kqZgR1g78tq23SAm5ZnyT/1dr2uyWZomdgobjz+8mEwcExnyikxiPmEUGCd/Dw== 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=1703556255; 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=IaEy/PEOFYg5HT5Operw1zJKf5Ts8zCVSngNyEMK/Go=; b=C/gde+ZDcX9KER6sCpvBiFds0ijgMuRcrnG/hcsawciheq8KKfH7OuCcxX7A97XZWrzl9z 9IGt1oIJ3gGogakIzVPhDMnHmGFztHVGqH0mrH/nVbogQP3Y1RfQiLtpIQVCQjJvtYTcPJ 4s4Y47MUu9vmiVkVaqX2ew+9rjiDWd8J4Z3drUQndjz1UVs9mF48kN0e73JgVl/rWX4d4W xrgFVngfVV9Lthu7jqNxD3u5Haf0BpT4mrMQ76o8FCvf6RRzX2jvuwb/st3NwYmkq/qOgR eePHQYwiBKEnVL+JgfBtW5m/oqG5GaUbNF+yYCO5EQuftOmzRRrkAHUJn4eTpw== 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 4SzdPB6311zc77; Tue, 26 Dec 2023 02:04:14 +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 3BQ24EHe002797; Tue, 26 Dec 2023 02:04:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3BQ24ETu002794; Tue, 26 Dec 2023 02:04:14 GMT (envelope-from git) Date: Tue, 26 Dec 2023 02:04:14 GMT Message-Id: <202312260204.3BQ24ETu002794@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: b2caed2f8d69 - main - uhid: Check for errors from copyin() in ioctl handlers List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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: b2caed2f8d699d6dc59ecf8810d945cdea148c44 Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=b2caed2f8d699d6dc59ecf8810d945cdea148c44 commit b2caed2f8d699d6dc59ecf8810d945cdea148c44 Author: Mark Johnston AuthorDate: 2023-12-26 01:38:04 +0000 Commit: Mark Johnston CommitDate: 2023-12-26 02:04:00 +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 --- 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 2f65a07dea56..863e04f4e52b 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 085881faa88b..7a16542794cc 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: