Skip to contentSkip to conversation

xen-netfront: XSA-403 follow-on

PATCH In review Jan Beulich 3 participants 5 messages Jul 13, 2022 – Jul 14, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

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

#1 lore raw

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_dev
 		if (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);
#2 lore raw

PATCH 2/2 xen-netfront: re-order error checks in xennet_get_responses()

In reply to 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).

---
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,
maintainer
#3 lore raw

Re: [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).

---
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.

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

#4 lore raw
In reply to Jan Beulich
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 in xennet_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