* [PATCH] target/tcm_fc: Fix use-after-free of ft_tpg
@ 2014-04-04 23:44 Andy Grover
2014-04-06 22:59 ` Nicholas A. Bellinger
0 siblings, 1 reply; 3+ messages in thread
From: Andy Grover @ 2014-04-04 23:44 UTC (permalink / raw)
To: target-devel-u79uwXL29TY76Z2rM5mHXA
Cc: fcoe-devel-s9riP+hp16TNLxjTenLetw,
linux-scsi-u79uwXL29TY76Z2rM5mHXA
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-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Signed-off-by: Andy Grover <agrover-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
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;
}
--
1.9.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] target/tcm_fc: Fix use-after-free of ft_tpg
2014-04-04 23:44 [PATCH] target/tcm_fc: Fix use-after-free of ft_tpg Andy Grover
@ 2014-04-06 22:59 ` Nicholas A. Bellinger
2014-04-07 19:11 ` Andy Grover
0 siblings, 1 reply; 3+ messages in thread
From: Nicholas A. Bellinger @ 2014-04-06 22:59 UTC (permalink / raw)
To: Andy Grover; +Cc: target-devel, linux-scsi, fcoe-devel
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] target/tcm_fc: Fix use-after-free of ft_tpg
2014-04-06 22:59 ` Nicholas A. Bellinger
@ 2014-04-07 19:11 ` Andy Grover
0 siblings, 0 replies; 3+ messages in thread
From: Andy Grover @ 2014-04-07 19:11 UTC (permalink / raw)
To: target-devel; +Cc: linux-scsi, fcoe-devel
This can happen:
- lport created, tport (our per-lport, per-provider context) is allocated.
tport->tpg = NULL
- tpg created
- a PRLI is received. ft_tport_create is called, tpg is found and
tport->tpg is set
- tpg removed. ft_tpg is freed in ft_del_tpg. Since tpg->tport was not
set, tport->tpg is not cleared and points at freed memory
- Future calls to ft_tport_create return tport via first conditional,
instead of searching for new tpg by calling ft_lport_find_tpg.
tport->tpg is still invalid, and will access freed memory.
This patch sets tpg->tport in ft_tport_create, because that's what
ft_del_tpg checks, and is the only way to get back to the tport to
clear tport->tpg.
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;
}
--
1.9.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-04-07 19:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-04 23:44 [PATCH] target/tcm_fc: Fix use-after-free of ft_tpg Andy Grover
2014-04-06 22:59 ` Nicholas A. Bellinger
2014-04-07 19:11 ` Andy Grover
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).