]> git.baikalelectronics.ru Git - kernel.git/commit
hamradio: defer 6pack kfree after unregister_netdev
authorLin Ma <linma@zju.edu.cn>
Mon, 8 Nov 2021 10:37:59 +0000 (18:37 +0800)
committerDavid S. Miller <davem@davemloft.net>
Tue, 9 Nov 2021 11:49:12 +0000 (11:49 +0000)
commit9371cd9fc2872abbe9bae8b3dde3330940b94949
tree170686756f3248243afccecb824ca94187b50809
parent7c1da104def9f7e529e5c15a169de629db0efa13
hamradio: defer 6pack kfree after unregister_netdev

There is a possible race condition (use-after-free) like below

 (USE)                       |  (FREE)
  dev_queue_xmit             |
   __dev_queue_xmit          |
    __dev_xmit_skb           |
     sch_direct_xmit         | ...
      xmit_one               |
       netdev_start_xmit     | tty_ldisc_kill
        __netdev_start_xmit  |  6pack_close
         sp_xmit             |   kfree
          sp_encaps          |
                             |

According to the patch "defer ax25 kfree after unregister_netdev", this
patch reorder the kfree after the unregister_netdev to avoid the possible
UAF as the unregister_netdev() is well synchronized and won't return if
there is a running routine.

Signed-off-by: Lin Ma <linma@zju.edu.cn>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/hamradio/6pack.c