From patchwork Thu Jul 11 17:28:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 13730940 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 5A07D161B43; Thu, 11 Jul 2024 17:28:22 +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=1720718902; cv=none; b=dSLGgWUdkHHJMUBjoCgoqovdQiHI09H3FabbpKVk3kPmWyQyzEdZb7q/yh8DRQCrLsVS6PrqTJxrWkiSCGvqBqjeDP831Q+L5d05KQSjW6207JzIOVEDrJaESeuxUDlNIqQnfZ/bdOZrJ/pKJ1WnF3tr/VR2fAy2SxP97c81Jpo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720718902; c=relaxed/simple; bh=S/t7jEfsjpSOFiX2lqIU3Uboq5XyFS6FeOQZndPIGIE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZlSZ2G4h6BHiUD4PUtKyYGBBEuHF0ghXpF91sUZZjJknzgvLvjQYZv6iy4veOOA1324JvdWgthqYsnlS7k3ZkRV/V213koHIuiRqkQ7S1Zdok1CIT6kT8w6xg034dqAsRBg+4y4PIhnb7SZD5W//nfEtws8C/AQ+COnjnDw48UQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ocbYwkZI; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ocbYwkZI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0B95EC116B1; Thu, 11 Jul 2024 17:28:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720718902; bh=S/t7jEfsjpSOFiX2lqIU3Uboq5XyFS6FeOQZndPIGIE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ocbYwkZIbRZThQpOqDQiRvszH6StHF5tuWI+zDdk3c4P6f/0Ko+nxo84R4HRLhTT7 8xmQVMsRpNfMzXqsXPRb3o3oxNYuPw16e8lt5iDd35BBcPSxiaxy18eLB0mEXVm8p2 5zucKlHQDvJA5duk3yQ90QNBmTXBLsOuT+PAuBKePLJpR0/+pjVj7T5nviF8IsmgZZ sM4ymqj0cTDMFrIzj34nLa9j5riV6VvTwL5t/R1WR+Mu/ljfSZdsWNEtUuFLEv5hTT 0ektS5tRdYxFgrL6QLW4goR2Y+eAhE3aHwvLotzhbFFoi/9pjWJniJDY0SCJCstw/M dUNZEH4ikJ/kQ== From: Kees Cook To: Sathya Prakash Cc: Kees Cook , Sreekanth Reddy , Suganath Prabu Subramani , "Gustavo A. R. Silva" , MPT-FusionLinux.pdl@broadcom.com, linux-scsi@vger.kernel.org, linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/6] scsi: message: fusion: struct _RAID_VOL0_SETTINGS: Replace 1-element array with flexible array Date: Thu, 11 Jul 2024 10:28:15 -0700 Message-Id: <20240711172821.123936-1-kees@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240711172432.work.523-kees@kernel.org> References: <20240711172432.work.523-kees@kernel.org> Precedence: bulk X-Mailing-List: linux-hardening@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2598; i=kees@kernel.org; h=from:subject; bh=S/t7jEfsjpSOFiX2lqIU3Uboq5XyFS6FeOQZndPIGIE=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBmkBYz9kgTTMGIAtlV30HywJoIqN5yG0+IKrxfM Rxmxp5my4+JAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZpAWMwAKCRCJcvTf3G3A JrRjEACn7ztVfg6iizze+imGktoQFIv0ZdxFCxj80w/UO9p+bTxQ9zjpMqjcD1XB9FKsuktLWDq Oq3B3APJ7DwCuEtMDNF331HnIyNg0Ud0gcGvQ4bLkHwU9QbfTrO22DQSmdzO4feTjAG09/ALjgm EuHTDFe+vB7V0f1DukEjThNBdRly13mXQIXQUs+KrfaEfXHrGXLRMs7HXDqe8AKe8jaKleUo7N0 3uusN4oBBhXuLcTIKP0HttFChDcsdwBpPCZ15WvFRTBKKo7flcM6roE6WT3O+ZnD/FxDqY6vD+9 eP0BIAodeRKfmsKJI/Yda0kfwM40TnECm69LVhKAlZKAVlJCpzabolINZH0F81LKDS4j/vrxpZR 4afZ85C7DZ9dd/m1tj3VnSTUlbrxuduggCKxnTNSod1uMMqDdz9VMiuMOcMukaqs+A63XG0EeOa znm/Eh9zPm/wY5OsIcZfVIWHXuIiULsXviDrtomWkuskoGm6lIh/Q1+GavPO6DlLnEvXLh1njkr ME0SHw8M5k+IQMJ91tSum5cNM3rZmqxqwbMDWKK7iGIhNlLfDq5uKQXShXFrFPamjsMrx/LzBEi WEQq4nCoYmP2LYqJSBUFz/tU5Vs0p27fJQpK2Cr21Li/rYSUjxKyVp7fSaHTwGb7u75ajdMIgY4 yrjXX3H+H4lHpBQ== X-Developer-Key: i=kees@kernel.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Replace the deprecated[1] use of a 1-element array in struct _RAID_VOL0_SETTINGS with a modern flexible array. Additionally add __counted_by annotation since PhysDisk is only ever accessed via a loops bounded by NumPhysDisks: lsi/mpi_cnfg.h: RAID_VOL0_PHYS_DISK PhysDisk[] __counted_by(NumPhysDisks); /* 28h */ mptbase.c: for (i = 0; i < buffer->NumPhysDisks; i++) { mptbase.c: buffer->PhysDisk[i].PhysDiskNum, &phys_disk) != 0) mptsas.c: for (i = 0; i < buffer->NumPhysDisks; i++) { mptsas.c: buffer->PhysDisk[i].PhysDiskNum, &phys_disk) != 0) mptsas.c: for (i = 0; i < buffer->NumPhysDisks; i++) { mptsas.c: buffer->PhysDisk[i].PhysDiskNum, &phys_disk) != 0) No binary differences are present after this conversion. Link: https://github.com/KSPP/linux/issues/79 [1] Signed-off-by: Kees Cook Reviewed-by: Gustavo A. R. Silva --- Cc: Sathya Prakash Cc: Sreekanth Reddy Cc: Suganath Prabu Subramani Cc: "Gustavo A. R. Silva" Cc: MPT-FusionLinux.pdl@broadcom.com Cc: linux-scsi@vger.kernel.org Cc: linux-hardening@vger.kernel.org --- drivers/message/fusion/lsi/mpi_cnfg.h | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/drivers/message/fusion/lsi/mpi_cnfg.h b/drivers/message/fusion/lsi/mpi_cnfg.h index 3770cb1cff7d..f59a741ef21c 100644 --- a/drivers/message/fusion/lsi/mpi_cnfg.h +++ b/drivers/message/fusion/lsi/mpi_cnfg.h @@ -2295,14 +2295,6 @@ typedef struct _RAID_VOL0_SETTINGS #define MPI_RAID_HOT_SPARE_POOL_6 (0x40) #define MPI_RAID_HOT_SPARE_POOL_7 (0x80) -/* - * Host code (drivers, BIOS, utilities, etc.) should leave this define set to - * one and check Header.PageLength at runtime. - */ -#ifndef MPI_RAID_VOL_PAGE_0_PHYSDISK_MAX -#define MPI_RAID_VOL_PAGE_0_PHYSDISK_MAX (1) -#endif - typedef struct _CONFIG_PAGE_RAID_VOL_0 { CONFIG_PAGE_HEADER Header; /* 00h */ @@ -2321,7 +2313,7 @@ typedef struct _CONFIG_PAGE_RAID_VOL_0 U8 DataScrubRate; /* 25h */ U8 ResyncRate; /* 26h */ U8 InactiveStatus; /* 27h */ - RAID_VOL0_PHYS_DISK PhysDisk[MPI_RAID_VOL_PAGE_0_PHYSDISK_MAX];/* 28h */ + RAID_VOL0_PHYS_DISK PhysDisk[] __counted_by(NumPhysDisks); /* 28h */ } CONFIG_PAGE_RAID_VOL_0, MPI_POINTER PTR_CONFIG_PAGE_RAID_VOL_0, RaidVolumePage0_t, MPI_POINTER pRaidVolumePage0_t; From patchwork Thu Jul 11 17:28:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 13730942 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 684DB16DC17; Thu, 11 Jul 2024 17:28:22 +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=1720718902; cv=none; b=K15YL9Oe5OS+NX0oqRgBU5LHTj3t98imi27vk1oVPolhEFpGUP8K8DGgwje3qab/R65cn5PDZ7cYsu0IidY/w9agv+qo/Latjte779eyIhbX+eOH9JuQkBSfKKCPnAyu2xxd3mcudfQu5tPnLIalaOg+lsJ04s185NtE6zf4hRA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720718902; c=relaxed/simple; bh=tlFNtdPXIsjyicZF+y3g8YyRlX+dG+Y/x87VFaz+p5w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=T4cE6uWe5X8TgfrI9My929mOogXpI6EjLUL1CGHeU9UA4hm2rVvRawq7ISguWYLr2N+/mNVPozPetw7qy3U1Dvo6sJsr6e/MZZmygeq3AuyWD7EN/7zHg6nX0T0X7qqngSnCAspG298Pyz1/K5DVYv58NkfAA6NRag62g4bomYc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kW0d/7d5; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="kW0d/7d5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 16062C4AF07; Thu, 11 Jul 2024 17:28:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720718902; bh=tlFNtdPXIsjyicZF+y3g8YyRlX+dG+Y/x87VFaz+p5w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kW0d/7d5Alt7O+762Ma05vwt7bgo9oDQJ6QTTq8Qo8BKakNtMkX1fn1Nop+s9R9F5 UByrDK+FEb1qFagvYD/xuP1mJUsv2zdDyZu/3BmoEUEMNP4zuHWprJP/uZyiL34Kbj mdb2KwuchxnHdqnx9BSF4olEPu6dpmh36KgHfu/mGm6u9cVUdYKQAt2pxzsAcmIKc5 F/J50PJBJxFyJ4t2kju2csbyfO+pqaWOmBriKHILUt6XcqqHQwJYJTw/eBVg+mV1TM eye10XbHwTebPYxOxXT4INhYMRmAGB/hwaiQpff4aqms6LuapihEIA8jNdJCv/+Pk/ fRojRIZ/NKxXQ== From: Kees Cook To: Sathya Prakash Cc: Kees Cook , Sreekanth Reddy , Suganath Prabu Subramani , "Gustavo A. R. Silva" , MPT-FusionLinux.pdl@broadcom.com, linux-scsi@vger.kernel.org, linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/6] scsi: message: fusion: struct _CONFIG_PAGE_SAS_IO_UNIT_0: Replace 1-element array with flexible array Date: Thu, 11 Jul 2024 10:28:16 -0700 Message-Id: <20240711172821.123936-2-kees@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240711172432.work.523-kees@kernel.org> References: <20240711172432.work.523-kees@kernel.org> Precedence: bulk X-Mailing-List: linux-hardening@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2852; i=kees@kernel.org; h=from:subject; bh=tlFNtdPXIsjyicZF+y3g8YyRlX+dG+Y/x87VFaz+p5w=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBmkBYzm99u/pI8tnb58UexRVIlgpTl/2by8ge3B JVT1Tp83WaJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZpAWMwAKCRCJcvTf3G3A JndXEAClVG8hZ1gvChJQI1q05OsMAnd5K6vjz1iD0F1YVbxf1Io/lmnMbvyQkBaGIbUUyD5HX0C nswXfB9Tn4RouUs1NfnAZbgEC010eVqzKW3ploKcZ4ocLCLLR2T31lssRQH/pXT7uFEgx9k5HUP 8QzvJ5gbkmzLB0/QYNSrJC2yYaOXqdC3jsoc/O4vQaTX6OmF3AO4e1u4ge1c5AaS6bmD4m259b2 3M6nzZRF8lLRwJ28YZtLNG9vDEYmql1fI793PCklXIgVd6BRzx73/6QyDKAhSAbHPDxiM66LyqD S3iQOdU3PLKKrX9zSs+Bgsa2lRVlS8BzPWnzcL9s0lE2/BcfKn6Opx+I60wDUO1lou4drEOhHyh pSoKFYXZCfb+/4s39zakPEWR3UxCLafSHrQUB9kj4Wt5MvK0jhFgmZBPf9gOKpzI7kJuG8XCw9P EJjR7Iv4UYsKoXpLOLF9sOtkLVbPeqDzwGl+Sp3EcLYzijksTvw/lxK2qv10kNHUW2tGGnfiRNW EcV20TAb8rw5dUvwiqg3tIQFsT+LxOB2O6isQAhj2yWMlP6mdD8R+0vn6r26JQEX5+BptDHUJNi bR85cDX96CrdOONyK/FY02wJM5y56X3CW4YiIm5PGFRnYLilfKIedWmqsIBItAZR/NFRPMDLf09 K+WvqVTsAa4tEGg== X-Developer-Key: i=kees@kernel.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Replace the deprecated[1] use of a 1-element array in struct _CONFIG_PAGE_SAS_IO_UNIT_0 with a modern flexible array. Additionally add __counted_by annotation since PhyData is only ever accessed via a loops bounded by NumPhys: lsi/mpi_cnfg.h: MPI_SAS_IO_UNIT0_PHY_DATA PhyData[] __counted_by(NumPhys); /* 10h */ mptsas.c: port_info->num_phys = buffer->NumPhys; mptsas.c: for (i = 0; i < port_info->num_phys; i++) { mptsas.c: mptsas_print_phy_data(ioc, &buffer->PhyData[i]); mptsas.c: port_info->phy_info[i].phy_id = i; mptsas.c: port_info->phy_info[i].port_id = mptsas.c: buffer->PhyData[i].Port; mptsas.c: port_info->phy_info[i].negotiated_link_rate = mptsas.c: buffer->PhyData[i].NegotiatedLinkRate; No binary differences are present after this conversion. Link: https://github.com/KSPP/linux/issues/79 [1] Signed-off-by: Kees Cook Reviewed-by: Gustavo A. R. Silva --- Cc: Sathya Prakash Cc: Sreekanth Reddy Cc: Suganath Prabu Subramani Cc: "Gustavo A. R. Silva" Cc: MPT-FusionLinux.pdl@broadcom.com Cc: linux-scsi@vger.kernel.org Cc: linux-hardening@vger.kernel.org --- drivers/message/fusion/lsi/mpi_cnfg.h | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/drivers/message/fusion/lsi/mpi_cnfg.h b/drivers/message/fusion/lsi/mpi_cnfg.h index f59a741ef21c..c7997e32e82e 100644 --- a/drivers/message/fusion/lsi/mpi_cnfg.h +++ b/drivers/message/fusion/lsi/mpi_cnfg.h @@ -2547,14 +2547,6 @@ typedef struct _MPI_SAS_IO_UNIT0_PHY_DATA } MPI_SAS_IO_UNIT0_PHY_DATA, MPI_POINTER PTR_MPI_SAS_IO_UNIT0_PHY_DATA, SasIOUnit0PhyData, MPI_POINTER pSasIOUnit0PhyData; -/* - * Host code (drivers, BIOS, utilities, etc.) should leave this define set to - * one and check Header.PageLength at runtime. - */ -#ifndef MPI_SAS_IOUNIT0_PHY_MAX -#define MPI_SAS_IOUNIT0_PHY_MAX (1) -#endif - typedef struct _CONFIG_PAGE_SAS_IO_UNIT_0 { CONFIG_EXTENDED_PAGE_HEADER Header; /* 00h */ @@ -2563,7 +2555,7 @@ typedef struct _CONFIG_PAGE_SAS_IO_UNIT_0 U8 NumPhys; /* 0Ch */ U8 Reserved2; /* 0Dh */ U16 Reserved3; /* 0Eh */ - MPI_SAS_IO_UNIT0_PHY_DATA PhyData[MPI_SAS_IOUNIT0_PHY_MAX]; /* 10h */ + MPI_SAS_IO_UNIT0_PHY_DATA PhyData[] __counted_by(NumPhys); /* 10h */ } CONFIG_PAGE_SAS_IO_UNIT_0, MPI_POINTER PTR_CONFIG_PAGE_SAS_IO_UNIT_0, SasIOUnitPage0_t, MPI_POINTER pSasIOUnitPage0_t; From patchwork Thu Jul 11 17:28:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 13730941 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 6849416DC16; Thu, 11 Jul 2024 17:28:22 +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=1720718902; cv=none; b=u1x/C+CorNn9dWOOlCAr+M2MfG25d9OUWp5mFqGPZQGAS+ZFlmd9TP0ZcdPF8GphNQV8eGP8l+hm6aE4chGxyZam8pshnL93dNCjXH3BdKUBs27KLNAIilMGMmrla6kbiMWx7kmz3S1b7Qh+22Z85rcUJmuW4mxdYp+5ZLXI9RI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720718902; c=relaxed/simple; bh=KJRtzRSoC+YD4ifccvdvij8WY1nz8g+drmk27AlHQwc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=teL8j0zca30pKvDkaUPaeY+lpPU+MGzGuYtSHpXZNlHLL9XlqRQ3N6DjpEtU+hyvaQeCm+Zf+Pv0ai4pYgenYpsHAz46gi8MgPge2X8lqA5fmedBrKG6URkmdk+DVBQXAKq58sr2Z8KxJP374mOKMQY2JgGDE3MtLlnR088Lfxg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RY+OuZ2T; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RY+OuZ2T" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 226AAC4AF09; Thu, 11 Jul 2024 17:28:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720718902; bh=KJRtzRSoC+YD4ifccvdvij8WY1nz8g+drmk27AlHQwc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RY+OuZ2TKBefmdXQSIg/eGd1L+8tbd7PPhOzuDJkWRKe7BrSbAnbSM9zhwtFMdEIg LzbSh+rwuV49EMQ5fp/aN/EE/T57RMV/cPsJuGLCmU1CfWYfEYw72KjH5eP37wqgfN DWJATSiLDw470Gt7zhnLgARARNd/hAds2fN8aMwTUu6mKrlI/h1So9IHTGVavhLeOE Z0zMIRSo3ShcBOjoG1hEAIPL8nKKsGjVcvQYV7KptkymwjHCbbmPMsRdpMusQWTgPt /rDK3c5EmznMrCxskPAAecpZbbLDXSe8jan0kVBTXimQYfOMXs31vX6HKhHpOegumt I/4wO1YE4MovA== From: Kees Cook To: Sathya Prakash Cc: Kees Cook , Sreekanth Reddy , Suganath Prabu Subramani , "Gustavo A. R. Silva" , MPT-FusionLinux.pdl@broadcom.com, linux-scsi@vger.kernel.org, linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/6] scsi: message: fusion: struct _CONFIG_PAGE_RAID_PHYS_DISK_1: Replace 1-element array with flexible array Date: Thu, 11 Jul 2024 10:28:17 -0700 Message-Id: <20240711172821.123936-3-kees@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240711172432.work.523-kees@kernel.org> References: <20240711172432.work.523-kees@kernel.org> Precedence: bulk X-Mailing-List: linux-hardening@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2583; i=kees@kernel.org; h=from:subject; bh=KJRtzRSoC+YD4ifccvdvij8WY1nz8g+drmk27AlHQwc=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBmkBYzSnVQ68wF5ei0rKWx29joncaaILeM/2BQk 8+FkSUomRaJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZpAWMwAKCRCJcvTf3G3A Jom1D/9g/Ps1VLnG6OKWs8PoOZsmCXRCMBwLmXRoKXoa0Ov5J0/ObTivalAgKfehlP7WTtvsHLS rF/aX+elOIOAaeqHZTX232IdcXI3RsOfBArJ3DpbvyeQ+t59gTM/qksgfP0reTEhB3wbJIEmNWI TXvSlzWVgGyDJiXd2Ry60gESEXdmvJDxDfze7eqs8TpJO5U/d1NNoi0Y7osx96SinJgN2s/ZCO2 QuP3w/9skAG6kz1AIUW71aSWPkBiZ713sPHpXfF8hGPZvIv4w24NdQwfnjyuNYFK3FJ4/3iGRoD yhOEXSUFfRPMcI+bF4VWDYLArkv2jhsxvPh3/sB+OoKY426fTXCjhhAR4J1gzxhioj83OJIiI77 sldYu0ybXollOPNEwiRCsciuAZLTGNG3x84qdRAi6yf5V9JjQYQh8dxbaEJtpJSVaxq3d/gFBsM 3S4hkNIYg/wHBChLR56BJJ5jl2Fciaa9znLw1bNExRUBGOiHmnW+LBl/PBKFvg0EEQlsKjlKWF5 3Tkh4ADbUGf2B+5H0cvZoDCVWc2W1brUi5G9PRW0EOHLRkrh/ROCItOqKcNA7owOr69NebsRk5v pnqKf0uehDP/TY9QzhJWbdmwhpH9cu9mOHsD6ESTLnxuf+I95An3mxmjzVFBJ8yDPObbDxKAoYK FpCOLWn451la7Rg== X-Developer-Key: i=kees@kernel.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Replace the deprecated[1] use of a 1-element array in struct _CONFIG_PAGE_RAID_PHYS_DISK_1 with a modern flexible array. Additionally add __counted_by annotation since Path is only ever accessed via a loops bounded by NumPhysDiskPaths: lsi/mpi_cnfg.h: RAID_PHYS_DISK1_PATH Path[] __counted_by(NumPhysDiskPaths);/* 0Ch */ mptbase.c: phys_disk->NumPhysDiskPaths = buffer->NumPhysDiskPaths; mptbase.c: for (i = 0; i < phys_disk->NumPhysDiskPaths; i++) { mptbase.c: phys_disk->Path[i].PhysDiskID = buffer->Path[i].PhysDiskID; mptbase.c: phys_disk->Path[i].PhysDiskBus = buffer->Path[i].PhysDiskBus; No binary differences are present after this conversion. Link: https://github.com/KSPP/linux/issues/79 [1] Signed-off-by: Kees Cook Reviewed-by: Gustavo A. R. Silva --- Cc: Sathya Prakash Cc: Sreekanth Reddy Cc: Suganath Prabu Subramani Cc: "Gustavo A. R. Silva" Cc: MPT-FusionLinux.pdl@broadcom.com Cc: linux-scsi@vger.kernel.org Cc: linux-hardening@vger.kernel.org --- drivers/message/fusion/lsi/mpi_cnfg.h | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/drivers/message/fusion/lsi/mpi_cnfg.h b/drivers/message/fusion/lsi/mpi_cnfg.h index c7997e32e82e..e30132b57ae7 100644 --- a/drivers/message/fusion/lsi/mpi_cnfg.h +++ b/drivers/message/fusion/lsi/mpi_cnfg.h @@ -2447,14 +2447,6 @@ typedef struct _RAID_PHYS_DISK1_PATH #define MPI_RAID_PHYSDISK1_FLAG_INVALID (0x0001) -/* - * Host code (drivers, BIOS, utilities, etc.) should leave this define set to - * one and check Header.PageLength or NumPhysDiskPaths at runtime. - */ -#ifndef MPI_RAID_PHYS_DISK1_PATH_MAX -#define MPI_RAID_PHYS_DISK1_PATH_MAX (1) -#endif - typedef struct _CONFIG_PAGE_RAID_PHYS_DISK_1 { CONFIG_PAGE_HEADER Header; /* 00h */ @@ -2462,7 +2454,7 @@ typedef struct _CONFIG_PAGE_RAID_PHYS_DISK_1 U8 PhysDiskNum; /* 05h */ U16 Reserved2; /* 06h */ U32 Reserved1; /* 08h */ - RAID_PHYS_DISK1_PATH Path[MPI_RAID_PHYS_DISK1_PATH_MAX];/* 0Ch */ + RAID_PHYS_DISK1_PATH Path[] __counted_by(NumPhysDiskPaths);/* 0Ch */ } CONFIG_PAGE_RAID_PHYS_DISK_1, MPI_POINTER PTR_CONFIG_PAGE_RAID_PHYS_DISK_1, RaidPhysDiskPage1_t, MPI_POINTER pRaidPhysDiskPage1_t; From patchwork Thu Jul 11 17:28:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 13730943 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 8A22D16DC1C; Thu, 11 Jul 2024 17:28:22 +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=1720718902; cv=none; b=b9bUgs/SNWLcPMCWi4CZS3GrIwSSsqBWGfgEa/zTtO+f0QV8rnCpkuj0+8M/kOW+yuNi3MzCR+hnEJbT2meg3nYY6XrfRScJo3OMTUBIFe0ys2SrzVN/o/f4w+O9chzqx4UnE4F/Si0cV2GAs5e7bWV6+uuiRNrewyFQ7hKNUbw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720718902; c=relaxed/simple; bh=TFdd55gm7tedjfyA0tSLEzREVFMSxyPLwq5f8b56lIU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=C2Mz8hyPXMEqrFOQJpiN2w74qaI8dS2MIx7R5xRUm5sOvDndSpvoSTOWEzwv+KLaeTo+vxF9ocCtd9SMkL4DggMzrLuz4ar9dN3MnbhV0gXyUTpVKaaSYnETxGy8IeEsCHn3640JF9SaB36GTMWZ09cCAssa/cXPIX1wGQcAPZU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oNTz3k1R; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="oNTz3k1R" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2F79BC4AF0E; Thu, 11 Jul 2024 17:28:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720718902; bh=TFdd55gm7tedjfyA0tSLEzREVFMSxyPLwq5f8b56lIU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oNTz3k1RXtoJrTD9geq4YJ0PrHvAeG2XxRtC9sf46503DGwhjZmQaqDW9kJOcNTSq Qsj/hvU6mzG8ZtMeIUEV197iGw+y8AfJZ7/WH0mQjU6yYuB9ndL4hB3iFWbf6R8+BU Z8UQopMovKLTBt6MiPpYj1ZLqy4IItYhoKX3ViSlK8jquNLVkS9bvxazVQu3z9fDpt Gc2quSK38zGhYI56+s5PeLy2VJgh+ff6wmD26qan2pyaxULvlkkIRywLixZrFIliMC x6LsA4wn2lk8KEDvYdof5tlssYkhD7v4iurSHMb7Xm0TZkuvQCA5B4QPKWWStzV0tb Y18sudmcjoNZQ== From: Kees Cook To: Sathya Prakash Cc: Kees Cook , Sreekanth Reddy , Suganath Prabu Subramani , "Gustavo A. R. Silva" , MPT-FusionLinux.pdl@broadcom.com, linux-scsi@vger.kernel.org, linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/6] scsi: message: fusion: struct _CONFIG_PAGE_IOC_2: Replace 1-element array with flexible array Date: Thu, 11 Jul 2024 10:28:18 -0700 Message-Id: <20240711172821.123936-4-kees@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240711172432.work.523-kees@kernel.org> References: <20240711172432.work.523-kees@kernel.org> Precedence: bulk X-Mailing-List: linux-hardening@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3512; i=kees@kernel.org; h=from:subject; bh=TFdd55gm7tedjfyA0tSLEzREVFMSxyPLwq5f8b56lIU=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBmkBYznU8jZsF6x0BPmD/cpzsBuAcKzr5zPGH8d 6njqRjZCS+JAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZpAWMwAKCRCJcvTf3G3A Jh3gEACcdiLzOrjIsH9nE0Jmj2soc1aVdJlCGWpvkTRhtXFB4qYoXSUz0FamS8xcMmgSZpPhJHX g7xPhTslDwQJCbQwu25emCMpaHKERUR7WSXYtLagPOH3ux2+3B8qfaE+nXq5JvysvIgYS2a3dx9 BCdSkg5/CiLpRAXWBr99yKCvkaaAI4lJ8vEuKHxtAOVkr+lUkfH8nLyqXv5vagDTyGkfYWUPMcJ WkqCBQmStYBBJ8NvrQJjKZ+civiqKv2PR2UQwUoRX3cKo5KGubB9cyPcaWQmSvR7wWqApi19izC mUl+AWCiZkFouXX95ai+6UInmWHjtJ/rl86CL+eeKwQlN+UnjsAMeex26IlUKE41IdEptGxU956 jE2MSPA4641M9o9ozAxRfYjmWuHksUVuNl9jUeRZHRWCWvwRLWC34mzoJtxDm1RdDvMVDUExmQ0 BGbul+ZtVDXMt60e/7mTMB1CYzjJbb4g0m89MFrznJJWAGVItnuD32aVoFd2oM5i3IhrpS63oqx b04bNWR1k4uyVEYKbLMNsscCi58iNlUeGK46VC9F0qXPHlsGWoFx6ACDJCnaDBMDSRNy30MxG+u X8/0gxgZrVNQK1qUFLocaZk8aSrD/Uidh2+cpVGg7OjN1xBQRTbFR4w+VhbbvkjR9oTRpb1e4kt Cuvm5c0PHMDbINQ== X-Developer-Key: i=kees@kernel.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Replace the deprecated[1] use of a 1-element array in struct _CONFIG_PAGE_IOC_2 with a modern flexible array. Additionally add __counted_by annotation since RaidVolume is only ever accessed from loops controlled by NumActiveVolumes: lsi/mpi_cnfg.h: CONFIG_PAGE_IOC_2_RAID_VOL RaidVolume[] __counted_by(NumActiveVolumes); /* 0Ch */ mptbase.c: for (i = 0; i < pIoc2->NumActiveVolumes ; i++) mptbase.c: pIoc2->RaidVolume[i].VolumeBus, mptbase.c: pIoc2->RaidVolume[i].VolumeID); mptsas.c: for (i = 0; i < ioc->raid_data.pIocPg2->NumActiveVolumes; i++) { mptsas.c: RaidVolume[i].VolumeID) { mptsas.c: RaidVolume[i].VolumeBus; mptsas.c: for (i = 0; i < ioc->raid_data.pIocPg2->NumActiveVolumes; i++) { mptsas.c: ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID, 0); mptsas.c: ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID); mptsas.c: ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID, 0); mptsas.c: for (i = 0; i < ioc->raid_data.pIocPg2->NumActiveVolumes; i++) { mptsas.c: if (ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID == mptsas.c: for (i = 0; i < ioc->raid_data.pIocPg2->NumActiveVolumes; i++) mptsas.c: if (ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID == id) mptspi.c: for (i=0; i < ioc->raid_data.pIocPg2->NumActiveVolumes; i++) { mptspi.c: if (ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID == id) { No binary differences are present after this conversion. Link: https://github.com/KSPP/linux/issues/79 [1] Signed-off-by: Kees Cook Reviewed-by: Gustavo A. R. Silva --- Cc: Sathya Prakash Cc: Sreekanth Reddy Cc: Suganath Prabu Subramani Cc: "Gustavo A. R. Silva" Cc: MPT-FusionLinux.pdl@broadcom.com Cc: linux-scsi@vger.kernel.org Cc: linux-hardening@vger.kernel.org --- drivers/message/fusion/lsi/mpi_cnfg.h | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/drivers/message/fusion/lsi/mpi_cnfg.h b/drivers/message/fusion/lsi/mpi_cnfg.h index e30132b57ae7..7713c74e515b 100644 --- a/drivers/message/fusion/lsi/mpi_cnfg.h +++ b/drivers/message/fusion/lsi/mpi_cnfg.h @@ -1018,14 +1018,6 @@ typedef struct _CONFIG_PAGE_IOC_2_RAID_VOL #define MPI_IOCPAGE2_FLAG_VOLUME_INACTIVE (0x08) -/* - * Host code (drivers, BIOS, utilities, etc.) should leave this define set to - * one and check Header.PageLength at runtime. - */ -#ifndef MPI_IOC_PAGE_2_RAID_VOLUME_MAX -#define MPI_IOC_PAGE_2_RAID_VOLUME_MAX (1) -#endif - typedef struct _CONFIG_PAGE_IOC_2 { CONFIG_PAGE_HEADER Header; /* 00h */ @@ -1034,7 +1026,7 @@ typedef struct _CONFIG_PAGE_IOC_2 U8 MaxVolumes; /* 09h */ U8 NumActivePhysDisks; /* 0Ah */ U8 MaxPhysDisks; /* 0Bh */ - CONFIG_PAGE_IOC_2_RAID_VOL RaidVolume[MPI_IOC_PAGE_2_RAID_VOLUME_MAX];/* 0Ch */ + CONFIG_PAGE_IOC_2_RAID_VOL RaidVolume[] __counted_by(NumActiveVolumes); /* 0Ch */ } CONFIG_PAGE_IOC_2, MPI_POINTER PTR_CONFIG_PAGE_IOC_2, IOCPage2_t, MPI_POINTER pIOCPage2_t; From patchwork Thu Jul 11 17:28:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 13730945 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 BC04D16DEC2; Thu, 11 Jul 2024 17:28:22 +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=1720718902; cv=none; b=DMzR/zEoe+liTgOh9tQQ2Zso5GWfqoLtQk4kTHImg8Lds9cZtcqXLLS3szBCzMX4j/aXDJSF2GEt2UoTVfRyQESmSoIGSdP9KdF4k00SE44GcLczp/IZ4i8uo/c/6V69vSzbn+BZ7UdHfKMNsfVLOijtkOk8XK/Yg60DX/dl0jE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720718902; c=relaxed/simple; bh=MnZHveL4bhw7QKqCedPp+xc07Hey0fundjFehsgmf5w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GpFvMvqF7Eb85K1XCwI6FO4p7sG8H3pEGIe5DU19l24tc63ghpXleOHdJtnmRmS2927F4LQp1lv0XXfI2G5pYI31Yve0xQypBGLx6S10rXv+Y4KI2xTWwSiCH2Ya/e50rBwKXP2cXKyhA960Pb/pUZ1Z2fDzD/a3l5BDuu23cwM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LY9g7/TR; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="LY9g7/TR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 74D08C4AF18; Thu, 11 Jul 2024 17:28:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720718902; bh=MnZHveL4bhw7QKqCedPp+xc07Hey0fundjFehsgmf5w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LY9g7/TRYb/UetyNO/Ca4jI5BkPaGisNF3rTpxrp/rYmc43/OSVVGBUGtV4RUVKea DvEnEYhRFasDp+9l0/6exkd6gIqsDT7O7+zSeRN8M+HUI8AThYGX4Ol9crN/HCe7lB y/uarBwBr5PJYavJZLJblTJ+qMt/lxUFDF/EeDm5A+8hN+iFOd6kIW8/Zj3xtGcHgE k5p8LLf4PPsv2I411WZXuvS2qs1D71AbyOVud2zmheZBeO0zRtDaclOedw7eigXbjE 9icMa9snQibwOVkPlhcoGXDpvFo4rC9GBrOjr5095UbaKEbek4JQmxk/eERLVPL0vO BGNd8cc3zNVsg== From: Kees Cook To: Sathya Prakash Cc: Kees Cook , Sreekanth Reddy , Suganath Prabu Subramani , "Gustavo A. R. Silva" , MPT-FusionLinux.pdl@broadcom.com, linux-scsi@vger.kernel.org, linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/6] scsi: message: fusion: struct _CONFIG_PAGE_IOC_3: Replace 1-element array with flexible array Date: Thu, 11 Jul 2024 10:28:19 -0700 Message-Id: <20240711172821.123936-5-kees@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240711172432.work.523-kees@kernel.org> References: <20240711172432.work.523-kees@kernel.org> Precedence: bulk X-Mailing-List: linux-hardening@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3164; i=kees@kernel.org; h=from:subject; bh=MnZHveL4bhw7QKqCedPp+xc07Hey0fundjFehsgmf5w=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBmkBY0+IfDHmTrR7F+4Nw6sg6RTWu4dYQ8PC94w LD5eUgElKaJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZpAWNAAKCRCJcvTf3G3A JgzlD/9CQ9zmCPlZEsJz+MYcZ3brkTlXQxnE/MRIbQRddbmNlIGZqoltkazt7zYCuJtzE2mUfo9 EgjWZxbXflOmH/r0TZUFYfrhDiYIqrA1n2MOGpdjdFfFTtz3bR/9dL2qkPISojtexAEEkXQnjMF /QlwARa6sNlpqVovfsjPFEJHOGpaHI2JBzf3NpTogg85e8hDSvuQx5dSkVUXmR/1YhljWmMSp3w RmYS3o3/mkDBDLQafWFKs7l/9WxZNIwfjq8KeD6diisq9viZEpUN+BFbn0kqS7+xd6zkWa9xlPX XBUTxMoYQm00LRnRo/US3XsItNIZJELxGuBTD/iBM8uSPoV8gYsAUy9BjTEjwB7ezrBJHy/mFzw CHOjg8UrVPIU/GLcZMhrxjPHl82o4hyixCOvQzvguiRvmcmS5raWAqYQUVF3LLwKVIJqg4f23uI ZiQe/jTPpElylJUBckRZidI4aOW6CNiPbnPd+v0ZlcHLBrnwS1bFwZAVu4K9Y3WddgqcCaCR81J c+h4y7gxX98zlGB0yYec/o/w3ZF0m/nRzRl3zYIfgNtU4uTbX4FZY2cdldLydj8UmX0YwPMAcpo gl/csUMfpUi8LkbwUH4dtYpY8tDrY/Xm9BAjz1zBL51NRT2iP5uFvLMBJ7oCQdfMzvbiEXM9MME idSgdPVwgpNgjbQ== X-Developer-Key: i=kees@kernel.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Replace the deprecated[1] use of a 1-element array in struct _CONFIG_PAGE_IOC_3 with a modern flexible array. Additionally add __counted_by annotation since PhysDisk is only ever accessed via a loops bounded by NumPhysDisks: lsi/mpi_cnfg.h: IOC_3_PHYS_DISK PhysDisk[] __counted_by(NumPhysDisks); /* 08h */ mptscsih.c: for (i = 0; i < ioc->raid_data.pIocPg3->NumPhysDisks; i++) { mptscsih.c: if ((id == ioc->raid_data.pIocPg3->PhysDisk[i].PhysDiskID) && mptscsih.c: (channel == ioc->raid_data.pIocPg3->PhysDisk[i].PhysDiskBus)) { mptscsih.c: for (i = 0; i < ioc->raid_data.pIocPg3->NumPhysDisks; i++) { mptscsih.c: ioc->raid_data.pIocPg3->PhysDisk[i].PhysDiskNum); mptscsih.c: ioc->raid_data.pIocPg3->PhysDisk[i].PhysDiskNum, mptscsih.c: for (i = 0; i < ioc->raid_data.pIocPg3->NumPhysDisks; i++) { mptscsih.c: if ((id == ioc->raid_data.pIocPg3->PhysDisk[i].PhysDiskID) && mptscsih.c: (channel == ioc->raid_data.pIocPg3->PhysDisk[i].PhysDiskBus)) { mptscsih.c: rc = ioc->raid_data.pIocPg3->PhysDisk[i].PhysDiskNum; mptscsih.c: for (i = 0; i < ioc->raid_data.pIocPg3->NumPhysDisks; i++) { mptscsih.c: ioc->raid_data.pIocPg3->PhysDisk[i].PhysDiskNum); mptscsih.c: ioc->raid_data.pIocPg3->PhysDisk[i].PhysDiskNum, No binary differences are present after this conversion. Link: https://github.com/KSPP/linux/issues/79 [1] Signed-off-by: Kees Cook Reviewed-by: Gustavo A. R. Silva --- Cc: Sathya Prakash Cc: Sreekanth Reddy Cc: Suganath Prabu Subramani Cc: "Gustavo A. R. Silva" Cc: MPT-FusionLinux.pdl@broadcom.com Cc: linux-scsi@vger.kernel.org Cc: linux-hardening@vger.kernel.org --- drivers/message/fusion/lsi/mpi_cnfg.h | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/drivers/message/fusion/lsi/mpi_cnfg.h b/drivers/message/fusion/lsi/mpi_cnfg.h index 7713c74e515b..bac49c162165 100644 --- a/drivers/message/fusion/lsi/mpi_cnfg.h +++ b/drivers/message/fusion/lsi/mpi_cnfg.h @@ -1056,21 +1056,13 @@ typedef struct _IOC_3_PHYS_DISK } IOC_3_PHYS_DISK, MPI_POINTER PTR_IOC_3_PHYS_DISK, Ioc3PhysDisk_t, MPI_POINTER pIoc3PhysDisk_t; -/* - * Host code (drivers, BIOS, utilities, etc.) should leave this define set to - * one and check Header.PageLength at runtime. - */ -#ifndef MPI_IOC_PAGE_3_PHYSDISK_MAX -#define MPI_IOC_PAGE_3_PHYSDISK_MAX (1) -#endif - typedef struct _CONFIG_PAGE_IOC_3 { CONFIG_PAGE_HEADER Header; /* 00h */ U8 NumPhysDisks; /* 04h */ U8 Reserved1; /* 05h */ U16 Reserved2; /* 06h */ - IOC_3_PHYS_DISK PhysDisk[MPI_IOC_PAGE_3_PHYSDISK_MAX]; /* 08h */ + IOC_3_PHYS_DISK PhysDisk[] __counted_by(NumPhysDisks); /* 08h */ } CONFIG_PAGE_IOC_3, MPI_POINTER PTR_CONFIG_PAGE_IOC_3, IOCPage3_t, MPI_POINTER pIOCPage3_t; From patchwork Thu Jul 11 17:28:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 13730944 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 B12AB16DEA6; Thu, 11 Jul 2024 17:28:22 +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=1720718902; cv=none; b=QcItFva2clQQqZ1qYBW+E/o02bNKTNYHrBC8xJIUCt1XdsAfJ3aijYNHJGKMrdXcNfBy6q9TigKKaG72oeDsPKi8ZHmnKBC2wH5Ez/FN0mw3fB1Fc4o05Uo9xJH1uoVA1jCD5B2WBOmGWVVP4KKf3/QEo4eGUvpYQSR78b66u7c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720718902; c=relaxed/simple; bh=uTVAghxsaNEV213sw1BkmG0oj7wQ6hN2vTa2+UY7Ohg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=IyIX3RjbjcSLLgPXm116xLNi5M2kgBc65JKAKnBGmErJ1V5DQRGhQDq6MzIR88UOxX25Z8eY5KxQ7Z2W/1fKav05EtSIHpTLOPZ2KxyPwAzRMU3PvezF0UvEcmE8MCT3+To4vkjJeqlgZuHK1Ervu8vX9UAMitLVMNP5kUPZjDo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=iYhFHcqd; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="iYhFHcqd" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 74156C4AF11; Thu, 11 Jul 2024 17:28:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720718902; bh=uTVAghxsaNEV213sw1BkmG0oj7wQ6hN2vTa2+UY7Ohg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iYhFHcqdccBoKu8q64Hd84+hJUzs2L87MSgWqsSRxM7zbJ5huUChzXkf9XWR3Yir1 naI+INKAiCvrMNmm8pQT92fXuOCvbyVg/ODon5njZjTBnCxu6IZL25sXuwnZmuNLak +eRFDeGfQ3JHP5jerIPG5MV07DG9aF0IDgCv7b0PQHJccFmfYf9mdbVt42NLIAqR+B aehz3fC2PYxXTu8MCaQeYTp5uqOmlbo0U7T8Gp4ULzZaccAbDGtBwa4IEBSU+iZYO5 N2iDduVTFg8FJe/10Z/dZWVsp7UkQzUo6sbmpY28zLRgQjdR7VADYF+lUWtlwyVBze xsxseDJ94hkgw== From: Kees Cook To: Sathya Prakash Cc: Kees Cook , Sreekanth Reddy , Suganath Prabu Subramani , "Gustavo A. R. Silva" , MPT-FusionLinux.pdl@broadcom.com, linux-scsi@vger.kernel.org, linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 6/6] scsi: message: fusion: struct _CONFIG_PAGE_IOC_4: Replace 1-element array with flexible array Date: Thu, 11 Jul 2024 10:28:20 -0700 Message-Id: <20240711172821.123936-6-kees@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240711172432.work.523-kees@kernel.org> References: <20240711172432.work.523-kees@kernel.org> Precedence: bulk X-Mailing-List: linux-hardening@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2278; i=kees@kernel.org; h=from:subject; bh=uTVAghxsaNEV213sw1BkmG0oj7wQ6hN2vTa2+UY7Ohg=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBmkBY0xRaGMDDwrHBvkFQhoh6p0v0bM0OTDoFto 6yTjD2pKmyJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZpAWNAAKCRCJcvTf3G3A JiGUEACBxXVIes36bWRWlOikkcY2Xnpx0VBDqLTtI4KGlXy4oJyTD0nUBaG2yeSRvJ18jZcwR9B gMiVUXhzleFQcTuKywR6dXpGHIWwmzMwe2P3u4p7ISVg3xBVfxgS2l74QKx9tC47BSAODnI1Agl ffX2QIZ/Pvkzk/HU4mvaxIS4hw285aGxxI7nLLw+/arJJi/9xSR16OXecltT1xit/MBt3OXwHT/ l4Hd3HzSVRqUbtBotU7x1tzeSyhLrRY5l18np33Ha6BZPWCGVgBxcmeA6qBARs4ySEg14T/DOSj 4jox4WztvKG+oikdjNaj0HB/cJnxtuIP9kKmqrLKMIBTvIbxnUjXKd6vV/9C6NtORvqxlT10Gdd Ycqpv0Fd4xoRy/zabFSsdXyO2+AW48JpQ0RYVEK3NvtIaWv+8Zi000Zh1B7dGzLOzxbwkE71FFU znWY89bdvHQctXL0y6Sb2zahbHS1QY6xydkwmeyIVFywgYq2pu/nRuklQm7zfgY2v8O6vL9bVc2 Rirn8DOW1cKfO6gyg3yCMJpKmjRmScO74Y0oIuN0ngeqbC7Ee5vjKhwGHgiUpVKddmmReX5yd4z eNs+YNnDQ4mtlkOLNVXnEtl1/gEQYU4IlGDXlesRbors5iTmrdndBlZ62jowy4d7Ao4oJlKBBJV 0FfZx//tzAKxYsQ== X-Developer-Key: i=kees@kernel.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Replace the deprecated[1] use of a 1-element array in struct _CONFIG_PAGE_IOC_4 with a modern flexible array. Additionally add __counted_by annotation since SEP is only ever accessed after updating ACtiveSEP: lsi/mpi_cnfg.h: IOC_4_SEP SEP[] __counted_by(ActiveSEP); /* 08h */ mptsas.c: ii = IOCPage4Ptr->ActiveSEP++; mptsas.c: IOCPage4Ptr->SEP[ii].SEPTargetID = id; mptsas.c: IOCPage4Ptr->SEP[ii].SEPBus = channel; No binary differences are present after this conversion. Link: https://github.com/KSPP/linux/issues/79 [1] Signed-off-by: Kees Cook Reviewed-by: Gustavo A. R. Silva --- Cc: Sathya Prakash Cc: Sreekanth Reddy Cc: Suganath Prabu Subramani Cc: "Gustavo A. R. Silva" Cc: MPT-FusionLinux.pdl@broadcom.com Cc: linux-scsi@vger.kernel.org Cc: linux-hardening@vger.kernel.org --- drivers/message/fusion/lsi/mpi_cnfg.h | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/drivers/message/fusion/lsi/mpi_cnfg.h b/drivers/message/fusion/lsi/mpi_cnfg.h index bac49c162165..1167a16d8fb4 100644 --- a/drivers/message/fusion/lsi/mpi_cnfg.h +++ b/drivers/message/fusion/lsi/mpi_cnfg.h @@ -1077,21 +1077,13 @@ typedef struct _IOC_4_SEP } IOC_4_SEP, MPI_POINTER PTR_IOC_4_SEP, Ioc4Sep_t, MPI_POINTER pIoc4Sep_t; -/* - * Host code (drivers, BIOS, utilities, etc.) should leave this define set to - * one and check Header.PageLength at runtime. - */ -#ifndef MPI_IOC_PAGE_4_SEP_MAX -#define MPI_IOC_PAGE_4_SEP_MAX (1) -#endif - typedef struct _CONFIG_PAGE_IOC_4 { CONFIG_PAGE_HEADER Header; /* 00h */ U8 ActiveSEP; /* 04h */ U8 MaxSEP; /* 05h */ U16 Reserved1; /* 06h */ - IOC_4_SEP SEP[MPI_IOC_PAGE_4_SEP_MAX]; /* 08h */ + IOC_4_SEP SEP[] __counted_by(ActiveSEP); /* 08h */ } CONFIG_PAGE_IOC_4, MPI_POINTER PTR_CONFIG_PAGE_IOC_4, IOCPage4_t, MPI_POINTER pIOCPage4_t;