diff mbox

[net,3/3] xen-netback: BUG_ON in xenvif_rx_action() not catching overflow

Message ID 1395922988-37702-4-git-send-email-paul.durrant@citrix.com
State Superseded, archived
Delegated to: David Miller
Headers show

Commit Message

Paul Durrant March 27, 2014, 12:23 p.m. UTC
The BUG_ON to catch ring overflow in xenvif_rx_action() makes the assumption
that meta_slots_used == ring slots used. This is not the case for GSO
packets. This patch changes the test to actually check ring slots.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>
Cc: Sander Eikelenboom <linux@eikelenboom.it>
---
 drivers/net/xen-netback/netback.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Ian Campbell March 27, 2014, 12:28 p.m. UTC | #1
On Thu, 2014-03-27 at 12:23 +0000, Paul Durrant wrote:
> The BUG_ON to catch ring overflow in xenvif_rx_action() makes the assumption
> that meta_slots_used == ring slots used. This is not the case for GSO
> packets.

Can you explain why not here please.

>  This patch changes the test to actually check ring slots.
> 
> Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
> Cc: Ian Campbell <ian.campbell@citrix.com>
> Cc: Wei Liu <wei.liu2@citrix.com>
> Cc: Sander Eikelenboom <linux@eikelenboom.it>
> ---
>  drivers/net/xen-netback/netback.c |    8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c
> index ac35489..ae7351f 100644
> --- a/drivers/net/xen-netback/netback.c
> +++ b/drivers/net/xen-netback/netback.c
> @@ -481,6 +481,8 @@ static void xenvif_rx_action(struct xenvif *vif)
>  
>  	while ((skb = skb_dequeue(&vif->rx_queue)) != NULL) {
>  		RING_IDX max_slots_needed;
> +		RING_IDX old_req_cons;
> +		RING_IDX ring_slots_used;
>  		int i;
>  
>  		/* We need a cheap worse case estimate for the number of
> @@ -520,8 +522,12 @@ static void xenvif_rx_action(struct xenvif *vif)
>  			vif->rx_last_skb_slots = 0;
>  
>  		sco = (struct skb_cb_overlay *)skb->cb;
> +
> +		old_req_cons = vif->rx.req_cons;
>  		sco->meta_slots_used = xenvif_gop_skb(skb, &npo);
> -		BUG_ON(sco->meta_slots_used > max_slots_needed);
> +		ring_slots_used = vif->rx.req_cons - old_req_cons;
> +
> +		BUG_ON(ring_slots_used > max_slots_needed);
>  
>  		__skb_queue_tail(&rxq, skb);
>  	}


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Paul Durrant March 27, 2014, 12:30 p.m. UTC | #2
> -----Original Message-----

> From: Ian Campbell

> Sent: 27 March 2014 12:28

> To: Paul Durrant

> Cc: xen-devel@lists.xen.org; netdev@vger.kernel.org; Wei Liu; Sander

> Eikelenboom

> Subject: Re: [PATCH net 3/3] xen-netback: BUG_ON in xenvif_rx_action()

> not catching overflow

> 

> On Thu, 2014-03-27 at 12:23 +0000, Paul Durrant wrote:

> > The BUG_ON to catch ring overflow in xenvif_rx_action() makes the

> assumption

> > that meta_slots_used == ring slots used. This is not the case for GSO

> > packets.

> 

> Can you explain why not here please.

>


Sure. I'll add an explanation.

  Paul
 
> >  This patch changes the test to actually check ring slots.

> >

> > Signed-off-by: Paul Durrant <paul.durrant@citrix.com>

> > Cc: Ian Campbell <ian.campbell@citrix.com>

> > Cc: Wei Liu <wei.liu2@citrix.com>

> > Cc: Sander Eikelenboom <linux@eikelenboom.it>

> > ---

> >  drivers/net/xen-netback/netback.c |    8 +++++++-

> >  1 file changed, 7 insertions(+), 1 deletion(-)

> >

> > diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-

> netback/netback.c

> > index ac35489..ae7351f 100644

> > --- a/drivers/net/xen-netback/netback.c

> > +++ b/drivers/net/xen-netback/netback.c

> > @@ -481,6 +481,8 @@ static void xenvif_rx_action(struct xenvif *vif)

> >

> >  	while ((skb = skb_dequeue(&vif->rx_queue)) != NULL) {

> >  		RING_IDX max_slots_needed;

> > +		RING_IDX old_req_cons;

> > +		RING_IDX ring_slots_used;

> >  		int i;

> >

> >  		/* We need a cheap worse case estimate for the number of

> > @@ -520,8 +522,12 @@ static void xenvif_rx_action(struct xenvif *vif)

> >  			vif->rx_last_skb_slots = 0;

> >

> >  		sco = (struct skb_cb_overlay *)skb->cb;

> > +

> > +		old_req_cons = vif->rx.req_cons;

> >  		sco->meta_slots_used = xenvif_gop_skb(skb, &npo);

> > -		BUG_ON(sco->meta_slots_used > max_slots_needed);

> > +		ring_slots_used = vif->rx.req_cons - old_req_cons;

> > +

> > +		BUG_ON(ring_slots_used > max_slots_needed);

> >

> >  		__skb_queue_tail(&rxq, skb);

> >  	}

>
diff mbox

Patch

diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c
index ac35489..ae7351f 100644
--- a/drivers/net/xen-netback/netback.c
+++ b/drivers/net/xen-netback/netback.c
@@ -481,6 +481,8 @@  static void xenvif_rx_action(struct xenvif *vif)
 
 	while ((skb = skb_dequeue(&vif->rx_queue)) != NULL) {
 		RING_IDX max_slots_needed;
+		RING_IDX old_req_cons;
+		RING_IDX ring_slots_used;
 		int i;
 
 		/* We need a cheap worse case estimate for the number of
@@ -520,8 +522,12 @@  static void xenvif_rx_action(struct xenvif *vif)
 			vif->rx_last_skb_slots = 0;
 
 		sco = (struct skb_cb_overlay *)skb->cb;
+
+		old_req_cons = vif->rx.req_cons;
 		sco->meta_slots_used = xenvif_gop_skb(skb, &npo);
-		BUG_ON(sco->meta_slots_used > max_slots_needed);
+		ring_slots_used = vif->rx.req_cons - old_req_cons;
+
+		BUG_ON(ring_slots_used > max_slots_needed);
 
 		__skb_queue_tail(&rxq, skb);
 	}