From nobody Tue Jan 02 00:37:14 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 4T3v7b0B1Pz55yTX; Tue, 2 Jan 2024 00:37: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 4T3v7Z4mxPz3HZv; Tue, 2 Jan 2024 00:37:14 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704155834; 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=IFm4DY/z/xfAYNoI1thOjNbqZZgMpg5lMdXIO5UW2Cg=; b=Zq88i/KJJUuedXVdyvmspBy/NMa1a9Ag95iYqS6ddboK4AznPMM1NR35hOrHzkx7YBlbdQ DL+FBeuC0TKCW/C2aN7E2iy8vKNo9qA0Smy6+3JUepiW45X8plCML6C+Bs4Cg7rLs2I8jo 1Z62Kts4TH/0ijE87NT0vPUcRppxWTnKTp2EZ4i8Xxw6APq8Rf7/j1brEXbkoj750fapP9 MKAotunJ6fn0UkbFk/Ea7yFdGMRuq++2recdny9H1IhdIuTvw0B8839S23FQUvt4guke+4 8fGDH4ermMmFCJyyvCPIyijL9FOlc49Q6LfumBLsdu3MZUTZLSrV8quZGQJVEA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1704155834; a=rsa-sha256; cv=none; b=xiEXdRttYJVIZGu4QHYIh9YfUGqnGinWBS0ABKqy2DNAYqDATgjdHBC4Xfntw3ugMelpnw aB3vjB7ymsoIR3bDRNrsRNo+z5SOEcjFCw+23+zcMk71Qj6hxE5rOnyucVumw2ZdMX/NBH vvfKbWsHtT+occn2RarSYHhKtbpPYIk/yi+agDFGypDT5i32FTp+bNaV255K+ADlIkdh7g 7Eps7sLL9BTdT/4L/SMF7vCaPT/IPTY0D6R2HCCZjJS6xvwjFQJ/Y2uILNWYzepfzc1qum Gkf9hZqPTBHWTlkAba6S/QKsrXQGYctNtxyrnmRTW6qxe13batUYIJ+K4JJhfw== 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=1704155834; 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=IFm4DY/z/xfAYNoI1thOjNbqZZgMpg5lMdXIO5UW2Cg=; b=HTIlH4wemr+IJv7Ok7gIF78KL3PnMLj+izj6CAHUBvHSi7GRayx7QdWcINY135mpL3wDli q0dKx/yELfolQJYYtumSzfYcDohH6fr1BH2x91SawSjiDtHI/ensoK7yAhPTyuCrqrvFZ+ FEsgQYlXELorFWoRR62Bgk47AEm/CducLpFoCf/OGSVM5UwrWjMgNX1VjoX+BLkWbjE87M +W+DuIF2oMOJre1bHpgtbXYIWHNviMy7woGekhYcgBq1oH11tPMPXGIH2Ee7k2PjrZmGbJ 6wAQvhdAnGjtpIEipFEYq4IRKAD/6+UjFoUTHZpauYYJ00ljVoJFD9Tq+gcc9g== 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 4T3v7Z3glQzfsg; Tue, 2 Jan 2024 00:37: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 4020bEoc085029; Tue, 2 Jan 2024 00:37:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 4020bEwa085026; Tue, 2 Jan 2024 00:37:14 GMT (envelope-from git) Date: Tue, 2 Jan 2024 00:37:14 GMT Message-Id: <202401020037.4020bEwa085026@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: f9946e9ae724 - stable/14 - 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/14 X-Git-Reftype: branch X-Git-Commit: f9946e9ae7240d0c27d1062bec54d48e14b4204a Auto-Submitted: auto-generated The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=f9946e9ae7240d0c27d1062bec54d48e14b4204a commit f9946e9ae7240d0c27d1062bec54d48e14b4204a Author: Mark Johnston AuthorDate: 2023-12-26 01:38:04 +0000 Commit: Mark Johnston CommitDate: 2024-01-02 00:29: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 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: