diff mbox series

[-next] mmc: sdhci-cadence: Annotate struct sdhci_cdns_phy_param with __counted_by()

Message ID 20240904014636.2033138-1-lihongbo22@huawei.com
State New
Headers show
Series [-next] mmc: sdhci-cadence: Annotate struct sdhci_cdns_phy_param with __counted_by() | expand

Commit Message

Hongbo Li Sept. 4, 2024, 1:46 a.m. UTC
Add the __counted_by compiler attribute to the flexible array member
entries to improve access bounds-checking via CONFIG_UBSAN_BOUNDS and
CONFIG_FORTIFY_SOURCE.

Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
---
 drivers/mmc/host/sdhci-cadence.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Gustavo A. R. Silva Sept. 5, 2024, 12:16 a.m. UTC | #1
[..]

> -	struct sdhci_cdns_phy_param phy_params[];
> +	struct sdhci_cdns_phy_param phy_params[] __counted_by(count);

It seems there is no such `count` member in the structure[1].

Since `counted_by` hasn't been released in GCC yet. Please, make
sure to build-test any `counted_by` patches with Clang 18+.

Thanks
--
Gustavo

[1] https://lore.kernel.org/linux-hardening/202409042358.dwEQMShp-lkp@intel.com/
Hongbo Li Sept. 5, 2024, 1:10 a.m. UTC | #2
On 2024/9/5 8:16, Gustavo A. R. Silva wrote:
> [..]
> 
>> -    struct sdhci_cdns_phy_param phy_params[];
>> +    struct sdhci_cdns_phy_param phy_params[] __counted_by(count);
> 
> It seems there is no such `count` member in the structure[1].
> 
> Since `counted_by` hasn't been released in GCC yet. Please, make
> sure to build-test any `counted_by` patches with Clang 18+.

Sorry, it is nr_phy_params, I made a mistake with this patch.

Thanks
Hongbo
> 
> Thanks
> -- 
> Gustavo
> 
> [1] 
> https://lore.kernel.org/linux-hardening/202409042358.dwEQMShp-lkp@intel.com/
diff mbox series

Patch

diff --git a/drivers/mmc/host/sdhci-cadence.c b/drivers/mmc/host/sdhci-cadence.c
index be1505e8c536..2690bcaeaad5 100644
--- a/drivers/mmc/host/sdhci-cadence.c
+++ b/drivers/mmc/host/sdhci-cadence.c
@@ -73,7 +73,7 @@  struct sdhci_cdns_priv {
 	void (*priv_writel)(struct sdhci_cdns_priv *priv, u32 val, void __iomem *reg);
 	struct reset_control *rst_hw;
 	unsigned int nr_phy_params;
-	struct sdhci_cdns_phy_param phy_params[];
+	struct sdhci_cdns_phy_param phy_params[] __counted_by(count);
 };
 
 struct sdhci_cdns_phy_cfg {