Patchwork [Open-FCoE] target/tcm_fc: Fix use-after-free of ft_tpg

login
register
mail settings
Submitter Andy Grover
Date April 4, 2014, 11:44 p.m.
Message ID <1396655077-30912-1-git-send-email-agrover@redhat.com>
Download mbox | patch
Permalink /patch/145/
State Not Applicable
Headers show

Comments

Andy Grover - April 4, 2014, 11:44 p.m.
ft_del_tpg checks tpg->tport is set before unlinking the tpg from the
tport when the tpg is being removed. Set this pointer in ft_tport_create,
or the unlinking won't happen in ft_del_tpg and tport->tpg will reference
a deleted object.

see https://bugzilla.redhat.com/show_bug.cgi?id=1071340

Cc: stable@vger.kernel.org
Signed-off-by: Andy Grover <agrover@redhat.com>
---
 drivers/target/tcm_fc/tfc_sess.c | 1 +
 1 file changed, 1 insertion(+)
Nicholas A. Bellinger - April 6, 2014, 10:59 p.m.
Hi Andy,

On Fri, 2014-04-04 at 16:44 -0700, Andy Grover wrote:
> ft_del_tpg checks tpg->tport is set before unlinking the tpg from the
> tport when the tpg is being removed. Set this pointer in ft_tport_create,
> or the unlinking won't happen in ft_del_tpg and tport->tpg will reference
> a deleted object.
> 
> see https://bugzilla.redhat.com/show_bug.cgi?id=1071340
> 
> Cc: stable@vger.kernel.org
> Signed-off-by: Andy Grover <agrover@redhat.com>
> ---
>  drivers/target/tcm_fc/tfc_sess.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/target/tcm_fc/tfc_sess.c b/drivers/target/tcm_fc/tfc_sess.c
> index 0475142..1329726 100644
> --- a/drivers/target/tcm_fc/tfc_sess.c
> +++ b/drivers/target/tcm_fc/tfc_sess.c
> @@ -68,6 +68,7 @@ static struct ft_tport *ft_tport_create(struct fc_lport *lport)
>  
>  	if (tport) {
>  		tport->tpg = tpg;
> +		tpg->tport = tport;
>  		return tport;
>  	}
>  

I'm confused how this addresses the bug above..?

Does this mean the bug is only triggered when a previously
configured /sys/kernel/config/target/fc/$FCOE_WWPN/$TPGT has been
removed, and then a new PLOGI picks up a left-over pointer to an
endpoint that previously had been released..?

Care to add a more detailed commit explaining the exact details..?

--nab

Patch

diff --git a/drivers/target/tcm_fc/tfc_sess.c b/drivers/target/tcm_fc/tfc_sess.c
index 0475142..1329726 100644
--- a/drivers/target/tcm_fc/tfc_sess.c
+++ b/drivers/target/tcm_fc/tfc_sess.c
@@ -68,6 +68,7 @@  static struct ft_tport *ft_tport_create(struct fc_lport *lport)
 
 	if (tport) {
 		tport->tpg = tpg;
+		tpg->tport = tport;
 		return tport;
 	}