From: dho@fastly.com Subject: [PATCH net] xps: clear skb sender_cpu before tee Date: Tue, 6 Oct 2015 12:38:46 -0700 Message-ID: <1444160326-9375-1-git-send-email-dho@fastly.com> Cc: "Devon H. O'Dell" To: netdev@vger.kernel.org Return-path: Received: from mail-pa0-f53.google.com ([209.85.220.53]:33947 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752397AbbJFTi5 (ORCPT ); Tue, 6 Oct 2015 15:38:57 -0400 Received: by padhy16 with SMTP id hy16so78687371pad.1 for ; Tue, 06 Oct 2015 12:38:57 -0700 (PDT) Sender: netdev-owner@vger.kernel.org List-ID: From: "Devon H. O'Dell" The netfilter tee code does not clear skb->sender_cpu after copying the skb. When both CONFIG_XPS and CONFIG_NET_RX_BUSY_POLL are active, it is possible for a tee rule to duplicate a skb from input, leaving its its napi queue id set. Because this field is shared in a union with sender_cpu, we can get an invalid offset in __netdev_pick_tx when the napi_id exceeds the number of logical CPUs in the system. This yields the following panic: BUG: unable to handle kernel paging request at 0000333300000000 IP: [] __netdev_pick_tx+0x6d/0x150 PGD 0 Oops: 0000 [#1] SMP Call Trace: [] ixgbe_select_queue+0xe2/0x190 [ixgbe] [] netdev_pick_tx+0x6b/0x100 [] __dev_queue_xmit+0x84/0x540 [] ? ipt_do_table+0x208/0x5f0 [] dev_queue_xmit_sk+0x13/0x20 [] macvlan_start_xmit+0xb1/0x150 [macvlan] [] dev_hard_start_xmit+0x22b/0x3d0 [] ? validate_xmit_skb.isra.98.part.99+0x29/0x2c0 [] __dev_queue_xmit+0x461/0x540 [] dev_queue_xmit_sk+0x13/0x20 [] ip_finish_output+0x258/0x8c0 [] ip_output+0x6b/0xc0 [] ? ip_finish_output2+0x370/0x370 [] ip_local_out_sk+0x3a/0x50 [] tee_tg4+0x186/0x208 [xt_TEE] [] ipt_do_table+0x2fb/0x5f0 [] ? tcp_rcv_established+0x4b2/0x800 [] ? ipt_do_table+0x208/0x5f0 [] ? ixgbe_xmit_frame_ring+0x415/0xe20 [ixgbe] [] iptable_mangle_hook+0x4b/0x140 [] nf_iterate+0x7f/0xb0 [] nf_hook_slow+0xa4/0x110 [] ip_rcv+0x2d1/0x3b0 ... Investigation shows that Eric Dumazet fixed a similar issue in commit c29390c6dfeee094 ("xps: must clear sender_cpu before forwarding"), which was introduced by his commit 2bd82484bb4c5db1 ("xps: fix xps for stacked devices"). Thanks-to: Eric Hoffman Thanks-to: Grant Zhang Tested-by: Jonathan Steinert Signed-off-by: Devon H. O'Dell --- net/ipv4/netfilter/nf_dup_ipv4.c | 2 ++ net/ipv6/netfilter/nf_dup_ipv6.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/net/ipv4/netfilter/nf_dup_ipv4.c b/net/ipv4/netfilter/nf_dup_ipv4.c index 2d79e6e..2f2a79b 100644 --- a/net/ipv4/netfilter/nf_dup_ipv4.c +++ b/net/ipv4/netfilter/nf_dup_ipv4.c @@ -81,6 +81,8 @@ void nf_dup_ipv4(struct sk_buff *skb, unsigned int hooknum, if (skb == NULL) return; + skb_sender_cpu_clear(skb); + #if IS_ENABLED(CONFIG_NF_CONNTRACK) /* Avoid counting cloned packets towards the original connection. */ nf_conntrack_put(skb->nfct); diff --git a/net/ipv6/netfilter/nf_dup_ipv6.c b/net/ipv6/netfilter/nf_dup_ipv6.c index c8ab626..03f0a15 100644 --- a/net/ipv6/netfilter/nf_dup_ipv6.c +++ b/net/ipv6/netfilter/nf_dup_ipv6.c @@ -70,6 +70,8 @@ void nf_dup_ipv6(struct sk_buff *skb, unsigned int hooknum, if (skb == NULL) return; + skb_sender_cpu_clear(skb); + #if IS_ENABLED(CONFIG_NF_CONNTRACK) nf_conntrack_put(skb->nfct); skb->nfct = &nf_ct_untracked_get()->ct_general; -- 2.1.4