From: Joao Martins <joao.martins@neclab.eu>
To: xen-devel@lists.xenproject.org, netdev@vger.kernel.org
Cc: wei.liu2@citrix.com, ian.campbell@citrix.com,
Joao Martins <joao.martins@neclab.eu>,
david.vrabel@citrix.com, boris.ostrovsky@oracle.com
Subject: [RFC PATCH 08/13] xen-netback: clone skb if skb->xmit_more is set
Date: Tue, 12 May 2015 19:18:32 +0200 [thread overview]
Message-ID: <1431451117-70051-9-git-send-email-joao.martins@neclab.eu> (raw)
In-Reply-To: <1431451117-70051-1-git-send-email-joao.martins@neclab.eu>
On xenvif_start_xmit() we have an additional queue to the netback RX
kthread that will sends the packet. When using burst>1 pktgen sets
skb->xmit_more to tell the driver that there more skbs in the queue.
However, pktgen transmits the same skb <burst> times, which leads to
the BUG below. Long story short adding the same skb in the rx_queue
queue leads to crash. Specifically, having pktgen running with burst=2
what happens is: when we queue the second skb (that is the same as
the first queued skb), the list will have the tail element with skb->prev
which is the skb itself. On skb_unlink (i.e. when dequeueing the skb)
skb->prev will become NULL, but still having list->next pointing to the
unlinked skb. Because of this skb_peek will still return an skb, which
will redo the skb_unlink trying to set (skb->prev)->next where skb->prev
is now NULL, thus leading to the crash (trace below).
I'm not sure what the best way to fix this but since it's only happening
when we use pktgen with burst>1: I chose doing an skb_clone when we don't
use persistent grants and skb->xmit_more flag is set, and when
CONFIG_NET_PKTGEN is compiled builtin.
BUG: unable to handle kernel NULL pointer dereference at 0000000000000008
IP: [<ffffffffa01dbcdc>] xenvif_rx_dequeue+0x7c/0x120 [xen_netback]
PGD 0
Oops: 0002 [#1] SMP
CPU: 1 PID: 10391 Comm: vif510.1-q0-gue Not tainted 4.0.0-rc2-net-next+
task: ffff88003b0ce400 ti: ffff880008538000 task.ti: ffff880008538000
RIP: e030:[<ffffffffa01dbcdc>] [<ffffffffa01dbcdc>]
xenvif_rx_dequeue+0x7c/0x120 [xen_netback]
RSP: e02b:ffff88000853bde8 EFLAGS: 00010006
RAX: 0000000000000000 RBX: ffffc9000212e000 RCX: 00000000000000e4
RDX: 0000000000000000 RSI: ffff88003b0c0200 RDI: ffffc90002139a24
RBP: ffff88000853bdf8 R08: ffff880008538000 R09: 0000000000000000
R10: aaaaaaaaaaaaaaaa R11: 0000000000000000 R12: ffff8800089a6400
R13: ffffc9000212e000 R14: ffffc90002139a10 R15: 0000000000000000
FS: 0000000000000000(0000) GS:ffff88003f700000(0000)
knlGS:ffff88003f700000
CS: e033 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000008 CR3: 000000000260b000 CR4: 0000000000042660
Stack:
ffff88000853be48 ffff88000853be30 ffff88000853beb8 ffffffffa01e19ea
ffff88000853be60 ffff88003b0ce400 ffff88003ba418c0 ffffc900021399c0
0000000000000000 ffff88000853be30 ffff88000853be30 ffff000000000000
Call Trace:
[<ffffffffa01e19ea>] xenvif_kthread_guest_rx+0x26a/0x6e0 [xen_netback]
[<ffffffffa01e1780>] ? xenvif_map_frontend_rings+0x110/0x110 [xen_netback]
[<ffffffff8111ae9b>] kthread+0x11b/0x150
[<ffffffff81120000>] ? clean_sort_range+0x170/0x2f0
[<ffffffff8111ad80>] ? kthread_stop+0x230/0x230
[<ffffffff81d6957c>] ret_from_fork+0x7c/0xb0
[<ffffffff8111ad80>] ? kthread_stop+0x230/0x230
Code: 01 48 83 05 9e f5 00 00 01 49 8b 44 24 08 49 8b 14 24 49 c7 44 24 08
00 00 00 00 49 c7 04 24 00 00 00 00 48 83 05 84 f5 00 00 01 <48> 89 42 08
48 89 10 41 8b 84 24 80 00 00 00 29 83 2c ba 00 00
RIP [<ffffffffa01dbcdc>] xenvif_rx_dequeue+0x7c/0x120 [xen_netback]
RSP <ffff88000853bde8>
CR2: 0000000000000008
---[ end trace b3caaf6875c8a975 ]---
Signed-off-by: Joao Martins <joao.martins@neclab.eu>
---
drivers/net/xen-netback/interface.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/net/xen-netback/interface.c b/drivers/net/xen-netback/interface.c
index dfe2b7b..5748ba5 100644
--- a/drivers/net/xen-netback/interface.c
+++ b/drivers/net/xen-netback/interface.c
@@ -170,6 +170,15 @@ static int xenvif_start_xmit(struct sk_buff *skb, struct net_device *dev)
cb->expires = jiffies + vif->drain_timeout;
if (!queue->vif->persistent_grants) {
+#ifdef CONFIG_NET_PKTGEN
+ if (skb->xmit_more) {
+ struct sk_buff *nskb;
+
+ nskb = skb_clone(skb, GFP_ATOMIC | __GFP_NOWARN);
+ dev_kfree_skb(skb);
+ skb = nskb;
+ }
+#endif
xenvif_rx_queue_tail(queue, skb);
xenvif_kick_thread(queue);
} else if (xenvif_rx_map(queue, skb)) {
--
2.1.3
next prev parent reply other threads:[~2015-05-12 17:22 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-12 17:18 [RFC PATCH 00/13] Persistent grant maps for xen net drivers Joao Martins
2015-05-12 17:18 ` [RFC PATCH 01/13] xen-netback: add persistent grant tree ops Joao Martins
2015-05-12 17:18 ` [RFC PATCH 02/13] xen-netback: xenbus feature persistent support Joao Martins
2015-05-19 15:19 ` Wei Liu
[not found] ` <20150519151929.GA26335@zion.uk.xensource.com>
2015-05-22 10:24 ` Joao Martins
2015-05-12 17:18 ` [RFC PATCH 03/13] xen-netback: implement TX persistent grants Joao Martins
2015-05-19 15:23 ` Wei Liu
[not found] ` <20150519152342.GB26335@zion.uk.xensource.com>
2015-05-22 10:24 ` Joao Martins
[not found] ` <30CF0FF9-3B1D-48AF-AFB4-73E20C404357@neclab.eu>
2015-06-02 14:53 ` Wei Liu
[not found] ` <20150602145359.GP19403@zion.uk.xensource.com>
2015-06-03 17:07 ` Joao Martins
[not found] ` <B1B43019-3C94-4FBA-9139-7683FEC2901E@neclab.eu>
2015-06-07 12:04 ` Wei Liu
2015-05-12 17:18 ` [RFC PATCH 04/13] xen-netback: implement RX " Joao Martins
2015-05-19 15:32 ` Wei Liu
[not found] ` <20150519153205.GC26335@zion.uk.xensource.com>
2015-05-22 10:25 ` Joao Martins
[not found] ` <65A385A5-4D11-4032-BB1B-82180AF76477@neclab.eu>
2015-06-02 15:07 ` Wei Liu
[not found] ` <20150602150704.GQ19403@zion.uk.xensource.com>
2015-06-03 17:08 ` Joao Martins
2015-05-12 17:18 ` [RFC PATCH 05/13] xen-netback: refactor xenvif_rx_action Joao Martins
2015-05-19 15:32 ` Wei Liu
2015-05-12 17:18 ` [RFC PATCH 06/13] xen-netback: copy buffer on xenvif_start_xmit() Joao Martins
2015-05-19 15:35 ` Wei Liu
[not found] ` <20150519153558.GE26335@zion.uk.xensource.com>
2015-05-22 10:26 ` Joao Martins
[not found] ` <915BCC85-25D1-4960-A1BA-0C6459ABC953@neclab.eu>
2015-06-02 15:10 ` Wei Liu
2015-05-12 17:18 ` [RFC PATCH 07/13] xen-netback: add persistent tree counters to debugfs Joao Martins
2015-05-19 15:36 ` Wei Liu
2015-05-12 17:18 ` Joao Martins [this message]
2015-05-19 15:36 ` [RFC PATCH 08/13] xen-netback: clone skb if skb->xmit_more is set Wei Liu
[not found] ` <20150519153613.GG26335@zion.uk.xensource.com>
2015-05-22 17:14 ` Joao Martins
2015-05-12 17:18 ` [RFC PATCH 09/13] xen-netfront: move grant_{ref, page} to struct grant Joao Martins
2015-05-18 15:44 ` David Vrabel
[not found] ` <555A08F4.1030202@citrix.com>
2015-05-19 10:19 ` Joao Martins
2015-05-12 17:18 ` [RFC PATCH 10/13] xen-netfront: refactor claim/release grant Joao Martins
2015-05-18 15:48 ` David Vrabel
[not found] ` <555A09D1.50902@citrix.com>
2015-05-19 10:19 ` Joao Martins
2015-05-12 17:18 ` [RFC PATCH 11/13] xen-netfront: feature-persistent xenbus support Joao Martins
2015-05-18 15:51 ` David Vrabel
[not found] ` <555A0A95.20409@citrix.com>
2015-05-19 10:19 ` Joao Martins
2015-05-12 17:18 ` [RFC PATCH 12/13] xen-netfront: implement TX persistent grants Joao Martins
2015-05-18 15:55 ` David Vrabel
[not found] ` <555A0B5D.3090505@citrix.com>
2015-05-19 10:20 ` Joao Martins
[not found] ` <77896F5F-DC2C-4F2A-9BB3-CE5F404DCECC@neclab.eu>
2015-05-19 10:23 ` David Vrabel
2015-05-12 17:18 ` [RFC PATCH 13/13] xen-netfront: implement RX " Joao Martins
2015-05-18 16:04 ` David Vrabel
[not found] ` <555A0D8C.4020309@citrix.com>
2015-05-19 10:22 ` Joao Martins
2015-05-13 10:50 ` [RFC PATCH 00/13] Persistent grant maps for xen net drivers David Vrabel
[not found] ` <55532C86.8020409@citrix.com>
2015-05-13 13:01 ` Joao Martins
2015-05-19 15:39 ` Wei Liu
[not found] ` <20150519153901.GH26335@zion.uk.xensource.com>
2015-05-22 10:27 ` Joao Martins
[not found] ` <191EF54A-D8DE-4BAA-B15D-41B2BA35353F@neclab.eu>
2015-05-29 6:53 ` Yuzhou (C)
[not found] ` <47498F109986134D9A5B42B82F405EBBA3244CB6@SZXEMA502-MBX.china.huawei.com>
2015-05-29 14:51 ` Joao Martins
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1431451117-70051-9-git-send-email-joao.martins@neclab.eu \
--to=joao.martins@neclab.eu \
--cc=boris.ostrovsky@oracle.com \
--cc=david.vrabel@citrix.com \
--cc=ian.campbell@citrix.com \
--cc=netdev@vger.kernel.org \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).