Commit 2ea3528
skbuff: skb_segment, Call zero copy functions before using skbuff frags
Commit bf5c25d ("skbuff: in skb_segment, call zerocopy functions
once per nskb") added the call to zero copy functions in skb_segment().
The change introduced a bug in skb_segment() because skb_orphan_frags()
may possibly change the number of fragments or allocate new fragments
altogether leaving nrfrags and frag to point to the old values. This can
cause a panic with stacktrace like the one below.
[ 193.894380] BUG: kernel NULL pointer dereference, address: 00000000000000bc
[ 193.895273] CPU: 13 PID: 18164 Comm: vh-net-17428 Kdump: loaded Tainted: G O 5.15.123+ #26
[ 193.903919] RIP: 0010:skb_segment+0xb0e/0x12f0
[ 194.021892] Call Trace:
[ 194.027422] <TASK>
[ 194.072861] tcp_gso_segment+0x107/0x540
[ 194.082031] inet_gso_segment+0x15c/0x3d0
[ 194.090783] skb_mac_gso_segment+0x9f/0x110
[ 194.095016] __skb_gso_segment+0xc1/0x190
[ 194.103131] netem_enqueue+0x290/0xb10 [sch_netem]
[ 194.107071] dev_qdisc_enqueue+0x16/0x70
[ 194.110884] __dev_queue_xmit+0x63b/0xb30
[ 194.121670] bond_start_xmit+0x159/0x380 [bonding]
[ 194.128506] dev_hard_start_xmit+0xc3/0x1e0
[ 194.131787] __dev_queue_xmit+0x8a0/0xb30
[ 194.138225] macvlan_start_xmit+0x4f/0x100 [macvlan]
[ 194.141477] dev_hard_start_xmit+0xc3/0x1e0
[ 194.144622] sch_direct_xmit+0xe3/0x280
[ 194.147748] __dev_queue_xmit+0x54a/0xb30
[ 194.154131] tap_get_user+0x2a8/0x9c0 [tap]
[ 194.157358] tap_sendmsg+0x52/0x8e0 [tap]
[ 194.167049] handle_tx_zerocopy+0x14e/0x4c0 [vhost_net]
[ 194.173631] handle_tx+0xcd/0xe0 [vhost_net]
[ 194.176959] vhost_worker+0x76/0xb0 [vhost]
[ 194.183667] kthread+0x118/0x140
[ 194.190358] ret_from_fork+0x1f/0x30
[ 194.193670] </TASK>
In this case calling skb_orphan_frags() updated nr_frags leaving nrfrags
local variable in skb_segment() stale. This resulted in the code hitting
i >= nrfrags prematurely and trying to move to next frag_skb using
list_skb pointer, which was NULL, and caused kernel panic. Move the call
to zero copy functions before using frags and nr_frags.
Fixes: bf5c25d ("skbuff: in skb_segment, call zerocopy functions once per nskb")
Signed-off-by: Mohamed Khalfella <mkhalfella@purestorage.com>
Reported-by: Amit Goyal <agoyal@purestorage.com>
Cc: stable@vger.kernel.org
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>1 parent f2e977f commit 2ea3528
1 file changed
+20
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4423 | 4423 | | |
4424 | 4424 | | |
4425 | 4425 | | |
4426 | | - | |
4427 | 4426 | | |
4428 | 4427 | | |
4429 | | - | |
4430 | 4428 | | |
4431 | 4429 | | |
4432 | 4430 | | |
4433 | 4431 | | |
4434 | 4432 | | |
| 4433 | + | |
| 4434 | + | |
4435 | 4435 | | |
4436 | 4436 | | |
4437 | | - | |
4438 | 4437 | | |
4439 | 4438 | | |
4440 | | - | |
| 4439 | + | |
4441 | 4440 | | |
4442 | 4441 | | |
4443 | 4442 | | |
| |||
4514 | 4513 | | |
4515 | 4514 | | |
4516 | 4515 | | |
| 4516 | + | |
| 4517 | + | |
| 4518 | + | |
| 4519 | + | |
| 4520 | + | |
| 4521 | + | |
| 4522 | + | |
4517 | 4523 | | |
4518 | 4524 | | |
4519 | 4525 | | |
| |||
4534 | 4540 | | |
4535 | 4541 | | |
4536 | 4542 | | |
| 4543 | + | |
| 4544 | + | |
| 4545 | + | |
| 4546 | + | |
4537 | 4547 | | |
4538 | 4548 | | |
4539 | 4549 | | |
| |||
4552 | 4562 | | |
4553 | 4563 | | |
4554 | 4564 | | |
4555 | | - | |
4556 | 4565 | | |
4557 | 4566 | | |
4558 | | - | |
4559 | | - | |
4560 | | - | |
4561 | 4567 | | |
4562 | 4568 | | |
4563 | 4569 | | |
| |||
4633 | 4639 | | |
4634 | 4640 | | |
4635 | 4641 | | |
4636 | | - | |
4637 | | - | |
| 4642 | + | |
4638 | 4643 | | |
4639 | 4644 | | |
4640 | 4645 | | |
4641 | 4646 | | |
| 4647 | + | |
| 4648 | + | |
| 4649 | + | |
| 4650 | + | |
| 4651 | + | |
4642 | 4652 | | |
4643 | 4653 | | |
4644 | 4654 | | |
| |||
4652 | 4662 | | |
4653 | 4663 | | |
4654 | 4664 | | |
4655 | | - | |
4656 | | - | |
4657 | | - | |
4658 | | - | |
4659 | 4665 | | |
4660 | 4666 | | |
4661 | 4667 | | |
| |||
0 commit comments