diff mbox series

[1/9] lpfc: Fix use-after-free rport memory access in lpfc_register_remote_port

Message ID 20230523183206.7728-2-justintee8345@gmail.com
State New
Headers show
Series lpfc: Update lpfc to revision 14.2.0.13 | expand

Commit Message

Justin Tee May 23, 2023, 6:31 p.m. UTC
Due to a target port D_ID swap, it is possible for the
lpfc_register_remote_port routine to touch post mortem fc_rport memory when
trying to access fc_rport->dd_data.

The D_ID swap causes a simultaneous call to lpfc_unregister_remote_port,
where fc_remote_port_delete reclaims fc_rport memory.

Remove the fc_rport->dd_data->pnode NULL assignment because the following
line reassigns ndlp->rport with an fc_rport object from fc_remote_port_add
anyways.  The pnode nullification is superfluous.

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
---
 drivers/scsi/lpfc/lpfc_hbadisc.c | 8 --------
 1 file changed, 8 deletions(-)

Comments

Martin Wilck May 31, 2023, 4:46 p.m. UTC | #1
On Tue, 2023-05-23 at 11:31 -0700, Justin Tee wrote:
> Due to a target port D_ID swap, it is possible for the
> lpfc_register_remote_port routine to touch post mortem fc_rport
> memory when
> trying to access fc_rport->dd_data.
> 
> The D_ID swap causes a simultaneous call to
> lpfc_unregister_remote_port,
> where fc_remote_port_delete reclaims fc_rport memory.
> 
> Remove the fc_rport->dd_data->pnode NULL assignment because the
> following
> line reassigns ndlp->rport with an fc_rport object from
> fc_remote_port_add
> anyways.  The pnode nullification is superfluous.
> 
> Signed-off-by: Justin Tee <justin.tee@broadcom.com>

This patch fixed a customer issue for us.

Acked-by: Martin Wilck <mwilck@suse.com>


> ---
>  drivers/scsi/lpfc/lpfc_hbadisc.c | 8 --------
>  1 file changed, 8 deletions(-)
> 
> diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c
> b/drivers/scsi/lpfc/lpfc_hbadisc.c
> index 67bfdddb897c..63e42e3f2165 100644
> --- a/drivers/scsi/lpfc/lpfc_hbadisc.c
> +++ b/drivers/scsi/lpfc/lpfc_hbadisc.c
> @@ -4498,14 +4498,6 @@ lpfc_register_remote_port(struct lpfc_vport
> *vport, struct lpfc_nodelist *ndlp)
>         if (vport->load_flag & FC_UNLOADING)
>                 return;
>  
> -       /*
> -        * Disassociate any older association between this ndlp and
> rport
> -        */
> -       if (ndlp->rport) {
> -               rdata = ndlp->rport->dd_data;
> -               rdata->pnode = NULL;
> -       }
> -
>         ndlp->rport = rport = fc_remote_port_add(shost, 0,
> &rport_ids);
>         if (!rport) {
>                 dev_printk(KERN_WARNING, &phba->pcidev->dev,
diff mbox series

Patch

diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c
index 67bfdddb897c..63e42e3f2165 100644
--- a/drivers/scsi/lpfc/lpfc_hbadisc.c
+++ b/drivers/scsi/lpfc/lpfc_hbadisc.c
@@ -4498,14 +4498,6 @@  lpfc_register_remote_port(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
 	if (vport->load_flag & FC_UNLOADING)
 		return;
 
-	/*
-	 * Disassociate any older association between this ndlp and rport
-	 */
-	if (ndlp->rport) {
-		rdata = ndlp->rport->dd_data;
-		rdata->pnode = NULL;
-	}
-
 	ndlp->rport = rport = fc_remote_port_add(shost, 0, &rport_ids);
 	if (!rport) {
 		dev_printk(KERN_WARNING, &phba->pcidev->dev,