All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xen-netback: don't de-reference vif pointer after having called xenvif_put()
@ 2013-06-05 14:03 Jan Beulich
  2013-06-05 15:13 ` Ian Campbell
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: Jan Beulich @ 2013-06-05 14:03 UTC (permalink / raw)
  To: Ian Campbell, davem; +Cc: xen-devel, netdev

[-- Attachment #1: Type: text/plain, Size: 1643 bytes --]

When putting vif-s on the rx notify list, calling xenvif_put() must be
deferred until after the removal from the list and the issuing of the
notification, as both operations dereference the pointer.

Changing this got me to notice that the "irq" variable was effectively
unused (and was of too narrow type anyway).

Signed-off-by: Jan Beulich <jbeulich@suse.com>

---
 drivers/net/xen-netback/netback.c |   11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

--- 3.10-rc4/drivers/net/xen-netback/netback.c
+++ 3.10-rc4-xen-netback-vif-use-after-free/drivers/net/xen-netback/netback.c
@@ -662,7 +662,7 @@ static void xen_netbk_rx_action(struct x
 {
 	struct xenvif *vif = NULL, *tmp;
 	s8 status;
-	u16 irq, flags;
+	u16 flags;
 	struct xen_netif_rx_response *resp;
 	struct sk_buff_head rxq;
 	struct sk_buff *skb;
@@ -771,13 +771,13 @@ static void xen_netbk_rx_action(struct x
 					 sco->meta_slots_used);
 
 		RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(&vif->rx, ret);
-		irq = vif->irq;
-		if (ret && list_empty(&vif->notify_list))
-			list_add_tail(&vif->notify_list, &notify);
 
 		xenvif_notify_tx_completion(vif);
 
-		xenvif_put(vif);
+		if (ret && list_empty(&vif->notify_list))
+			list_add_tail(&vif->notify_list, &notify);
+		else
+			xenvif_put(vif);
 		npo.meta_cons += sco->meta_slots_used;
 		dev_kfree_skb(skb);
 	}
@@ -785,6 +785,7 @@ static void xen_netbk_rx_action(struct x
 	list_for_each_entry_safe(vif, tmp, &notify, notify_list) {
 		notify_remote_via_irq(vif->irq);
 		list_del_init(&vif->notify_list);
+		xenvif_put(vif);
 	}
 
 	/* More work to do? */




[-- Attachment #2: linux-3.10-rc4-xen-netback-vif-use-after-free.patch --]
[-- Type: text/plain, Size: 1717 bytes --]

xen-netback: don't de-reference vif pointer after having called xenvif_put()

When putting vif-s on the rx notify list, calling xenvif_put() must be
deferred until after the removal from the list and the issuing of the
notification, as both operations dereference the pointer.

Changing this got me to notice that the "irq" variable was effectively
unused (and was of too narrow type anyway).

Signed-off-by: Jan Beulich <jbeulich@suse.com>

---
 drivers/net/xen-netback/netback.c |   11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

--- 3.10-rc4/drivers/net/xen-netback/netback.c
+++ 3.10-rc4-xen-netback-vif-use-after-free/drivers/net/xen-netback/netback.c
@@ -662,7 +662,7 @@ static void xen_netbk_rx_action(struct x
 {
 	struct xenvif *vif = NULL, *tmp;
 	s8 status;
-	u16 irq, flags;
+	u16 flags;
 	struct xen_netif_rx_response *resp;
 	struct sk_buff_head rxq;
 	struct sk_buff *skb;
@@ -771,13 +771,13 @@ static void xen_netbk_rx_action(struct x
 					 sco->meta_slots_used);
 
 		RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(&vif->rx, ret);
-		irq = vif->irq;
-		if (ret && list_empty(&vif->notify_list))
-			list_add_tail(&vif->notify_list, &notify);
 
 		xenvif_notify_tx_completion(vif);
 
-		xenvif_put(vif);
+		if (ret && list_empty(&vif->notify_list))
+			list_add_tail(&vif->notify_list, &notify);
+		else
+			xenvif_put(vif);
 		npo.meta_cons += sco->meta_slots_used;
 		dev_kfree_skb(skb);
 	}
@@ -785,6 +785,7 @@ static void xen_netbk_rx_action(struct x
 	list_for_each_entry_safe(vif, tmp, &notify, notify_list) {
 		notify_remote_via_irq(vif->irq);
 		list_del_init(&vif->notify_list);
+		xenvif_put(vif);
 	}
 
 	/* More work to do? */

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] xen-netback: don't de-reference vif pointer after having called xenvif_put()
  2013-06-05 14:03 [PATCH] xen-netback: don't de-reference vif pointer after having called xenvif_put() Jan Beulich
  2013-06-05 15:13 ` Ian Campbell
@ 2013-06-05 15:13 ` Ian Campbell
  2013-06-11  9:01 ` David Miller
  2013-06-11  9:01 ` [PATCH] " David Miller
  3 siblings, 0 replies; 14+ messages in thread
From: Ian Campbell @ 2013-06-05 15:13 UTC (permalink / raw)
  To: Jan Beulich; +Cc: davem, xen-devel, netdev

On Wed, 2013-06-05 at 15:03 +0100, Jan Beulich wrote:
> When putting vif-s on the rx notify list, calling xenvif_put() must be
> deferred until after the removal from the list and the issuing of the
> notification, as both operations dereference the pointer.
> 
> Changing this got me to notice that the "irq" variable was effectively
> unused (and was of too narrow type anyway).
> 
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Acked-by: Ian Campbell <ian.campbell@citrix.com>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] xen-netback: don't de-reference vif pointer after having called xenvif_put()
  2013-06-05 14:03 [PATCH] xen-netback: don't de-reference vif pointer after having called xenvif_put() Jan Beulich
@ 2013-06-05 15:13 ` Ian Campbell
  2013-06-05 15:13 ` Ian Campbell
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 14+ messages in thread
From: Ian Campbell @ 2013-06-05 15:13 UTC (permalink / raw)
  To: Jan Beulich; +Cc: netdev, davem, xen-devel

On Wed, 2013-06-05 at 15:03 +0100, Jan Beulich wrote:
> When putting vif-s on the rx notify list, calling xenvif_put() must be
> deferred until after the removal from the list and the issuing of the
> notification, as both operations dereference the pointer.
> 
> Changing this got me to notice that the "irq" variable was effectively
> unused (and was of too narrow type anyway).
> 
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Acked-by: Ian Campbell <ian.campbell@citrix.com>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] xen-netback: don't de-reference vif pointer after having called xenvif_put()
  2013-06-05 14:03 [PATCH] xen-netback: don't de-reference vif pointer after having called xenvif_put() Jan Beulich
  2013-06-05 15:13 ` Ian Campbell
  2013-06-05 15:13 ` Ian Campbell
@ 2013-06-11  9:01 ` David Miller
  2013-06-11  9:59   ` Jan Beulich
                     ` (3 more replies)
  2013-06-11  9:01 ` [PATCH] " David Miller
  3 siblings, 4 replies; 14+ messages in thread
From: David Miller @ 2013-06-11  9:01 UTC (permalink / raw)
  To: JBeulich; +Cc: ian.campbell, xen-devel, netdev

From: "Jan Beulich" <JBeulich@suse.com>
Date: Wed, 05 Jun 2013 15:03:11 +0100

> When putting vif-s on the rx notify list, calling xenvif_put() must be
> deferred until after the removal from the list and the issuing of the
> notification, as both operations dereference the pointer.
> 
> Changing this got me to notice that the "irq" variable was effectively
> unused (and was of too narrow type anyway).
> 
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

You've included the commit message, and the patch, twice.  Once inline
and once as an attachment, do not do this.  It makes the patch impossible
to apply when I fetch it out of patchwork.

Please submit it properly.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] xen-netback: don't de-reference vif pointer after having called xenvif_put()
  2013-06-05 14:03 [PATCH] xen-netback: don't de-reference vif pointer after having called xenvif_put() Jan Beulich
                   ` (2 preceding siblings ...)
  2013-06-11  9:01 ` David Miller
@ 2013-06-11  9:01 ` David Miller
  3 siblings, 0 replies; 14+ messages in thread
From: David Miller @ 2013-06-11  9:01 UTC (permalink / raw)
  To: JBeulich; +Cc: netdev, ian.campbell, xen-devel

From: "Jan Beulich" <JBeulich@suse.com>
Date: Wed, 05 Jun 2013 15:03:11 +0100

> When putting vif-s on the rx notify list, calling xenvif_put() must be
> deferred until after the removal from the list and the issuing of the
> notification, as both operations dereference the pointer.
> 
> Changing this got me to notice that the "irq" variable was effectively
> unused (and was of too narrow type anyway).
> 
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

You've included the commit message, and the patch, twice.  Once inline
and once as an attachment, do not do this.  It makes the patch impossible
to apply when I fetch it out of patchwork.

Please submit it properly.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] xen-netback: don't de-reference vif pointer after having called xenvif_put()
  2013-06-11  9:01 ` David Miller
  2013-06-11  9:59   ` Jan Beulich
@ 2013-06-11  9:59   ` Jan Beulich
  2013-06-11 20:00     ` David Miller
  2013-06-11 20:00     ` David Miller
  2013-06-11 10:00   ` [PATCH, resend] " Jan Beulich
  2013-06-11 10:00   ` Jan Beulich
  3 siblings, 2 replies; 14+ messages in thread
From: Jan Beulich @ 2013-06-11  9:59 UTC (permalink / raw)
  To: David Miller; +Cc: ian.campbell, xen-devel, netdev

>>> On 11.06.13 at 11:01, David Miller <davem@davemloft.net> wrote:
> From: "Jan Beulich" <JBeulich@suse.com>
> Date: Wed, 05 Jun 2013 15:03:11 +0100
> 
>> When putting vif-s on the rx notify list, calling xenvif_put() must be
>> deferred until after the removal from the list and the issuing of the
>> notification, as both operations dereference the pointer.
>> 
>> Changing this got me to notice that the "irq" variable was effectively
>> unused (and was of too narrow type anyway).
>> 
>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> 
> You've included the commit message, and the patch, twice.  Once inline
> and once as an attachment, do not do this.  It makes the patch impossible
> to apply when I fetch it out of patchwork.
> 
> Please submit it properly.

Sending to multiple lists makes it impossible to match everyone's
preferences/requirements. xen-devel generally wants patches
inline and attached (for the case where the inline variant gets
mangled by mail programs).

I'll resend inline only, in the hope that it'll reach your inbox intact.

Jan

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] xen-netback: don't de-reference vif pointer after having called xenvif_put()
  2013-06-11  9:01 ` David Miller
@ 2013-06-11  9:59   ` Jan Beulich
  2013-06-11  9:59   ` Jan Beulich
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 14+ messages in thread
From: Jan Beulich @ 2013-06-11  9:59 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, ian.campbell, xen-devel

>>> On 11.06.13 at 11:01, David Miller <davem@davemloft.net> wrote:
> From: "Jan Beulich" <JBeulich@suse.com>
> Date: Wed, 05 Jun 2013 15:03:11 +0100
> 
>> When putting vif-s on the rx notify list, calling xenvif_put() must be
>> deferred until after the removal from the list and the issuing of the
>> notification, as both operations dereference the pointer.
>> 
>> Changing this got me to notice that the "irq" variable was effectively
>> unused (and was of too narrow type anyway).
>> 
>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> 
> You've included the commit message, and the patch, twice.  Once inline
> and once as an attachment, do not do this.  It makes the patch impossible
> to apply when I fetch it out of patchwork.
> 
> Please submit it properly.

Sending to multiple lists makes it impossible to match everyone's
preferences/requirements. xen-devel generally wants patches
inline and attached (for the case where the inline variant gets
mangled by mail programs).

I'll resend inline only, in the hope that it'll reach your inbox intact.

Jan

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH, resend] xen-netback: don't de-reference vif pointer after having called xenvif_put()
  2013-06-11  9:01 ` David Miller
                     ` (2 preceding siblings ...)
  2013-06-11 10:00   ` [PATCH, resend] " Jan Beulich
@ 2013-06-11 10:00   ` Jan Beulich
  2013-06-13  8:25     ` David Miller
  2013-06-13  8:25     ` David Miller
  3 siblings, 2 replies; 14+ messages in thread
From: Jan Beulich @ 2013-06-11 10:00 UTC (permalink / raw)
  To: David Miller; +Cc: ian.campbell, xen-devel, netdev

When putting vif-s on the rx notify list, calling xenvif_put() must be
deferred until after the removal from the list and the issuing of the
notification, as both operations dereference the pointer.

Changing this got me to notice that the "irq" variable was effectively
unused (and was of too narrow type anyway).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>

---
 drivers/net/xen-netback/netback.c |   11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

--- 3.10-rc4/drivers/net/xen-netback/netback.c
+++ 3.10-rc4-xen-netback-vif-use-after-free/drivers/net/xen-netback/netback.c
@@ -662,7 +662,7 @@ static void xen_netbk_rx_action(struct x
 {
 	struct xenvif *vif = NULL, *tmp;
 	s8 status;
-	u16 irq, flags;
+	u16 flags;
 	struct xen_netif_rx_response *resp;
 	struct sk_buff_head rxq;
 	struct sk_buff *skb;
@@ -771,13 +771,13 @@ static void xen_netbk_rx_action(struct x
 					 sco->meta_slots_used);
 
 		RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(&vif->rx, ret);
-		irq = vif->irq;
-		if (ret && list_empty(&vif->notify_list))
-			list_add_tail(&vif->notify_list, &notify);
 
 		xenvif_notify_tx_completion(vif);
 
-		xenvif_put(vif);
+		if (ret && list_empty(&vif->notify_list))
+			list_add_tail(&vif->notify_list, &notify);
+		else
+			xenvif_put(vif);
 		npo.meta_cons += sco->meta_slots_used;
 		dev_kfree_skb(skb);
 	}
@@ -785,6 +785,7 @@ static void xen_netbk_rx_action(struct x
 	list_for_each_entry_safe(vif, tmp, &notify, notify_list) {
 		notify_remote_via_irq(vif->irq);
 		list_del_init(&vif->notify_list);
+		xenvif_put(vif);
 	}
 
 	/* More work to do? */

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH, resend] xen-netback: don't de-reference vif pointer after having called xenvif_put()
  2013-06-11  9:01 ` David Miller
  2013-06-11  9:59   ` Jan Beulich
  2013-06-11  9:59   ` Jan Beulich
@ 2013-06-11 10:00   ` Jan Beulich
  2013-06-11 10:00   ` Jan Beulich
  3 siblings, 0 replies; 14+ messages in thread
From: Jan Beulich @ 2013-06-11 10:00 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, ian.campbell, xen-devel

When putting vif-s on the rx notify list, calling xenvif_put() must be
deferred until after the removal from the list and the issuing of the
notification, as both operations dereference the pointer.

Changing this got me to notice that the "irq" variable was effectively
unused (and was of too narrow type anyway).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>

---
 drivers/net/xen-netback/netback.c |   11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

--- 3.10-rc4/drivers/net/xen-netback/netback.c
+++ 3.10-rc4-xen-netback-vif-use-after-free/drivers/net/xen-netback/netback.c
@@ -662,7 +662,7 @@ static void xen_netbk_rx_action(struct x
 {
 	struct xenvif *vif = NULL, *tmp;
 	s8 status;
-	u16 irq, flags;
+	u16 flags;
 	struct xen_netif_rx_response *resp;
 	struct sk_buff_head rxq;
 	struct sk_buff *skb;
@@ -771,13 +771,13 @@ static void xen_netbk_rx_action(struct x
 					 sco->meta_slots_used);
 
 		RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(&vif->rx, ret);
-		irq = vif->irq;
-		if (ret && list_empty(&vif->notify_list))
-			list_add_tail(&vif->notify_list, &notify);
 
 		xenvif_notify_tx_completion(vif);
 
-		xenvif_put(vif);
+		if (ret && list_empty(&vif->notify_list))
+			list_add_tail(&vif->notify_list, &notify);
+		else
+			xenvif_put(vif);
 		npo.meta_cons += sco->meta_slots_used;
 		dev_kfree_skb(skb);
 	}
@@ -785,6 +785,7 @@ static void xen_netbk_rx_action(struct x
 	list_for_each_entry_safe(vif, tmp, &notify, notify_list) {
 		notify_remote_via_irq(vif->irq);
 		list_del_init(&vif->notify_list);
+		xenvif_put(vif);
 	}
 
 	/* More work to do? */

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] xen-netback: don't de-reference vif pointer after having called xenvif_put()
  2013-06-11  9:59   ` Jan Beulich
  2013-06-11 20:00     ` David Miller
@ 2013-06-11 20:00     ` David Miller
  1 sibling, 0 replies; 14+ messages in thread
From: David Miller @ 2013-06-11 20:00 UTC (permalink / raw)
  To: JBeulich; +Cc: ian.campbell, xen-devel, netdev

From: "Jan Beulich" <JBeulich@suse.com>
Date: Tue, 11 Jun 2013 10:59:39 +0100

>>>> On 11.06.13 at 11:01, David Miller <davem@davemloft.net> wrote:
>> From: "Jan Beulich" <JBeulich@suse.com>
>> Date: Wed, 05 Jun 2013 15:03:11 +0100
>> 
>>> When putting vif-s on the rx notify list, calling xenvif_put() must be
>>> deferred until after the removal from the list and the issuing of the
>>> notification, as both operations dereference the pointer.
>>> 
>>> Changing this got me to notice that the "irq" variable was effectively
>>> unused (and was of too narrow type anyway).
>>> 
>>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>> 
>> You've included the commit message, and the patch, twice.  Once inline
>> and once as an attachment, do not do this.  It makes the patch impossible
>> to apply when I fetch it out of patchwork.
>> 
>> Please submit it properly.
> 
> Sending to multiple lists makes it impossible to match everyone's
> preferences/requirements. xen-devel generally wants patches
> inline and attached (for the case where the inline variant gets
> mangled by mail programs).

That's rediculous.  Fix your mail client setup, and send it inline
only.

Otherwise people can't reply and comment inline to the content of
your patch properly.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] xen-netback: don't de-reference vif pointer after having called xenvif_put()
  2013-06-11  9:59   ` Jan Beulich
@ 2013-06-11 20:00     ` David Miller
  2013-06-11 20:00     ` David Miller
  1 sibling, 0 replies; 14+ messages in thread
From: David Miller @ 2013-06-11 20:00 UTC (permalink / raw)
  To: JBeulich; +Cc: netdev, ian.campbell, xen-devel

From: "Jan Beulich" <JBeulich@suse.com>
Date: Tue, 11 Jun 2013 10:59:39 +0100

>>>> On 11.06.13 at 11:01, David Miller <davem@davemloft.net> wrote:
>> From: "Jan Beulich" <JBeulich@suse.com>
>> Date: Wed, 05 Jun 2013 15:03:11 +0100
>> 
>>> When putting vif-s on the rx notify list, calling xenvif_put() must be
>>> deferred until after the removal from the list and the issuing of the
>>> notification, as both operations dereference the pointer.
>>> 
>>> Changing this got me to notice that the "irq" variable was effectively
>>> unused (and was of too narrow type anyway).
>>> 
>>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>> 
>> You've included the commit message, and the patch, twice.  Once inline
>> and once as an attachment, do not do this.  It makes the patch impossible
>> to apply when I fetch it out of patchwork.
>> 
>> Please submit it properly.
> 
> Sending to multiple lists makes it impossible to match everyone's
> preferences/requirements. xen-devel generally wants patches
> inline and attached (for the case where the inline variant gets
> mangled by mail programs).

That's rediculous.  Fix your mail client setup, and send it inline
only.

Otherwise people can't reply and comment inline to the content of
your patch properly.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH, resend] xen-netback: don't de-reference vif pointer after having called xenvif_put()
  2013-06-11 10:00   ` Jan Beulich
@ 2013-06-13  8:25     ` David Miller
  2013-06-13  8:25     ` David Miller
  1 sibling, 0 replies; 14+ messages in thread
From: David Miller @ 2013-06-13  8:25 UTC (permalink / raw)
  To: JBeulich; +Cc: ian.campbell, xen-devel, netdev

From: "Jan Beulich" <JBeulich@suse.com>
Date: Tue, 11 Jun 2013 11:00:34 +0100

> When putting vif-s on the rx notify list, calling xenvif_put() must be
> deferred until after the removal from the list and the issuing of the
> notification, as both operations dereference the pointer.
> 
> Changing this got me to notice that the "irq" variable was effectively
> unused (and was of too narrow type anyway).
> 
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> Acked-by: Ian Campbell <ian.campbell@citrix.com>

Applied.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH, resend] xen-netback: don't de-reference vif pointer after having called xenvif_put()
  2013-06-11 10:00   ` Jan Beulich
  2013-06-13  8:25     ` David Miller
@ 2013-06-13  8:25     ` David Miller
  1 sibling, 0 replies; 14+ messages in thread
From: David Miller @ 2013-06-13  8:25 UTC (permalink / raw)
  To: JBeulich; +Cc: netdev, ian.campbell, xen-devel

From: "Jan Beulich" <JBeulich@suse.com>
Date: Tue, 11 Jun 2013 11:00:34 +0100

> When putting vif-s on the rx notify list, calling xenvif_put() must be
> deferred until after the removal from the list and the issuing of the
> notification, as both operations dereference the pointer.
> 
> Changing this got me to notice that the "irq" variable was effectively
> unused (and was of too narrow type anyway).
> 
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> Acked-by: Ian Campbell <ian.campbell@citrix.com>

Applied.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH] xen-netback: don't de-reference vif pointer after having called xenvif_put()
@ 2013-06-05 14:03 Jan Beulich
  0 siblings, 0 replies; 14+ messages in thread
From: Jan Beulich @ 2013-06-05 14:03 UTC (permalink / raw)
  To: Ian Campbell, davem; +Cc: netdev, xen-devel

[-- Attachment #1: Type: text/plain, Size: 1643 bytes --]

When putting vif-s on the rx notify list, calling xenvif_put() must be
deferred until after the removal from the list and the issuing of the
notification, as both operations dereference the pointer.

Changing this got me to notice that the "irq" variable was effectively
unused (and was of too narrow type anyway).

Signed-off-by: Jan Beulich <jbeulich@suse.com>

---
 drivers/net/xen-netback/netback.c |   11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

--- 3.10-rc4/drivers/net/xen-netback/netback.c
+++ 3.10-rc4-xen-netback-vif-use-after-free/drivers/net/xen-netback/netback.c
@@ -662,7 +662,7 @@ static void xen_netbk_rx_action(struct x
 {
 	struct xenvif *vif = NULL, *tmp;
 	s8 status;
-	u16 irq, flags;
+	u16 flags;
 	struct xen_netif_rx_response *resp;
 	struct sk_buff_head rxq;
 	struct sk_buff *skb;
@@ -771,13 +771,13 @@ static void xen_netbk_rx_action(struct x
 					 sco->meta_slots_used);
 
 		RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(&vif->rx, ret);
-		irq = vif->irq;
-		if (ret && list_empty(&vif->notify_list))
-			list_add_tail(&vif->notify_list, &notify);
 
 		xenvif_notify_tx_completion(vif);
 
-		xenvif_put(vif);
+		if (ret && list_empty(&vif->notify_list))
+			list_add_tail(&vif->notify_list, &notify);
+		else
+			xenvif_put(vif);
 		npo.meta_cons += sco->meta_slots_used;
 		dev_kfree_skb(skb);
 	}
@@ -785,6 +785,7 @@ static void xen_netbk_rx_action(struct x
 	list_for_each_entry_safe(vif, tmp, &notify, notify_list) {
 		notify_remote_via_irq(vif->irq);
 		list_del_init(&vif->notify_list);
+		xenvif_put(vif);
 	}
 
 	/* More work to do? */




[-- Attachment #2: linux-3.10-rc4-xen-netback-vif-use-after-free.patch --]
[-- Type: text/plain, Size: 1717 bytes --]

xen-netback: don't de-reference vif pointer after having called xenvif_put()

When putting vif-s on the rx notify list, calling xenvif_put() must be
deferred until after the removal from the list and the issuing of the
notification, as both operations dereference the pointer.

Changing this got me to notice that the "irq" variable was effectively
unused (and was of too narrow type anyway).

Signed-off-by: Jan Beulich <jbeulich@suse.com>

---
 drivers/net/xen-netback/netback.c |   11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

--- 3.10-rc4/drivers/net/xen-netback/netback.c
+++ 3.10-rc4-xen-netback-vif-use-after-free/drivers/net/xen-netback/netback.c
@@ -662,7 +662,7 @@ static void xen_netbk_rx_action(struct x
 {
 	struct xenvif *vif = NULL, *tmp;
 	s8 status;
-	u16 irq, flags;
+	u16 flags;
 	struct xen_netif_rx_response *resp;
 	struct sk_buff_head rxq;
 	struct sk_buff *skb;
@@ -771,13 +771,13 @@ static void xen_netbk_rx_action(struct x
 					 sco->meta_slots_used);
 
 		RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(&vif->rx, ret);
-		irq = vif->irq;
-		if (ret && list_empty(&vif->notify_list))
-			list_add_tail(&vif->notify_list, &notify);
 
 		xenvif_notify_tx_completion(vif);
 
-		xenvif_put(vif);
+		if (ret && list_empty(&vif->notify_list))
+			list_add_tail(&vif->notify_list, &notify);
+		else
+			xenvif_put(vif);
 		npo.meta_cons += sco->meta_slots_used;
 		dev_kfree_skb(skb);
 	}
@@ -785,6 +785,7 @@ static void xen_netbk_rx_action(struct x
 	list_for_each_entry_safe(vif, tmp, &notify, notify_list) {
 		notify_remote_via_irq(vif->irq);
 		list_del_init(&vif->notify_list);
+		xenvif_put(vif);
 	}
 
 	/* More work to do? */

[-- Attachment #3: Type: text/plain, Size: 126 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2013-06-13  8:25 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-05 14:03 [PATCH] xen-netback: don't de-reference vif pointer after having called xenvif_put() Jan Beulich
2013-06-05 15:13 ` Ian Campbell
2013-06-05 15:13 ` Ian Campbell
2013-06-11  9:01 ` David Miller
2013-06-11  9:59   ` Jan Beulich
2013-06-11  9:59   ` Jan Beulich
2013-06-11 20:00     ` David Miller
2013-06-11 20:00     ` David Miller
2013-06-11 10:00   ` [PATCH, resend] " Jan Beulich
2013-06-11 10:00   ` Jan Beulich
2013-06-13  8:25     ` David Miller
2013-06-13  8:25     ` David Miller
2013-06-11  9:01 ` [PATCH] " David Miller
2013-06-05 14:03 Jan Beulich

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.