From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 56164426EC7; Tue, 31 Mar 2026 16:52:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774975979; cv=none; b=fm32ep21NC6VTtDoD9gwemygrVy6kGGZAgi2uKhSkHGU/PgfHhV6VyfdypzFH3XJXP07zAaRn+Y7orpMRrhW4fFHkzA5Lym4ZBk2rLAt/U7yCtyoHiGhVKo7ie9BXvRkJWhU5m8LqDG5B3ZrU/QVI1ZGYZc3EksjZf0czTsY0gM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774975979; c=relaxed/simple; bh=VKf9WV1IQl9az5wRuntkEDluiKBg8lXh3u0pyqj94qY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GjrnWSVfZO5iP4sWBjhuNwrQcEg25WX2Hju1QS5ovwoVbj/i7uhBPPpg9euooAnQhqC6RhKX39siSOaCmu9sghYHTyT8dANLoIoIeFU97CwLtdNMPsswWZIWkpRzfRpcfuJHapKxkOkYgK48FFUEQXeQOFKX0Wo4kapUqHNPdN8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=AgwOniT2; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="AgwOniT2" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE3E7C19423; Tue, 31 Mar 2026 16:52:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1774975979; bh=VKf9WV1IQl9az5wRuntkEDluiKBg8lXh3u0pyqj94qY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AgwOniT2nE7nimHSY7mkfm0EmqPJ2lw9sIKbXjaG6HgIyVCT5Ic7ZzlPffX5+Ldon 8b79knP9mjKuSyU2zI/BBw48KMBZWBVJX7UCh9JlaZd3YK6LAYuqQ9L+XcVb7sR8Rq 9WE7rcl6Q3qrmJlcOLX9B9Az6qc+HKvAdbMvntsY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yuhao Jiang , Tyllis Xu , Dave Marquardt , Tyrel Datwyler , "Martin K. Petersen" Subject: [PATCH 6.12 160/244] scsi: ibmvfc: Fix OOB access in ibmvfc_discover_targets_done() Date: Tue, 31 Mar 2026 18:21:50 +0200 Message-ID: <20260331161747.677100471@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260331161741.651718120@linuxfoundation.org> References: <20260331161741.651718120@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Tyllis Xu commit 61d099ac4a7a8fb11ebdb6e2ec8d77f38e77362f upstream. A malicious or compromised VIO server can return a num_written value in the discover targets MAD response that exceeds max_targets. This value is stored directly in vhost->num_targets without validation, and is then used as the loop bound in ibmvfc_alloc_targets() to index into disc_buf[], which is only allocated for max_targets entries. Indices at or beyond max_targets access kernel memory outside the DMA-coherent allocation. The out-of-bounds data is subsequently embedded in Implicit Logout and PLOGI MADs that are sent back to the VIO server, leaking kernel memory. Fix by clamping num_written to max_targets before storing it. Fixes: 072b91f9c651 ("[SCSI] ibmvfc: IBM Power Virtual Fibre Channel Adapter Client Driver") Reported-by: Yuhao Jiang Cc: stable@vger.kernel.org Signed-off-by: Tyllis Xu Reviewed-by: Dave Marquardt Acked-by: Tyrel Datwyler Link: https://patch.msgid.link/20260314170151.548614-1-LivelyCarpet87@gmail.com Signed-off-by: Martin K. Petersen Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/ibmvscsi/ibmvfc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/scsi/ibmvscsi/ibmvfc.c +++ b/drivers/scsi/ibmvscsi/ibmvfc.c @@ -4963,7 +4963,8 @@ static void ibmvfc_discover_targets_done switch (mad_status) { case IBMVFC_MAD_SUCCESS: ibmvfc_dbg(vhost, "Discover Targets succeeded\n"); - vhost->num_targets = be32_to_cpu(rsp->num_written); + vhost->num_targets = min_t(u32, be32_to_cpu(rsp->num_written), + max_targets); ibmvfc_set_host_action(vhost, IBMVFC_HOST_ACTION_ALLOC_TGTS); break; case IBMVFC_MAD_FAILED: