Commit 04c3eee
skbuff: skb_segment, Call zero copy functions before using skbuff frags
commit 2ea3528 upstream.
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>1 parent 4921f93 commit 04c3eee
1 file changed
+20
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4135 | 4135 | | |
4136 | 4136 | | |
4137 | 4137 | | |
4138 | | - | |
4139 | 4138 | | |
4140 | 4139 | | |
4141 | | - | |
4142 | 4140 | | |
4143 | 4141 | | |
4144 | 4142 | | |
4145 | 4143 | | |
4146 | 4144 | | |
| 4145 | + | |
| 4146 | + | |
4147 | 4147 | | |
4148 | 4148 | | |
4149 | | - | |
4150 | 4149 | | |
4151 | 4150 | | |
4152 | | - | |
| 4151 | + | |
4153 | 4152 | | |
4154 | 4153 | | |
4155 | 4154 | | |
| |||
4226 | 4225 | | |
4227 | 4226 | | |
4228 | 4227 | | |
| 4228 | + | |
| 4229 | + | |
| 4230 | + | |
| 4231 | + | |
| 4232 | + | |
| 4233 | + | |
| 4234 | + | |
4229 | 4235 | | |
4230 | 4236 | | |
4231 | 4237 | | |
| |||
4246 | 4252 | | |
4247 | 4253 | | |
4248 | 4254 | | |
| 4255 | + | |
| 4256 | + | |
| 4257 | + | |
| 4258 | + | |
4249 | 4259 | | |
4250 | 4260 | | |
4251 | 4261 | | |
| |||
4264 | 4274 | | |
4265 | 4275 | | |
4266 | 4276 | | |
4267 | | - | |
4268 | 4277 | | |
4269 | 4278 | | |
4270 | | - | |
4271 | | - | |
4272 | | - | |
4273 | 4279 | | |
4274 | 4280 | | |
4275 | 4281 | | |
| |||
4345 | 4351 | | |
4346 | 4352 | | |
4347 | 4353 | | |
4348 | | - | |
4349 | | - | |
| 4354 | + | |
4350 | 4355 | | |
4351 | 4356 | | |
4352 | 4357 | | |
4353 | 4358 | | |
| 4359 | + | |
| 4360 | + | |
| 4361 | + | |
| 4362 | + | |
| 4363 | + | |
4354 | 4364 | | |
4355 | 4365 | | |
4356 | 4366 | | |
| |||
4364 | 4374 | | |
4365 | 4375 | | |
4366 | 4376 | | |
4367 | | - | |
4368 | | - | |
4369 | | - | |
4370 | | - | |
4371 | 4377 | | |
4372 | 4378 | | |
4373 | 4379 | | |
| |||
0 commit comments