[hns3-0114]net: hns3: fix a use after free problem in hns3_nic_maybe_stop_tx()

Bug #1859575 reported by Fred Kimmy
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
kunpeng920
Fix Released
Undecided
Unassigned
Ubuntu-18.04
Won't Fix
Undecided
Unassigned
Ubuntu-18.04-hwe
Fix Released
Undecided
Unassigned
Ubuntu-20.04
Fix Released
Undecided
Unassigned
Upstream-kernel
Fix Released
Undecided
Unassigned

Bug Description

[Bug Description]
Currently, hns3_nic_maybe_stop_tx() uses skb_copy() to linearize a
SKB if the BD num required by the SKB does not meet the hardware
limitation, and it linearizes the SKB by allocating a new linearized SKB
and freeing the old SKB, if hns3_nic_maybe_stop_tx() returns -EBUSY
because there are no enough space in the ring to send the linearized
skb to hardware, the sch_direct_xmit() still hold reference to old SKB
and try to retransmit the old SKB when dev_hard_start_xmit() return
TX_BUSY, which may cause use after freed problem.

[Steps to Reproduce]
1.run IO with high throughput

[Actual Results]
Oops

[Expected Results]
IO ok

[Reproducibility]
Inevitably

[Additional information]
Hardware: D06
Firmware: NA
Kernel: NA

[Resolution]
This patch fixes it by using __skb_linearize() to linearize the
SKB in hns3_nic_maybe_stop_tx().

d1a37dedcfcf net: hns3: fix a use after free problem in hns3_nic_maybe_stop_tx()

Ike Panhc (ikepanhc)
description: updated
tags: added: ikeradar
Revision history for this message
Ike Panhc (ikepanhc) wrote :

Unable to cherry-pick for bionic kernel.

Revision history for this message
Ike Panhc (ikepanhc) wrote :

In focal kernel since 5.4.0-13.16

Changed in kunpeng920:
status: New → Fix Committed
Ike Panhc (ikepanhc)
tags: removed: ikeradar
Ike Panhc (ikepanhc)
Changed in kunpeng920:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.