pds_core: limit loop over fw name list
Subsystems (3)
PATCH 1/1 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.
--- drivers/net/ethernet/amd/pds_core/devlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/amd/pds_core/devlink.c +1 -1
@@ -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));for (i =0 ; i < listlen; i++) {if (i <ARRAY_SIZE (fw_slotnames))strscpy (buf, fw_slotnames[i],sizeof (buf));
Signature · 1 line
2.17.1
Quoted 7 lines · Shannon Nelson
Add an array size limit to the for-loop to be sure we don't try to reference a
fw_versionstring 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 <[email protected]>
Quoted 16 lines · Shannon Nelson
Add an array size limit to the for-loop to be sure we don't try to reference a
fw_versionstring 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 <[email protected]>--- drivers/net/ethernet/amd/pds_core/devlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/amd/pds_core/devlink.c +0
-0
drivers/net/ethernet/amd/pds_core/devlink.c int pdsc_dl_info_get(struct devlink *dl, struct devlink_info_req *req, · line 121
Quoted 5 lines
drivers/net/ethernet/amd/pds_core/devlink.c +1
-1@@ -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));
LGTM. Thanks!
Quoted 3 lines
drivers/net/ethernet/amd/pds_core/devlink.c +0
-0for (i =0 ; i < listlen; i++) {if (i <ARRAY_SIZE (fw_slotnames))strscpy (buf, fw_slotnames[i],sizeof (buf));
Quoted 28 lines
-----Original Message-----
From: Shannon Nelson <[email protected]>
Sent: Friday, January 3, 2025 11:52 AM
To: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Keller, Jacob E <[email protected]>
Cc: [email protected]; Shannon Nelson <[email protected]>
Subject: [PATCH net]pds_core: limit loop over fw name listAdd an array size limit to the for-loop to be sure we don't try to reference a
fw_versionstring 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 <[email protected]>--- drivers/net/ethernet/amd/pds_core/devlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/amd/pds_core/devlink.c +0
-0
drivers/net/ethernet/amd/pds_core/devlink.c int pdsc_dl_info_get(struct devlink *dl, struct · line 122
Quoted 6 lines
drivers/net/ethernet/amd/pds_core/devlink.c +1
-1@@ -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.
Thanks,
Jake
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Fri, 3 Jan 2025 11:51:47 -0800 you wrote:
Add an array size limit to the for-loop to be sure we don't try to reference a
fw_versionstring 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 <[email protected]>[...]
Here is the summary with links:
- [net] pds_core: limit loop over fw name list
https://git.kernel.org/netdev/net/c/8c817eb26230
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html