From nobody Thu Jun 15 16:35:38 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 4QhnwB4M7pz4fQNF; Thu, 15 Jun 2023 16:35:38 +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 4QhnwB3xpjz4Ds9; Thu, 15 Jun 2023 16:35:38 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1686846938; 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=ELxQ4jP1dEG84JGvP0obGUZ42VXtgBylduIYR23eZts=; b=aQHSYDjtBz0z0i4xsLfxvf29r2UJVy5Wxe3ahWtSMegW8TNhp4hDS9f5wWzBTDiLtsVbr/ Dk0mKwU1s1W3zd1eYjL9Zx22L58IHfiC3VvifIEDaswY1TmTEPHFU4dlkp251bB5K7sLL5 D/V34mxeSP2bD7IAKpmBfJHFLr4I4y7dWK6fA6yop6f8dZmKQJxG3trwE/ZDLysZvkjuCI wDnXeQE2OCCTN5kEmCqEIio4EOCg7/6CjG9VVSXCngWChJl0e0vFQ7YOf+JRogSeJtp+mY wzWy5VXy+tRTKl1D8IZ0w9ezzg+u5VLCKa3TpNUn4jb2wRGPdNxlP76kmLbBTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1686846938; 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=ELxQ4jP1dEG84JGvP0obGUZ42VXtgBylduIYR23eZts=; b=ZHUjiAnp6d0Vhl4MT7PkiJNTAf/ujh0sh64Oc8qC0e2rLB4pXOp6ynW10XT1n0VAk5U97W Y2zKGsLnlMzCzwGhlU1BO7biHugLog+PuiasTvuodKc24GX0k+0nn++sVspLo7ZKDSTqZN 98hkJAca2uwwi5iShRAbuZu5w9+FjhsZMxBCiU4ZVFl827hlHHgHBFXkN9NyWveB/D/UH4 sYc28tA/cFu1URZTA1x/KcjQXZNacES93PJ9hZddoF8bE0HKFDxnL6hGfpi58jLA/LJYgF dnNy2lhIISr3T1mTZIJZ9AKOeYiSQTuTumYGHP26LHlu56YwINoyBh945Pp/1Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1686846938; a=rsa-sha256; cv=none; b=J4LzhulFQL1MNmvYESArmD4e3fnXDCk+83XvB4c+W9mk4axLAnsYIQ3NuI3R4wqgtpEyAK 2zk5KQJpez0folaQhnvzJVOJ968ZxR0VEyeEPh/h+zdrqwiYCvOQueRL2XQudxSkDAWzc2 /UCilYGCkd9s6RZ3W47seq7YkA/7koquSG/sgZE3ZFoHOKFfZwCz9VCkaYbNjZptKqrJAi qzbaG+ZRLXTOw8ac3abuSYd4p8wKjNamOzhUAt43h4U9XPUqyKDyMIijQ3YdIMMu6B2/N0 M+RGZoF63kYSCUdyO7dOnrclmp9I25d+xdS3D1BH0gmwmoFJCxoBMhAKKIauMg== 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 4QhnwB315gztB3; Thu, 15 Jun 2023 16:35:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 35FGZcgX085221; Thu, 15 Jun 2023 16:35:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 35FGZckD085220; Thu, 15 Jun 2023 16:35:38 GMT (envelope-from git) Date: Thu, 15 Jun 2023 16:35:38 GMT Message-Id: <202306151635.35FGZckD085220@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Brooks Davis Subject: git: 758927a982db - main - oce(4): Don't directly access usespace 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: brooks X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 758927a982db0ae3ebb02c05aec8a53bcc0c20cb Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by brooks: URL: https://cgit.FreeBSD.org/src/commit/?id=758927a982db0ae3ebb02c05aec8a53bcc0c20cb commit 758927a982db0ae3ebb02c05aec8a53bcc0c20cb Author: Brooks Davis AuthorDate: 2023-06-14 17:55:41 +0000 Commit: Brooks Davis CommitDate: 2023-06-15 16:34:54 +0000 oce(4): Don't directly access usespace Replace direct stores to userspace addresses (never safe and broken on modern CPUs) with a copyout. Use a static assert on the size to ensure we don't overflow the field. Reviewed by: markj, jhb Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D40519 --- sys/dev/oce/oce_if.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/sys/dev/oce/oce_if.c b/sys/dev/oce/oce_if.c index 5d250fcac0bd..bde7bf9b208a 100644 --- a/sys/dev/oce/oce_if.c +++ b/sys/dev/oce/oce_if.c @@ -2246,7 +2246,6 @@ oce_handle_passthrough(if_t ifp, caddr_t data) uint32_t req_size; struct mbx_hdr req; OCE_DMA_MEM dma_mem; - struct mbx_common_get_cntl_attr *fw_cmd; if (copyin(priv_data, cookie, strlen(IOCTL_COOKIE))) return EFAULT; @@ -2278,17 +2277,25 @@ oce_handle_passthrough(if_t ifp, caddr_t data) goto dma_free; } - if (copyout(OCE_DMAPTR(&dma_mem,char), ioctl_ptr, req_size)) + if (copyout(OCE_DMAPTR(&dma_mem,char), ioctl_ptr, req_size)) { rc = EFAULT; + goto dma_free; + } /* firmware is filling all the attributes for this ioctl except the driver version..so fill it */ if(req.u0.rsp.opcode == OPCODE_COMMON_GET_CNTL_ATTRIBUTES) { - fw_cmd = (struct mbx_common_get_cntl_attr *) ioctl_ptr; - strncpy(fw_cmd->params.rsp.cntl_attr_info.hba_attr.drv_ver_str, - COMPONENT_REVISION, strlen(COMPONENT_REVISION)); + struct mbx_common_get_cntl_attr *fw_cmd = + (struct mbx_common_get_cntl_attr *)ioctl_ptr; + _Static_assert(sizeof(COMPONENT_REVISION) <= + sizeof(fw_cmd->params.rsp.cntl_attr_info.hba_attr.drv_ver_str), + "driver version string too long"); + + rc = copyout(COMPONENT_REVISION, + fw_cmd->params.rsp.cntl_attr_info.hba_attr.drv_ver_str, + sizeof(COMPONENT_REVISION)); } dma_free: