xen-netfront: XSA-403 follow-on
Subsystems (3)
cover xen-netfront: XSA-403 follow-on
While investigating the XSA, I did notice a few more things. The two patches aren't really dependent on one another.
1: remove leftover call to xennet_tx_buf_gc() 2: re-order error checks in xennet_get_responses()
Jan
PATCH 1/2 xen-netfront: remove leftover call to xennet_tx_buf_gc()
In talk_to_netback(), called earlier from xennet_connect(), queues and shared rings were just re-initialized, so all this function call could result in is setting ->broken (again) right away in case any unconsumed responses were found.
drivers/net/xen-netfront.c +0 -4
@@ -2464,10 +2464,6 @@ static int xennet_connect(struct net_devif (queue->tx_irq != queue->rx_irq)notify_remote_via_irq (queue->rx_irq); -spin_lock_irq (&queue->tx_lock); -xennet_tx_buf_gc (queue); -spin_unlock_irq (&queue->tx_lock); -spin_lock_bh (&queue->rx_lock);xennet_alloc_rx_buffers (queue);spin_unlock_bh (&queue->rx_lock);
PATCH 2/2 xen-netfront: re-order error checks in xennet_get_responses()
In reply to Jan BeulichCheck the retrieved grant reference first; there's no point trying to have xennet_move_rx_slot() move invalid data (and further defer recognition of the issue, likely making diagnosis yet more difficult).
---
I question the log message claiming a bad ID (which is how I read its wording): rx->id isn't involved in determining ref. I don't see what else to usefully log, though, yet making the message just "Bad rx response" also doesn't look very useful.
drivers/net/xen-netfront.c +10 -10
@@ -1043,16 +1043,6 @@ static int xennet_get_responses(struct n }for (;;) { -if (unlikely (rx->status <0 || - rx->offset + rx->status >XEN_PAGE_SIZE )) { -if (net_ratelimit ()) -dev_warn (dev,"rx->offset: %u, size: %d\n" , - rx->offset, rx->status); -xennet_move_rx_slot (queue, skb, ref); - err = -EINVAL ; - goto next; - } -/* * This definitely indicates a bug, either in this driver or in * the backend driver. In future this should flag the bad
@@ -1065,6 +1055,16 @@ static int xennet_get_responses(struct n err = -EINVAL ; goto next; } + +if (unlikely (rx->status <0 || + rx->offset + rx->status >XEN_PAGE_SIZE )) { +if (net_ratelimit ()) +dev_warn (dev,"rx->offset: %u, size: %d\n" , + rx->offset, rx->status); +xennet_move_rx_slot (queue, skb, ref); + err = -EINVAL ; + goto next; + }if (!gnttab_end_foreign_access_ref (ref)) { dev_alert(dev,
Paolo Abeni
maintainerRe: [PATCH net-next 2/2] xen-netfront: re-order error checks in xennet_get_responses()
Quoted 10 lines · Jan Beulich
Check the retrieved grant reference first; there's no point trying to have
xennet_move_rx_slot()move invalid data (and further defer recognition of the issue, likely making diagnosis yet more difficult).Signed-off-by Jan Beulich <[email protected]>---
I question the log message claiming a bad ID (which is how I read its wording):rx->idisn't involved in determining ref. I don't see what else to usefully log, though, yet making the message just "Bad rx response" also doesn't look very useful.
For the records, I (mis-)read that log message differently, claiming there is a bad RX response, and specifying the ID of such response, which may or may be not useful to diagnose where/when the problem happens.
Cheers,
Paolo
This series was applied to netdev/net-next.git (master) by Paolo Abeni <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (master) by Paolo Abeni <[email protected]>:
Quoted 7 lines · On Wed, 13 Jul 2022 11:18:03 +0200 you wrote:
While investigating the XSA, I did notice a few more things. The two patches aren't really dependent on one another.
1: remove leftover call to
xennet_tx_buf_gc()2: re-order error checks inxennet_get_responses()Jan
Here is the summary with links:
- [net-next,1/2] xen-netfront: remove leftover call to xennet_tx_buf_gc()
https://git.kernel.org/netdev/net-next/c/ad39bafda736
- [net-next,2/2] xen-netfront: re-order error checks in xennet_get_responses() (no matching commit)
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html