Commit 761c509
committed
skbuff: skb_segment, Call zero copy functions before using skbuff frags
jira VULN-155411
cve CVE-2023-53354
commit-author Mohamed Khalfella <[email protected]>
commit 2ea3528
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 <[email protected]>
Reported-by: Amit Goyal <[email protected]>
Cc: [email protected]
Reviewed-by: Eric Dumazet <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
(cherry picked from commit 2ea3528)
Signed-off-by: Brett Mastbergen <[email protected]>1 parent 7a7f1c0 commit 761c509
1 file changed
+20
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4101 | 4101 | | |
4102 | 4102 | | |
4103 | 4103 | | |
4104 | | - | |
4105 | 4104 | | |
4106 | 4105 | | |
4107 | | - | |
4108 | 4106 | | |
4109 | 4107 | | |
4110 | 4108 | | |
4111 | 4109 | | |
4112 | 4110 | | |
| 4111 | + | |
| 4112 | + | |
4113 | 4113 | | |
4114 | 4114 | | |
4115 | | - | |
4116 | 4115 | | |
4117 | 4116 | | |
4118 | | - | |
| 4117 | + | |
4119 | 4118 | | |
4120 | 4119 | | |
4121 | 4120 | | |
| |||
4192 | 4191 | | |
4193 | 4192 | | |
4194 | 4193 | | |
| 4194 | + | |
| 4195 | + | |
| 4196 | + | |
| 4197 | + | |
| 4198 | + | |
| 4199 | + | |
| 4200 | + | |
4195 | 4201 | | |
4196 | 4202 | | |
4197 | 4203 | | |
| |||
4212 | 4218 | | |
4213 | 4219 | | |
4214 | 4220 | | |
| 4221 | + | |
| 4222 | + | |
| 4223 | + | |
| 4224 | + | |
4215 | 4225 | | |
4216 | 4226 | | |
4217 | 4227 | | |
| |||
4230 | 4240 | | |
4231 | 4241 | | |
4232 | 4242 | | |
4233 | | - | |
4234 | 4243 | | |
4235 | 4244 | | |
4236 | | - | |
4237 | | - | |
4238 | | - | |
4239 | 4245 | | |
4240 | 4246 | | |
4241 | 4247 | | |
| |||
4312 | 4318 | | |
4313 | 4319 | | |
4314 | 4320 | | |
4315 | | - | |
4316 | | - | |
| 4321 | + | |
4317 | 4322 | | |
4318 | 4323 | | |
4319 | 4324 | | |
4320 | 4325 | | |
| 4326 | + | |
| 4327 | + | |
| 4328 | + | |
| 4329 | + | |
| 4330 | + | |
4321 | 4331 | | |
4322 | 4332 | | |
4323 | 4333 | | |
| |||
4331 | 4341 | | |
4332 | 4342 | | |
4333 | 4343 | | |
4334 | | - | |
4335 | | - | |
4336 | | - | |
4337 | | - | |
4338 | 4344 | | |
4339 | 4345 | | |
4340 | 4346 | | |
| |||
0 commit comments