From nobody Tue Nov 17 17:08:05 2026 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 4jTWQF4Fm8z71S7W for ; Tue, 17 Nov 2026 17:08:05 +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) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jTWQF2ZxNz4MZG for ; Tue, 17 Nov 2026 17:08:05 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794935285; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=8MZW351ms0NYI3Gs0AiZR0BNB9HY64TT4t9fr1tPOCA=; b=gmKBXwt6kq0Uli/+l8v03EFIHpxRLDGQY0O3evN7VAEi2E9msUvrtXVwyaq6DReZHHgxHY 4v74nam7OAN09yuli6BDkTmsU/DfaqA1dlDPrB4VFKz3+/uKs7V2J61FwivjzXLOubCxpa MVGqapix98sdhvoCnVWfeVrMcQTVp6qF5r80KbYATIz6YLs1GHjmYsgY7UCXSg8y5RlKdD Apfh3X2uyvGeYl6TXG/FPG9hfljcLzonfnDdyrC8HECmutxufYblI9pKkoyEVLOQ/D6q6a cvSSYDJg3ymP/+YQ6uJ8LFQT6URscQw1pWNVZkSlF7BEm/nZ5/dCfTRlwtaCpQ== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794935285; b=DU1I6nQf8wyavaH/56H5RNHxQ2+MOvUADhcT7nN64K6gpHishkJhgimaNYnvPQr1hHx7oU jr13Znnm79yvl+44qx28anN/ZQSsgAmmkYFNNTnoiw6xXIr42WItHQTwj6MvkOaKGKmzdl e+uaOoGNtW39ozu3CHstjipHCViLHAa2z6p/t6FXyy6FYlW4WtVSB+vEay7cZdwA2VXq9q fJP11klw23hJSWCEr6OxPFgma+JPHMBkjFATtp7nIlkVYraOnrXTYjgthon8ya0YiKq6Ak 7j/G/Opm13TPcROR5DBJn4S8n7NCCwQ2iZU9GEhYym83EH9ry+HY/oUH3YLVwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794935285; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=8MZW351ms0NYI3Gs0AiZR0BNB9HY64TT4t9fr1tPOCA=; b=IxpNQdH9tfQUFx7Rf4GTmPs6KFcJPGzQI4uN8SgI66Hhy+e5LNs1jUqB23feHDVH3tAg3i ojvPRemAnaitWbntJmSXNgTjuvSECByrlr1YQBdAcEbfG+MT0LiDVQenNqQczgIGfqi6kx 2KJF5TpdtHZX6k5KMVvbsNk6Rgukkbm6b5+th6FQmansgn6DhPqnCJT1W4YAUun2f7JkI1 lCX/EwPn/cubRA1fIyMXMw2JjmoBuLKE8yyqv1JTJK5VK5JfUsnyc1f6uHbkUn/6ibqGgF PX0BSHUMRv/W4XADOi/Tgg/ZMk/R3vI9Rk6W+zZxL49JZ91q1byv9bq7tW/uKQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jTWQF1hq0zrn4 for ; Tue, 17 Nov 2026 17:08:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1f1c1 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 17 Nov 2026 17:08:05 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Cc: Ram Kishore Vegesna From: Mark Johnston Subject: git: f0964d6f6e06 - releng/15.1 - ocs_fc: Fix config space bounds, double PRLI response and a stack overflow List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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/releng/15.1 X-Git-Reftype: branch X-Git-Commit: f0964d6f6e06d86ecba10cf2b3e2c7fdf85890a6 Auto-Submitted: auto-generated Date: Tue, 17 Nov 2026 17:08:05 +0000 Message-Id: <6afc89f5.1f1c1.2d233620@gitrepo.freebsd.org> The branch releng/15.1 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=f0964d6f6e06d86ecba10cf2b3e2c7fdf85890a6 commit f0964d6f6e06d86ecba10cf2b3e2c7fdf85890a6 Author: Ram Kishore Vegesna AuthorDate: 2026-10-19 17:29:31 +0000 Commit: Mark Johnston CommitDate: 2026-11-16 21:20:59 +0000 ocs_fc: Fix config space bounds, double PRLI response and a stack overflow Fix three unrelated problems found by security review of the driver. ECD helper ioctl: - OCS_ECD_HELPER_CFG_READ* and OCS_ECD_HELPER_CFG_WRITE* passed a user supplied offset straight to pci_read_config() and pci_write_config(). Reject accesses that extend past PCIE_REGMAX, so that a wide access starting in range cannot run past the end of config space. - Use the real access width (1, 2 or 4 bytes) of the command for both the BAR and the config space checks, rather than assuming 4 bytes, so that narrow accesses at the very end of the BAR or config space are not rejected while wider ones remain bounded. PRLI: - When a PRLI carries an FC-4 type other than the one the driver supports, ocs_d_send_prli_rsp() sent an LS_RJT and started node shutdown, but then fell through and sent a second response on the same IO (another LS_RJT, or a PRLI LS_ACC when the initiator is accepted), followed by a conflicting transition to __ocs_d_device_ready. The two responses posted two WQEs for one IO and caused a double ocs_ref_put(), a use after free of the ELS IO. Return after dispatching the LS_RJT so that exactly one response is sent. - __ocs_d_port_logged_in calls ocs_d_send_prli_rsp() without checking the FC-4 type, so any port that has completed a PLOGI can trigger this with a single PRLI, whether or not target mode is enabled. Management: - The active profile id is a uint32_t that is formatted as "0x%02x" with sprintf() into a buffer of MAX_PROFILE_LENGTH (5) bytes, which overflows for any id above 0xff. Size the buffer for the longest possible string ("0x" plus 8 hex digits and the terminating NUL) and use ocs_snprintf(). - Use ocs_snprintf() for nv_wwpn as well, as nv_wwnn already does. Approved by: so Security: FreeBSD-SA-26:76.ocs_fc Security: CVE-2026-127754 MFC after: 1 week Sponsored by: Broadcom Reviewed by: ken (cherry picked from commit 039a8e11f887e359af1346b04e05180b9a49920c) (cherry picked from commit 3440d485873e82989d1bc14ed871b7ea364946c8) --- sys/dev/ocs_fc/ocs_device.c | 2 ++ sys/dev/ocs_fc/ocs_ioctl.c | 42 +++++++++++++++++++++++++++++++++++++++++- sys/dev/ocs_fc/ocs_mgmt.c | 8 +++++--- 3 files changed, 48 insertions(+), 4 deletions(-) diff --git a/sys/dev/ocs_fc/ocs_device.c b/sys/dev/ocs_fc/ocs_device.c index d9c283541d3c..4d85970df675 100644 --- a/sys/dev/ocs_fc/ocs_device.c +++ b/sys/dev/ocs_fc/ocs_device.c @@ -74,6 +74,8 @@ ocs_d_send_prli_rsp(ocs_io_t *io, uint16_t ox_id) FC_EXPL_REQUEST_NOT_SUPPORTED, 0, NULL, NULL); node->shutdown_reason = OCS_NODE_SHUTDOWN_DEFAULT; ocs_node_transition(node, __ocs_d_initiate_shutdown, NULL); + /* Send only one response per PRLI; the LS_RJT owns the IO */ + return; } /* If the back-end doesn't want to talk to this initiator, we send an LS_RJT */ diff --git a/sys/dev/ocs_fc/ocs_ioctl.c b/sys/dev/ocs_fc/ocs_ioctl.c index a978f1084452..18dd3fbbac4c 100644 --- a/sys/dev/ocs_fc/ocs_ioctl.c +++ b/sys/dev/ocs_fc/ocs_ioctl.c @@ -41,6 +41,8 @@ #include #include +#include + static d_open_t ocs_open; static d_close_t ocs_close; static d_ioctl_t ocs_ioctl; @@ -299,6 +301,28 @@ no_support: return error; } +/** + * @brief return the access width in bytes of an ECD helper BAR/config command + */ +static uint32_t +ocs_ecd_helper_width(ocs_ecd_helper_cmd_t cmd) +{ + switch (cmd) { + case OCS_ECD_HELPER_BAR_READ8: + case OCS_ECD_HELPER_BAR_WRITE8: + case OCS_ECD_HELPER_CFG_READ8: + case OCS_ECD_HELPER_CFG_WRITE8: + return (sizeof(uint8_t)); + case OCS_ECD_HELPER_BAR_READ16: + case OCS_ECD_HELPER_BAR_WRITE16: + case OCS_ECD_HELPER_CFG_READ16: + case OCS_ECD_HELPER_CFG_WRITE16: + return (sizeof(uint16_t)); + default: + return (sizeof(uint32_t)); + } +} + /** * @brief perform requested Elx CoreDump helper function * @@ -318,6 +342,7 @@ ocs_process_ecd_helper (ocs_t *ocs, ocs_ioctl_ecd_helper_t *req) uint8_t v8; uint16_t v16; uint32_t v32; + uint32_t width; /* Check the BAR read/write commands for valid bar */ switch(req->cmd) { @@ -327,6 +352,7 @@ ocs_process_ecd_helper (ocs_t *ocs, ocs_ioctl_ecd_helper_t *req) case OCS_ECD_HELPER_BAR_WRITE8: case OCS_ECD_HELPER_BAR_WRITE16: case OCS_ECD_HELPER_BAR_WRITE32: + width = ocs_ecd_helper_width(req->cmd); if (req->bar >= PCI_MAX_BAR) { device_printf(ocs->dev, "Error: bar %d out of range\n", req->bar); return -EFAULT; @@ -335,13 +361,27 @@ ocs_process_ecd_helper (ocs_t *ocs, ocs_ioctl_ecd_helper_t *req) device_printf(ocs->dev, "Error: bar %d not defined\n", req->bar); return -EFAULT; } - if ((uint64_t)req->offset + sizeof(uint32_t) > + if ((uint64_t)req->offset + width > rman_get_size(ocs->reg[req->bar].res)) { device_printf(ocs->dev, "Error: bar %d offset 0x%x out of range\n", req->bar, req->offset); return -EFAULT; } break; + case OCS_ECD_HELPER_CFG_READ8: + case OCS_ECD_HELPER_CFG_READ16: + case OCS_ECD_HELPER_CFG_READ32: + case OCS_ECD_HELPER_CFG_WRITE8: + case OCS_ECD_HELPER_CFG_WRITE16: + case OCS_ECD_HELPER_CFG_WRITE32: + width = ocs_ecd_helper_width(req->cmd); + if ((uint64_t)req->offset + width - 1 > PCIE_REGMAX) { + device_printf(ocs->dev, + "Error: config offset 0x%x out of range\n", + req->offset); + return -EFAULT; + } + break; default: break; } diff --git a/sys/dev/ocs_fc/ocs_mgmt.c b/sys/dev/ocs_fc/ocs_mgmt.c index 5b7f6557c017..483e80ce649a 100644 --- a/sys/dev/ocs_fc/ocs_mgmt.c +++ b/sys/dev/ocs_fc/ocs_mgmt.c @@ -2076,7 +2076,8 @@ ocs_mgmt_get_active_profile_cb(int32_t status, uint32_t active_profile, void *ul ocs_sem_v(&(result->semaphore)); } -#define MAX_PROFILE_LENGTH 5 +/* "0x", up to 8 hex digits and a NUL for a uint32_t id */ +#define MAX_PROFILE_LENGTH 11 /** * @brief Get active profile @@ -2107,7 +2108,7 @@ get_active_profile(ocs_t *ocs, char *name, ocs_textbuf_t *textbuf) } if (result.status == 0) { /* Success. */ - sprintf(result_string, "0x%02x", result.active_profile_id); + ocs_snprintf(result_string, sizeof(result_string), "0x%02x", result.active_profile_id); ocs_mgmt_emit_string(textbuf, MGMT_MODE_RW, "active_profile", result_string); } else { ocs_log_test(ocs, "getting active profile status 0x%x\n", result.status); @@ -2225,7 +2226,8 @@ get_nv_wwpn(ocs_t *ocs, char *name, ocs_textbuf_t *textbuf) } if (result.status == 0) { /* Success. Copy wwpn from result struct to result string */ - sprintf(result_string, "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", + ocs_snprintf(result_string, sizeof(result_string), + "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", result.wwpn[0], result.wwpn[1], result.wwpn[2], result.wwpn[3], result.wwpn[4], result.wwpn[5], result.wwpn[6], result.wwpn[7]);