bounce_skb() is an open-coded skb_copy() for skbs whose data isn't
page-aligned, and it has the same BUG_ON(skb_copy_bits()).
skb_copy_bits() only fails when the skb's lengths don't add up.
bounce_skb() already frees the new skb and returns NULL when the
allocation comes back misaligned, and xennet_start_xmit() drops the
packet in that case. Take the same path, with a
DEBUG_NET_WARN_ON_ONCE() for debug kernels.
Assisted-by: LLM
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
drivers/net/xen-netfront.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index fdcb91042f29..17811d81937c 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -695,7 +695,12 @@ static struct sk_buff *bounce_skb(const struct sk_buff *skb)
/* Set the tail pointer and length */
skb_put(n, skb->len);
- BUG_ON(skb_copy_bits(skb, -headerlen, n->head, headerlen + skb->len));
+ if (unlikely(skb_copy_bits(skb, -headerlen, n->head,
+ headerlen + skb->len))) {
+ DEBUG_NET_WARN_ON_ONCE(1);
+ kfree_skb(n);
+ return NULL;
+ }
skb_copy_header(n, skb);
return n;
--
2.55.0