xen-netback: fix oopes during shutdown and error handling
Subsystems (3)
PATCH 1/2 xen-netback: correctly return errors from netbk_count_requests()
In reply to David VrabelFrom: David Vrabel <[email protected]>
netbk_count_requests() could detect an error, call netbk_fatal_tx_error() but return 0. The vif may then be used afterwards (e.g., in a call to netbk_tx_error().
Since netbk_fatal_tx_error() could set vif->refcnt to 1, the vif may be freed immediately after the call to netbk_fatal_tx_error() (e.g., if the vif is also removed).
Netback thread Xenwatch thread
-------------------------------------------netbk_fatal_tx_err() netback_remove()
xenvif_disconnect()
...
free_netdev()netbk_tx_err() Oops!
--- drivers/net/xen-netback/netback.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
drivers/net/xen-netback/netback.c +4 -4
@@ -911,13 +911,13 @@ static int netbk_count_requests(struct xenvif *vif,if (frags >= work_to_do) {netdev_err (vif->dev,"Need more frags\n" );netbk_fatal_tx_err (vif); -return -frags; +return -ENODATA ; }if (unlikely (frags >=MAX_SKB_FRAGS )) {netdev_err (vif->dev,"Too many frags\n" );netbk_fatal_tx_err (vif); -return -frags; +return -E2BIG ; } memcpy(txp, RING_GET_REQUEST(&vif->tx, cons + frags),
@@ -925,7 +925,7 @@ static int netbk_count_requests(struct xenvif *vif,if (txp->size > first->size) {netdev_err (vif->dev,"Frag is bigger than frame.\n" );netbk_fatal_tx_err (vif); -return -frags; +return -EIO ; } first->size -= txp->size;
@@ -935,7 +935,7 @@ static int netbk_count_requests(struct xenvif *vif,netdev_err (vif->dev,"txp->offset: %x, size: %u\n" , txp->offset, txp->size);netbk_fatal_tx_err (vif); -return -frags; +return -EINVAL ; } }while ((txp++)->flags & XEN_NETTXF_more_data);return frags;
Signature · 1 line
1.7.2.5
PATCH 2/2 xen-netback: cancel the credit timer when taking the vif down
In reply to David VrabelFrom: David Vrabel <[email protected]>
If the credit timer is left armed after calling xen_netbk_remove_xenvif(), then it may fire and attempt to schedule the vif which will then oops as vif->netbk == NULL.
This may happen both in the fatal error path and during normal disconnection from the front end.
The sequencing during shutdown is critical to ensure that: a) vif->netbk doesn't become unexpectedly NULL; and b) the net device/vif is not freed.
1. Mark as unschedulable (netif_carrier_off()).
2. Synchronously cancel the timer.
3. Remove the vif from the schedule list.
4. Remove it from it netback thread group.
5. Wait for vif->refcnt to become 0.
--- drivers/net/xen-netback/interface.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)
drivers/net/xen-netback/interface.c +1 -2
@@ -132,6 +132,7 @@ static void xenvif_up(struct xenvif *vif)static void xenvif_down (struct xenvif *vif) {disable_irq (vif->irq); +del_timer_sync (&vif->credit_timeout);xen_netbk_deschedule_xenvif (vif);xen_netbk_remove_xenvif (vif); }
@@ -363,8 +364,6 @@ void xenvif_disconnect(struct xenvif *vif)atomic_dec (&vif->refcnt);wait_event (vif->waiting_to_free,atomic_read (&vif->refcnt) ==0 ); -del_timer_sync (&vif->credit_timeout); -if (vif->irq)unbind_from_irqhandler (vif->irq, vif);
Signature · 1 line
1.7.2.5
These two netback patches fix oopes that may occur during shutdown or if a specific fatal error occurs.
They are stable candidants.
David
PATCH 2/2 xen-netback: cancel the credit timer when taking the vif down
From: David Vrabel <[email protected]>
If the credit timer is left armed after calling xen_netbk_remove_xenvif(), then it may fire and attempt to schedule the vif which will then oops as vif->netbk == NULL.
This may happen both in the fatal error path and during normal disconnection from the front end.
The sequencing during shutdown is critical to ensure that: a) vif->netbk doesn't become unexpectedly NULL; and b) the net device/vif is not freed.
1. Mark as unschedulable (netif_carrier_off()).
2. Synchronously cancel the timer.
3. Remove the vif from the schedule list.
4. Remove it from it netback thread group.
5. Wait for vif->refcnt to become 0.
--- drivers/net/xen-netback/interface.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)
drivers/net/xen-netback/interface.c +1 -2
@@ -132,6 +132,7 @@ static void xenvif_up(struct xenvif *vif)static void xenvif_down (struct xenvif *vif) {disable_irq (vif->irq); +del_timer_sync (&vif->credit_timeout);xen_netbk_deschedule_xenvif (vif);xen_netbk_remove_xenvif (vif); }
@@ -363,8 +364,6 @@ void xenvif_disconnect(struct xenvif *vif)atomic_dec (&vif->refcnt);wait_event (vif->waiting_to_free,atomic_read (&vif->refcnt) ==0 ); -del_timer_sync (&vif->credit_timeout); -if (vif->irq)unbind_from_irqhandler (vif->irq, vif);
Signature · 1 line
1.7.2.5
PATCH 1/2 xen-netback: correctly return errors from netbk_count_requests()
In reply to David VrabelFrom: David Vrabel <[email protected]>
netbk_count_requests() could detect an error, call netbk_fatal_tx_error() but return 0. The vif may then be used afterwards (e.g., in a call to netbk_tx_error().
Since netbk_fatal_tx_error() could set vif->refcnt to 1, the vif may be freed immediately after the call to netbk_fatal_tx_error() (e.g., if the vif is also removed).
Netback thread Xenwatch thread
-------------------------------------------netbk_fatal_tx_err() netback_remove()
xenvif_disconnect()
...
free_netdev()netbk_tx_err() Oops!
--- drivers/net/xen-netback/netback.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
drivers/net/xen-netback/netback.c +4 -4
@@ -911,13 +911,13 @@ static int netbk_count_requests(struct xenvif *vif,if (frags >= work_to_do) {netdev_err (vif->dev,"Need more frags\n" );netbk_fatal_tx_err (vif); -return -frags; +return -ENODATA ; }if (unlikely (frags >=MAX_SKB_FRAGS )) {netdev_err (vif->dev,"Too many frags\n" );netbk_fatal_tx_err (vif); -return -frags; +return -E2BIG ; } memcpy(txp, RING_GET_REQUEST(&vif->tx, cons + frags),
@@ -925,7 +925,7 @@ static int netbk_count_requests(struct xenvif *vif,if (txp->size > first->size) {netdev_err (vif->dev,"Frag is bigger than frame.\n" );netbk_fatal_tx_err (vif); -return -frags; +return -EIO ; } first->size -= txp->size;
@@ -935,7 +935,7 @@ static int netbk_count_requests(struct xenvif *vif,netdev_err (vif->dev,"txp->offset: %x, size: %u\n" , txp->offset, txp->size);netbk_fatal_tx_err (vif); -return -frags; +return -EINVAL ; } }while ((txp++)->flags & XEN_NETTXF_more_data);return frags;
Signature · 1 line
1.7.2.5
Re: [PATCH 2/2] xen-netback: cancel the credit timer when taking the vif down
In reply to David VrabelQuoted 13 lines · David Vrabel
From: David Vrabel <[email protected]>
If the credit timer is left armed after calling
xen_netbk_remove_xenvif(), then it may fire and attempt to schedule the vif which will then oops asvif->netbk== NULL.This may happen both in the fatal error path and during normal disconnection from the front end.
The sequencing during shutdown is critical to ensure that: a)
vif->netbkdoesn't become unexpectedly NULL; and b) the net device/vif is not freed.
Quoted 7 lines
1. Mark as unschedulable (
netif_carrier_off()).
2. Synchronously cancel the timer.
3. Remove the vif from the schedule list.
4. Remove it from it netback thread group.
5. Wait forvif->refcntto become 0.Signed-off-by David Vrabel <[email protected]>
You would need to reinitialize the timer in xenvif_up, given that user might ifconfig vifX.X down; ifconfig vifX.X up.
Another less desired but simpler fix would be leave the timer alone but check for vif->netbk != NULL in the timer callback.
Wei.
Quoted 25 lines
--- drivers/net/xen-netback/interface.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)drivers/net/xen-netback/interface.c +1
-2@@ -132,6 +132,7 @@ static void xenvif_up(struct xenvif *vif)static void xenvif_down (struct xenvif *vif) {disable_irq (vif->irq); +del_timer_sync (&vif->credit_timeout);xen_netbk_deschedule_xenvif (vif);xen_netbk_remove_xenvif (vif); }@@ -363,8 +364,6 @@ void xenvif_disconnect(struct xenvif *vif)atomic_dec (&vif->refcnt);wait_event (vif->waiting_to_free,atomic_read (&vif->refcnt) ==0 ); -del_timer_sync (&vif->credit_timeout); -if (vif->irq)unbind_from_irqhandler (vif->irq, vif);
Re: [Xen-devel] [PATCH 2/2] xen-netback: cancel the credit timer when taking the vif down
In reply to David VrabelQuoted 13 lines · David Vrabel
From: David Vrabel <[email protected]>
If the credit timer is left armed after calling
xen_netbk_remove_xenvif(), then it may fire and attempt to schedule the vif which will then oops asvif->netbk== NULL.This may happen both in the fatal error path and during normal disconnection from the front end.
The sequencing during shutdown is critical to ensure that: a)
vif->netbkdoesn't become unexpectedly NULL; and b) the net device/vif is not freed.
Quoted 7 lines
1. Mark as unschedulable (
netif_carrier_off()).
2. Synchronously cancel the timer.
3. Remove the vif from the schedule list.
4. Remove it from it netback thread group.
5. Wait forvif->refcntto become 0.Signed-off-by David Vrabel <[email protected]>
You would need to reinitialize the timer in xenvif_up, given that user might ifconfig vifX.X down; ifconfig vifX.X up.
Another less desired but simpler fix would be leave the timer alone but check for vif->netbk != NULL in the timer callback.
Wei.
Quoted 25 lines
--- drivers/net/xen-netback/interface.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)drivers/net/xen-netback/interface.c +1
-2@@ -132,6 +132,7 @@ static void xenvif_up(struct xenvif *vif)static void xenvif_down (struct xenvif *vif) {disable_irq (vif->irq); +del_timer_sync (&vif->credit_timeout);xen_netbk_deschedule_xenvif (vif);xen_netbk_remove_xenvif (vif); }@@ -363,8 +364,6 @@ void xenvif_disconnect(struct xenvif *vif)atomic_dec (&vif->refcnt);wait_event (vif->waiting_to_free,atomic_read (&vif->refcnt) ==0 ); -del_timer_sync (&vif->credit_timeout); -if (vif->irq)unbind_from_irqhandler (vif->irq, vif);
Re: [PATCH 2/2] xen-netback: cancel the credit timer when taking the vif down
Quoted 20 lines · Wei Liu
Quoted 19 lines · David Vrabel
From: David Vrabel <[email protected]>
If the credit timer is left armed after calling
xen_netbk_remove_xenvif(), then it may fire and attempt to schedule the vif which will then oops asvif->netbk== NULL.This may happen both in the fatal error path and during normal disconnection from the front end.
The sequencing during shutdown is critical to ensure that: a)
vif->netbkdoesn't become unexpectedly NULL; and b) the net device/vif is not freed.1. Mark as unschedulable (
netif_carrier_off()).
2. Synchronously cancel the timer.
3. Remove the vif from the schedule list.
4. Remove it from it netback thread group.
5. Wait forvif->refcntto become 0.
Quoted 4 lines
Quoted 1 line
Signed-off-by David Vrabel <[email protected]>You would need to reinitialize the timer in
xenvif_up, given that user mightifconfig vifX.X down; ifconfig vifX.X up.
No. Deleted timers do not need to be reinitialized. The timer will be armed as usual with mod_timer() when credit is next exhausted.
David
Re: [Xen-devel] [PATCH 2/2] xen-netback: cancel the credit timer when taking the vif down
In reply to Wei LiuQuoted 20 lines · Wei Liu
Quoted 19 lines · David Vrabel
From: David Vrabel <[email protected]>
If the credit timer is left armed after calling
xen_netbk_remove_xenvif(), then it may fire and attempt to schedule the vif which will then oops asvif->netbk== NULL.This may happen both in the fatal error path and during normal disconnection from the front end.
The sequencing during shutdown is critical to ensure that: a)
vif->netbkdoesn't become unexpectedly NULL; and b) the net device/vif is not freed.1. Mark as unschedulable (
netif_carrier_off()).
2. Synchronously cancel the timer.
3. Remove the vif from the schedule list.
4. Remove it from it netback thread group.
5. Wait forvif->refcntto become 0.
Quoted 4 lines
Quoted 1 line
Signed-off-by David Vrabel <[email protected]>You would need to reinitialize the timer in
xenvif_up, given that user mightifconfig vifX.X down; ifconfig vifX.X up.
No. Deleted timers do not need to be reinitialized. The timer will be armed as usual with mod_timer() when credit is next exhausted.
David
Re: [PATCH 2/2] xen-netback: cancel the credit timer when taking the vif down
Quoted 21 lines · David Vrabel
Quoted 20 lines · Wei Liu
Quoted 19 lines · David Vrabel
From: David Vrabel <[email protected]>
If the credit timer is left armed after calling
xen_netbk_remove_xenvif(), then it may fire and attempt to schedule the vif which will then oops asvif->netbk== NULL.This may happen both in the fatal error path and during normal disconnection from the front end.
The sequencing during shutdown is critical to ensure that: a)
vif->netbkdoesn't become unexpectedly NULL; and b) the net device/vif is not freed.1. Mark as unschedulable (
netif_carrier_off()).
2. Synchronously cancel the timer.
3. Remove the vif from the schedule list.
4. Remove it from it netback thread group.
5. Wait forvif->refcntto become 0.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by David Vrabel <[email protected]>You would need to reinitialize the timer in
xenvif_up, given that user mightifconfig vifX.X down; ifconfig vifX.X up.No. Deleted timers do not need to be reinitialized. The timer will be
What I really meant was to "rearm"...
Quoted 2 lines
armed as usual with
mod_timer()when credit is next exhausted.
Ah, ok.
Wei.
Re: [Xen-devel] [PATCH 2/2] xen-netback: cancel the credit timer when taking the vif down
In reply to David VrabelQuoted 21 lines · David Vrabel
Quoted 20 lines · Wei Liu
Quoted 19 lines · David Vrabel
From: David Vrabel <[email protected]>
If the credit timer is left armed after calling
xen_netbk_remove_xenvif(), then it may fire and attempt to schedule the vif which will then oops asvif->netbk== NULL.This may happen both in the fatal error path and during normal disconnection from the front end.
The sequencing during shutdown is critical to ensure that: a)
vif->netbkdoesn't become unexpectedly NULL; and b) the net device/vif is not freed.1. Mark as unschedulable (
netif_carrier_off()).
2. Synchronously cancel the timer.
3. Remove the vif from the schedule list.
4. Remove it from it netback thread group.
5. Wait forvif->refcntto become 0.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by David Vrabel <[email protected]>You would need to reinitialize the timer in
xenvif_up, given that user mightifconfig vifX.X down; ifconfig vifX.X up.No. Deleted timers do not need to be reinitialized. The timer will be
What I really meant was to "rearm"...
Quoted 2 lines
armed as usual with
mod_timer()when credit is next exhausted.
Ah, ok.
Wei.
Re: [Xen-devel] [PATCH 2/2] xen-netback: cancel the credit timer when taking the vif down
In reply to Wei LiuQuoted 21 lines
Quoted 1 line
Quoted 1 line · Wei Liu
Quoted 19 lines · David Vrabel
From: David Vrabel <[email protected]>
If the credit timer is left armed after calling
xen_netbk_remove_xenvif(), then it may fire and attempt to schedule the vif which will then oops asvif->netbk== NULL.This may happen both in the fatal error path and during normal disconnection from the front end.
The sequencing during shutdown is critical to ensure that: a)
vif->netbkdoesn't become unexpectedly NULL; and b) the net device/vif is not freed.1. Mark as unschedulable (
netif_carrier_off()).
2. Synchronously cancel the timer.
3. Remove the vif from the schedule list.
4. Remove it from it netback thread group.
5. Wait forvif->refcntto become 0.
Quoted 4 lines
Quoted 1 line
Signed-off-by David Vrabel <[email protected]>You would need to reinitialize the timer in
xenvif_up, given that user mightifconfig vifX.X down; ifconfig vifX.X up.
Which gets us to another aspect of the original fix that I don't think was considered: Is there anything preventing the interface to be brought back up after fatal_tx_err() shut it down?
Jan
Re: [PATCH 2/2] xen-netback: cancel the credit timer when taking the vif down
In reply to Wei LiuQuoted 21 lines
Quoted 1 line
Quoted 1 line · Wei Liu
Quoted 19 lines · David Vrabel
From: David Vrabel <[email protected]>
If the credit timer is left armed after calling
xen_netbk_remove_xenvif(), then it may fire and attempt to schedule the vif which will then oops asvif->netbk== NULL.This may happen both in the fatal error path and during normal disconnection from the front end.
The sequencing during shutdown is critical to ensure that: a)
vif->netbkdoesn't become unexpectedly NULL; and b) the net device/vif is not freed.1. Mark as unschedulable (
netif_carrier_off()).
2. Synchronously cancel the timer.
3. Remove the vif from the schedule list.
4. Remove it from it netback thread group.
5. Wait forvif->refcntto become 0.
Quoted 4 lines
Quoted 1 line
Signed-off-by David Vrabel <[email protected]>You would need to reinitialize the timer in
xenvif_up, given that user mightifconfig vifX.X down; ifconfig vifX.X up.
Which gets us to another aspect of the original fix that I don't think was considered: Is there anything preventing the interface to be brought back up after fatal_tx_err() shut it down?
Jan
Re: [PATCH 2/2] xen-netback: cancel the credit timer when taking the vif down
In reply to Jan BeulichQuoted 21 lines · Jan Beulich
Quoted 21 lines
Quoted 1 line
Quoted 1 line · Wei Liu
Quoted 19 lines · David Vrabel
From: David Vrabel <[email protected]>
If the credit timer is left armed after calling
xen_netbk_remove_xenvif(), then it may fire and attempt to schedule the vif which will then oops asvif->netbk== NULL.This may happen both in the fatal error path and during normal disconnection from the front end.
The sequencing during shutdown is critical to ensure that: a)
vif->netbkdoesn't become unexpectedly NULL; and b) the net device/vif is not freed.1. Mark as unschedulable (
netif_carrier_off()).
2. Synchronously cancel the timer.
3. Remove the vif from the schedule list.
4. Remove it from it netback thread group.
5. Wait forvif->refcntto become 0.
Quoted 9 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by David Vrabel <[email protected]>You would need to reinitialize the timer in
xenvif_up, given that user mightifconfig vifX.X down; ifconfig vifX.X up.Which gets us to another aspect of the original fix that I don't think was considered: Is there anything preventing the interface to be brought back up after
fatal_tx_err()shut it down?
I don't think so. Code could / should not prevent host admin from doing anything he wants - even it is re-enabling a malicious vif. ;-)
Wei.
Quoted 2 lines
Jan
Re: [Xen-devel] [PATCH 2/2] xen-netback: cancel the credit timer when taking the vif down
In reply to Jan BeulichQuoted 21 lines · Jan Beulich
Quoted 21 lines
Quoted 1 line
Quoted 1 line · Wei Liu
Quoted 19 lines · David Vrabel
From: David Vrabel <[email protected]>
If the credit timer is left armed after calling
xen_netbk_remove_xenvif(), then it may fire and attempt to schedule the vif which will then oops asvif->netbk== NULL.This may happen both in the fatal error path and during normal disconnection from the front end.
The sequencing during shutdown is critical to ensure that: a)
vif->netbkdoesn't become unexpectedly NULL; and b) the net device/vif is not freed.1. Mark as unschedulable (
netif_carrier_off()).
2. Synchronously cancel the timer.
3. Remove the vif from the schedule list.
4. Remove it from it netback thread group.
5. Wait forvif->refcntto become 0.
Quoted 9 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by David Vrabel <[email protected]>You would need to reinitialize the timer in
xenvif_up, given that user mightifconfig vifX.X down; ifconfig vifX.X up.Which gets us to another aspect of the original fix that I don't think was considered: Is there anything preventing the interface to be brought back up after
fatal_tx_err()shut it down?
I don't think so. Code could / should not prevent host admin from doing anything he wants - even it is re-enabling a malicious vif. ;-)
Wei.
Quoted 2 lines
Jan
Re: [PATCH 1/2] xen-netback: correctly return errors from netbk_count_requests()
In reply to David VrabelQuoted 13 lines · David Vrabel
From: David Vrabel <[email protected]>
netbk_count_requests()could detect an error, callnetbk_fatal_tx_error()but return 0. The vif may then be used afterwards (e.g., in a call tonetbk_tx_error().Since
netbk_fatal_tx_error()could setvif->refcntto 1, the vif may be freed immediately after the call tonetbk_fatal_tx_error()(e.g., if the vif is also removed).Netback thread Xenwatch thread
-------------------------------------------netbk_fatal_tx_err()netback_remove()
Quoted 8 lines
xenvif_disconnect() ... free_netdev()
netbk_tx_err()Oops!Signed-off-by Wei Liu <[email protected]>Signed-off-by Jan Beulich <[email protected]>Signed-off-by David Vrabel <[email protected]>
Although I would like to add a Tested-by: Christopher too if possible.
David (M) this should go to stable please.
Quoted 42 lines
--- drivers/net/xen-netback/netback.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)drivers/net/xen-netback/netback.c +4
-4@@ -911,13 +911,13 @@ static int netbk_count_requests(struct xenvif *vif,if (frags >= work_to_do) {netdev_err (vif->dev,"Need more frags\n" );netbk_fatal_tx_err (vif); -return -frags; +return -ENODATA ; }if (unlikely (frags >=MAX_SKB_FRAGS )) {netdev_err (vif->dev,"Too many frags\n" );netbk_fatal_tx_err (vif); -return -frags; +return -E2BIG ; } memcpy(txp, RING_GET_REQUEST(&vif->tx, cons + frags),@@ -925,7 +925,7 @@ static int netbk_count_requests(struct xenvif *vif,if (txp->size > first->size) {netdev_err (vif->dev,"Frag is bigger than frame.\n" );netbk_fatal_tx_err (vif); -return -frags; +return -EIO ; } first->size -= txp->size;@@ -935,7 +935,7 @@ static int netbk_count_requests(struct xenvif *vif,netdev_err (vif->dev,"txp->offset: %x, size: %u\n" , txp->offset, txp->size);netbk_fatal_tx_err (vif); -return -frags; +return -EINVAL ; } }while ((txp++)->flags & XEN_NETTXF_more_data);return frags;
Re: [PATCH 1/2] xen-netback: correctly return errors from netbk_count_requests()
In reply to David VrabelQuoted 13 lines · David Vrabel
From: David Vrabel <[email protected]>
netbk_count_requests()could detect an error, callnetbk_fatal_tx_error()but return 0. The vif may then be used afterwards (e.g., in a call tonetbk_tx_error().Since
netbk_fatal_tx_error()could setvif->refcntto 1, the vif may be freed immediately after the call tonetbk_fatal_tx_error()(e.g., if the vif is also removed).Netback thread Xenwatch thread
-------------------------------------------netbk_fatal_tx_err()netback_remove()
Quoted 8 lines
xenvif_disconnect() ... free_netdev()
netbk_tx_err()Oops!Signed-off-by Wei Liu <[email protected]>Signed-off-by Jan Beulich <[email protected]>Signed-off-by David Vrabel <[email protected]>
Although I would like to add a Tested-by: Christopher too if possible.
David (M) this should go to stable please.
Quoted 42 lines
--- drivers/net/xen-netback/netback.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)drivers/net/xen-netback/netback.c +4
-4@@ -911,13 +911,13 @@ static int netbk_count_requests(struct xenvif *vif,if (frags >= work_to_do) {netdev_err (vif->dev,"Need more frags\n" );netbk_fatal_tx_err (vif); -return -frags; +return -ENODATA ; }if (unlikely (frags >=MAX_SKB_FRAGS )) {netdev_err (vif->dev,"Too many frags\n" );netbk_fatal_tx_err (vif); -return -frags; +return -E2BIG ; } memcpy(txp, RING_GET_REQUEST(&vif->tx, cons + frags),@@ -925,7 +925,7 @@ static int netbk_count_requests(struct xenvif *vif,if (txp->size > first->size) {netdev_err (vif->dev,"Frag is bigger than frame.\n" );netbk_fatal_tx_err (vif); -return -frags; +return -EIO ; } first->size -= txp->size;@@ -935,7 +935,7 @@ static int netbk_count_requests(struct xenvif *vif,netdev_err (vif->dev,"txp->offset: %x, size: %u\n" , txp->offset, txp->size);netbk_fatal_tx_err (vif); -return -frags; +return -EINVAL ; } }while ((txp++)->flags & XEN_NETTXF_more_data);return frags;
Re: [PATCH 2/2] xen-netback: cancel the credit timer when taking the vif down
In reply to David VrabelQuoted 13 lines · David Vrabel
From: David Vrabel <[email protected]>
If the credit timer is left armed after calling
xen_netbk_remove_xenvif(), then it may fire and attempt to schedule the vif which will then oops asvif->netbk== NULL.This may happen both in the fatal error path and during normal disconnection from the front end.
The sequencing during shutdown is critical to ensure that: a)
vif->netbkdoesn't become unexpectedly NULL; and b) the net device/vif is not freed.
Quoted 7 lines
1. Mark as unschedulable (
netif_carrier_off()).
2. Synchronously cancel the timer.
3. Remove the vif from the schedule list.
4. Remove it from it netback thread group.
5. Wait forvif->refcntto become 0.Signed-off-by David Vrabel <[email protected]>
Was this one also Reported-by Christopher S. Aker or was it just discovered in the process of investigating?
Another stable candidate please Dave.
Quoted 25 lines
--- drivers/net/xen-netback/interface.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)drivers/net/xen-netback/interface.c +1
-2@@ -132,6 +132,7 @@ static void xenvif_up(struct xenvif *vif)static void xenvif_down (struct xenvif *vif) {disable_irq (vif->irq); +del_timer_sync (&vif->credit_timeout);xen_netbk_deschedule_xenvif (vif);xen_netbk_remove_xenvif (vif); }@@ -363,8 +364,6 @@ void xenvif_disconnect(struct xenvif *vif)atomic_dec (&vif->refcnt);wait_event (vif->waiting_to_free,atomic_read (&vif->refcnt) ==0 ); -del_timer_sync (&vif->credit_timeout); -if (vif->irq)unbind_from_irqhandler (vif->irq, vif);
Re: [PATCH 2/2] xen-netback: cancel the credit timer when taking the vif down
In reply to David VrabelQuoted 13 lines · David Vrabel
From: David Vrabel <[email protected]>
If the credit timer is left armed after calling
xen_netbk_remove_xenvif(), then it may fire and attempt to schedule the vif which will then oops asvif->netbk== NULL.This may happen both in the fatal error path and during normal disconnection from the front end.
The sequencing during shutdown is critical to ensure that: a)
vif->netbkdoesn't become unexpectedly NULL; and b) the net device/vif is not freed.
Quoted 7 lines
1. Mark as unschedulable (
netif_carrier_off()).
2. Synchronously cancel the timer.
3. Remove the vif from the schedule list.
4. Remove it from it netback thread group.
5. Wait forvif->refcntto become 0.Signed-off-by David Vrabel <[email protected]>
Was this one also Reported-by Christopher S. Aker or was it just discovered in the process of investigating?
Another stable candidate please Dave.
Quoted 25 lines
--- drivers/net/xen-netback/interface.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)drivers/net/xen-netback/interface.c +1
-2@@ -132,6 +132,7 @@ static void xenvif_up(struct xenvif *vif)static void xenvif_down (struct xenvif *vif) {disable_irq (vif->irq); +del_timer_sync (&vif->credit_timeout);xen_netbk_deschedule_xenvif (vif);xen_netbk_remove_xenvif (vif); }@@ -363,8 +364,6 @@ void xenvif_disconnect(struct xenvif *vif)atomic_dec (&vif->refcnt);wait_event (vif->waiting_to_free,atomic_read (&vif->refcnt) ==0 ); -del_timer_sync (&vif->credit_timeout); -if (vif->irq)unbind_from_irqhandler (vif->irq, vif);
Re: [PATCH 2/2] xen-netback: cancel the credit timer when taking the vif down
Quoted 20 lines · Ian Campbell
Quoted 19 lines · David Vrabel
From: David Vrabel <[email protected]>
If the credit timer is left armed after calling
xen_netbk_remove_xenvif(), then it may fire and attempt to schedule the vif which will then oops asvif->netbk== NULL.This may happen both in the fatal error path and during normal disconnection from the front end.
The sequencing during shutdown is critical to ensure that: a)
vif->netbkdoesn't become unexpectedly NULL; and b) the net device/vif is not freed.1. Mark as unschedulable (
netif_carrier_off()).
2. Synchronously cancel the timer.
3. Remove the vif from the schedule list.
4. Remove it from it netback thread group.
5. Wait forvif->refcntto become 0.
Quoted 7 lines
Quoted 1 line
Signed-off-by David Vrabel <[email protected]>Acked-by Ian Campbell <[email protected]>Was this one also Reported-by Christopher S. Aker or was it just discovered in the process of investigating?
His bug report did prod me to look into this, so I think it is worth adding
Wei.
Quoted 34 lines
Another stable candidate please Dave.
Quoted 17 lines
--- drivers/net/xen-netback/interface.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)drivers/net/xen-netback/interface.c +1
-0@@ -132,6 +132,7 @@ static void xenvif_up(struct xenvif *vif)static void xenvif_down (struct xenvif *vif) {disable_irq (vif->irq); +del_timer_sync (&vif->credit_timeout);xen_netbk_deschedule_xenvif (vif);xen_netbk_remove_xenvif (vif); }drivers/net/xen-netback/interface.c void xenvif_disconnect(struct xenvif *vif) · line 369
Quoted 8 lines
drivers/net/xen-netback/interface.c +0
-2@@ -363,8 +364,6 @@ void xenvif_disconnect(struct xenvif *vif)atomic_dec (&vif->refcnt);wait_event (vif->waiting_to_free,atomic_read (&vif->refcnt) ==0 ); -del_timer_sync (&vif->credit_timeout); -if (vif->irq)unbind_from_irqhandler (vif->irq, vif);_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [Xen-devel] [PATCH 2/2] xen-netback: cancel the credit timer when taking the vif down
In reply to Ian CampbellQuoted 20 lines · Ian Campbell
Quoted 19 lines · David Vrabel
From: David Vrabel <[email protected]>
If the credit timer is left armed after calling
xen_netbk_remove_xenvif(), then it may fire and attempt to schedule the vif which will then oops asvif->netbk== NULL.This may happen both in the fatal error path and during normal disconnection from the front end.
The sequencing during shutdown is critical to ensure that: a)
vif->netbkdoesn't become unexpectedly NULL; and b) the net device/vif is not freed.1. Mark as unschedulable (
netif_carrier_off()).
2. Synchronously cancel the timer.
3. Remove the vif from the schedule list.
4. Remove it from it netback thread group.
5. Wait forvif->refcntto become 0.
Quoted 7 lines
Quoted 1 line
Signed-off-by David Vrabel <[email protected]>Acked-by Ian Campbell <[email protected]>Was this one also Reported-by Christopher S. Aker or was it just discovered in the process of investigating?
His bug report did prod me to look into this, so I think it is worth adding
Wei.
Quoted 34 lines
Another stable candidate please Dave.
Quoted 17 lines
--- drivers/net/xen-netback/interface.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)drivers/net/xen-netback/interface.c +1
-0@@ -132,6 +132,7 @@ static void xenvif_up(struct xenvif *vif)static void xenvif_down (struct xenvif *vif) {disable_irq (vif->irq); +del_timer_sync (&vif->credit_timeout);xen_netbk_deschedule_xenvif (vif);xen_netbk_remove_xenvif (vif); }drivers/net/xen-netback/interface.c void xenvif_disconnect(struct xenvif *vif) · line 369
Quoted 8 lines
drivers/net/xen-netback/interface.c +0
-2@@ -363,8 +364,6 @@ void xenvif_disconnect(struct xenvif *vif)atomic_dec (&vif->refcnt);wait_event (vif->waiting_to_free,atomic_read (&vif->refcnt) ==0 ); -del_timer_sync (&vif->credit_timeout); -if (vif->irq)unbind_from_irqhandler (vif->irq, vif);_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
David Miller
maintainerFrom: David Vrabel <[email protected]>
Date: Thu, 14 Feb 2013 13:18:56 +0000
Quoted 4 lines
These two netback patches fix oopes that may occur during shutdown or if a specific fatal error occurs.
They are stable candidants.
Both applied and queued up for -stable, thanks.
David Miller
maintainerFrom: David Vrabel <[email protected]>
Date: Thu, 14 Feb 2013 13:18:56 +0000
Quoted 4 lines
These two netback patches fix oopes that may occur during shutdown or if a specific fatal error occurs.
They are stable candidants.
Both applied and queued up for -stable, thanks.
Christopher S. Aker
Tested-byQuoted 2 lines · David Vrabel
These two netback patches fix oopes that may occur during shutdown or if a specific fatal error occurs.
Quoted 2 lines · Ian Campbell
Although I would like to add a Tested-by: Christopher too if possible.
We are no longer able to trigger the last OOPs we provided by downing the vif. Further testing of the other issues will take time, but we're deploying a few patched hosts now.
Thanks!
-Chris
Quoted 9 lines · Christopher S. Aker
Quoted 2 lines · David Vrabel
These two netback patches fix oopes that may occur during shutdown or if a specific fatal error occurs.
Quoted 2 lines · Ian Campbell
Although I would like to add a Tested-by: Christopher too if possible.
Thank you!
Quoted 3 lines
We are no longer able to trigger the last OOPs we provided by downing the vif. Further testing of the other issues will take time, but we're deploying a few patched hosts now.
Great, please let me know how you get on.
Ian.
Quoted 9 lines · Christopher S. Aker
Quoted 2 lines · David Vrabel
These two netback patches fix oopes that may occur during shutdown or if a specific fatal error occurs.
Quoted 2 lines · Ian Campbell
Although I would like to add a Tested-by: Christopher too if possible.
Thank you!
Quoted 3 lines
We are no longer able to trigger the last OOPs we provided by downing the vif. Further testing of the other issues will take time, but we're deploying a few patched hosts now.
Great, please let me know how you get on.
Ian.