From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jesper Dangaard Brouer Subject: Re: [net-next PATCH] net: ipv4: fix listify ip_rcv_finish in case of forwarding Date: Wed, 11 Jul 2018 22:15:52 +0200 Message-ID: <20180711221552.62f90976@redhat.com> References: <153132125549.13161.16380200872856218805.stgit@firesoul> <539bb5cc-ceae-427d-5a74-f79d752184d9@solarflare.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Cc: , brouer@redhat.com To: Edward Cree Return-path: Received: from mx3-rdu2.redhat.com ([66.187.233.73]:57954 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2390100AbeGKUVx (ORCPT ); Wed, 11 Jul 2018 16:21:53 -0400 In-Reply-To: <539bb5cc-ceae-427d-5a74-f79d752184d9@solarflare.com> Sender: netdev-owner@vger.kernel.org List-ID: On Wed, 11 Jul 2018 16:41:35 +0100 Edward Cree wrote: > On 11/07/18 16:01, Jesper Dangaard Brouer wrote: > > 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 > Acked-by: Edward Cree > > But it feels weird and asymmetric to only NULL skb->next (not ->prev), and >  to have to do this by hand rather than e.g. being able to use >  list_del_init(&skb->list).  Hopefully this can be revisited once >  sch_direct_xmit() has been changed to use the list_head rather than SKB >  special lists. I cannot use list_del_init(&skb->list) it would also break. This is a fix, and this code should be revisited. The reason I used the list_del() + skb->next=NULL, combo, is to keep as much as possible of the list-poisoning, e.g. 'prev' will be LIST_POISON2. -- Best regards, Jesper Dangaard Brouer MSc.CS, Principal Kernel Engineer at Red Hat LinkedIn: http://www.linkedin.com/in/brouer