All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xen-netfront: drop skb when skb->len > 65535
@ 2013-03-01 16:31 Wei Liu
  2013-03-01 16:34 ` Wei Liu
  2013-03-01 16:48 ` Jan Beulich
  0 siblings, 2 replies; 12+ messages in thread
From: Wei Liu @ 2013-03-01 16:31 UTC (permalink / raw)
  To: xen-devel
  Cc: ij, ian.campbell, konrad.wilk, npegg, annie.li, jbeulich, Wei Liu

The `size' field of Xen network wired format is uint16_t, anything bigger than
65535 will cause overflow.

The punishment introduced by XSA-39 is quite harsh - DomU is disconnected when
it's discovered to be sending corrupted skbs. However, it looks like Linux
kernel will generate some bad skbs sometimes, so drop those skbs before
sending to over netback to avoid being disconnected.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
 drivers/net/xen-netfront.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index 5527663..284059b 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -547,6 +547,18 @@ static int xennet_start_xmit(struct sk_buff *skb, struct net_device *dev)
 	unsigned int len = skb_headlen(skb);
 	unsigned long flags;
 
+	/*
+	 * wired format of xen_netif_tx_request only supports skb->len
+	 * < 64K, because size field in xen_netif_tx_request is
+	 * uint16_t.
+	 */
+	if (unlikely(skb->len > (uint16_t)(~((uint16_t)0)))) {
+		net_alert_ratelimited(
+			"xennet: skb->len = %d, too big for wired format\n",
+			skb->len);
+		goto drop;
+	}
+
 	slots = DIV_ROUND_UP(offset + len, PAGE_SIZE) +
 		xennet_count_skb_frag_slots(skb);
 	if (unlikely(slots > MAX_SKB_FRAGS + 1)) {
-- 
1.7.10.4

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

end of thread, other threads:[~2013-03-06 18:04 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-01 16:31 [PATCH] xen-netfront: drop skb when skb->len > 65535 Wei Liu
2013-03-01 16:34 ` Wei Liu
2013-03-01 16:48 ` Jan Beulich
2013-03-01 17:00   ` Wei Liu
2013-03-02  2:54     ` Ian Campbell
2013-03-02 13:32       ` Wei Liu
2013-03-03  5:02         ` annie li
2013-03-06 17:20         ` Nick Pegg
2013-03-06 17:31           ` Wei Liu
2013-03-06 17:57             ` Jacek Milewicz
2013-03-06 18:04               ` Wei Liu
2013-03-03  4:13       ` annie li

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.