[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CO1PR11MB5089948E170987010BDA05DCD6102@CO1PR11MB5089.namprd11.prod.outlook.com>
Date: Mon, 6 Jan 2025 21:32:51 +0000
From: "Keller, Jacob E" <jacob.e.keller@...el.com>
To: Shannon Nelson <shannon.nelson@....com>, "netdev@...r.kernel.org"
<netdev@...r.kernel.org>, "davem@...emloft.net" <davem@...emloft.net>,
"kuba@...nel.org" <kuba@...nel.org>, "edumazet@...gle.com"
<edumazet@...gle.com>, "pabeni@...hat.com" <pabeni@...hat.com>,
"andrew+netdev@...n.ch" <andrew+netdev@...n.ch>
CC: "brett.creeley@....com" <brett.creeley@....com>
Subject: RE: [PATCH net] pds_core: limit loop over fw name list
> -----Original Message-----
> From: Shannon Nelson <shannon.nelson@....com>
> Sent: Friday, January 3, 2025 11:52 AM
> To: netdev@...r.kernel.org; davem@...emloft.net; kuba@...nel.org;
> edumazet@...gle.com; pabeni@...hat.com; andrew+netdev@...n.ch; Keller,
> Jacob E <jacob.e.keller@...el.com>
> Cc: brett.creeley@....com; Shannon Nelson <shannon.nelson@....com>
> Subject: [PATCH net] pds_core: limit loop over fw name list
>
> Add an array size limit to the for-loop to be sure we don't try
> to reference a fw_version string off the end of the fw info names
> array. We know that our firmware only has a limited number
> of firmware slot names, but we shouldn't leave this unchecked.
>
> Fixes: 45d76f492938 ("pds_core: set up device and adminq")
> Signed-off-by: Shannon Nelson <shannon.nelson@....com>
> ---
> drivers/net/ethernet/amd/pds_core/devlink.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/amd/pds_core/devlink.c
> b/drivers/net/ethernet/amd/pds_core/devlink.c
> index 2681889162a2..44971e71991f 100644
> --- a/drivers/net/ethernet/amd/pds_core/devlink.c
> +++ b/drivers/net/ethernet/amd/pds_core/devlink.c
> @@ -118,7 +118,7 @@ int pdsc_dl_info_get(struct devlink *dl, struct
> devlink_info_req *req,
> if (err && err != -EIO)
> return err;
>
> - listlen = fw_list.num_fw_slots;
> + listlen = min(fw_list.num_fw_slots, ARRAY_SIZE(fw_list.fw_names));
I assume num_fw_slots comes from the firmware? Makes sense to ensure we limit in case somehow the value no longer matches in the future.
Reviewed-by: Jacob Keller <jacob.e.keller@...el.com>
Thanks,
Jake
Powered by blists - more mailing lists