lpfc: size cpu map by last cpu id set
Subsystems (2)
PATCH 1/1 lpfc: size cpu map by last cpu id set
Currently the lpfc driver sizes its cpu_map array based on num_possible_cpus(). However, that can be a value that is less than the highest cpu id bit that is set. As such, if a thread runs on a cpu with a larger cpu id, or for_each_possible_cpu() is used, the driver could index off the end of the array and return garbage or GPF.
The driver maintains it's own internal copy of the "num_possible" cpu value and sizes arrays by it.
Fix by setting the driver's value to the value of the last cpu id bit set in the possible_mask - plus 1. Thus cpu_map will be sized to allow access by any cpu id possible.
--- drivers/scsi/lpfc/lpfc_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/lpfc/lpfc_init.c +1 -1
@@ -6460,7 +6460,7 @@ lpfc_sli4_driver_resource_setup(struct lpfc_hba *phba)u32 if_fam; phba->sli4_hba.num_present_cpu = lpfc_present_cpu; - phba->sli4_hba.num_possible_cpu =num_possible_cpus (); + phba->sli4_hba.num_possible_cpu =cpumask_last (cpu_possible_mask) +1 ; phba->sli4_hba.curr_disp_cpu =0 ;lpfc_cpumask_of_node_init (phba);
Signature · 1 line
2.13.7
Quoted 25 lines · James Smart
Currently the lpfc driver sizes its
cpu_maparray based onnum_possible_cpus(). However, that can be a value that is less than the highest cpu id bit that is set. As such, if a thread runs on a cpu with a larger cpu id, orfor_each_possible_cpu()is used, the driver could index off the end of the array and return garbage or GPF.The driver maintains it's own internal copy of the "
num_possible" cpu value and sizes arrays by it.Fix by setting the driver's value to the value of the last cpu id bit set in the
possible_mask- plus 1. Thuscpu_mapwill be sized to allow access by any cpu id possible.Signed-off-by Dick Kennedy <[email protected]>Signed-off-by James Smart <[email protected]>--- drivers/scsi/lpfc/lpfc_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/scsi/lpfc/lpfc_init.c +0
-0
drivers/scsi/lpfc/lpfc_init.c lpfc_sli4_driver_resource_setup(struct lpfc_hba *phba) · line 6466
Quoted 8 lines
drivers/scsi/lpfc/lpfc_init.c +1
-1@@ -6460,7 +6460,7 @@ lpfc_sli4_driver_resource_setup(struct lpfc_hba *phba)u32 if_fam; phba->sli4_hba.num_present_cpu = lpfc_present_cpu; - phba->sli4_hba.num_possible_cpu =num_possible_cpus (); + phba->sli4_hba.num_possible_cpu =cpumask_last (cpu_possible_mask) +1 ; phba->sli4_hba.curr_disp_cpu =0 ;lpfc_cpumask_of_node_init (phba);
Martin K. Petersen
AppliedJames,
Quoted 5 lines
Currently the lpfc driver sizes its
cpu_maparray based onnum_possible_cpus(). However, that can be a value that is less than the highest cpu id bit that is set. As such, if a thread runs on a cpu with a larger cpu id, orfor_each_possible_cpu()is used, the driver could index off the end of the array and return garbage or GPF.
Applied to 5.5/scsi-queue, thanks.
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering