netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [net-next PATCH] net: ipv4: fix listify ip_rcv_finish in case of forwarding
@ 2018-07-11 15:01 Jesper Dangaard Brouer
  2018-07-11 15:41 ` Edward Cree
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Jesper Dangaard Brouer @ 2018-07-11 15:01 UTC (permalink / raw)
  To: Edward Cree, netdev, Jesper Dangaard Brouer

In commit 5fa12739a53d ("net: ipv4: listify ip_rcv_finish") calling
dst_input(skb) was split-out.  The ip_sublist_rcv_finish() just calls
dst_input(skb) in a loop.

The problem is that ip_sublist_rcv_finish() forgot to remove the SKB
from the list before invoking dst_input().  Further more we need to
clear skb->next as other parts of the network stack use another kind
of SKB lists for xmit_more (see dev_hard_start_xmit).

A crash occurs if e.g. dst_input() invoke ip_forward(), which calls
dst_output()/ip_output() that eventually calls __dev_queue_xmit() +
sch_direct_xmit(), and a crash occurs in validate_xmit_skb_list().

This patch only fixes the crash, but there is a huge potential for
a performance boost if we can pass an SKB-list through to ip_forward.

Fixes: 5fa12739a53d ("net: ipv4: listify ip_rcv_finish")
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
---
Only driver sfc actually uses this, but I don't have this NIC, so I
tested this on mlx5, with my own changes to make it use netif_receive_skb_list(),
but I'm not ready to upstream the mlx5 driver change yet.

 net/ipv4/ip_input.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c
index 1a3b6f32b1c9..3196cf58f418 100644
--- a/net/ipv4/ip_input.c
+++ b/net/ipv4/ip_input.c
@@ -530,8 +530,14 @@ static void ip_sublist_rcv_finish(struct list_head *head)
 {
 	struct sk_buff *skb, *next;
 
-	list_for_each_entry_safe(skb, next, head, list)
+	list_for_each_entry_safe(skb, next, head, list) {
+		list_del(&skb->list);
+		/* Handle ip{6}_forward case, as sch_direct_xmit have
+		 * another kind of SKB-list usage (see validate_xmit_skb_list)
+		 */
+		skb->next = NULL;
 		dst_input(skb);
+	}
 }
 
 static void ip_list_rcv_finish(struct net *net, struct sock *sk,

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

end of thread, other threads:[~2018-07-30 16:14 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-11 15:01 [net-next PATCH] net: ipv4: fix listify ip_rcv_finish in case of forwarding Jesper Dangaard Brouer
2018-07-11 15:41 ` Edward Cree
2018-07-11 20:15   ` Jesper Dangaard Brouer
2018-07-11 19:05 ` Saeed Mahameed
2018-07-11 20:06   ` Jesper Dangaard Brouer
2018-07-12 20:10     ` Or Gerlitz
2018-07-13 11:08       ` Jesper Dangaard Brouer
2018-07-13 14:19       ` Edward Cree
2018-07-13 16:04         ` Jesper Dangaard Brouer
2018-07-13 18:14         ` Eric Dumazet
2018-07-30 14:38     ` Or Gerlitz
2018-07-12 23:41 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).