• Duoming Zhou's avatar
    ax25: Fix UAF bugs in ax25 timers · 82e31755
    Duoming Zhou authored
    There are race conditions that may lead to UAF bugs in
    ax25_heartbeat_expiry(), ax25_t1timer_expiry(), ax25_t2timer_expiry(),
    ax25_t3timer_expiry() and ax25_idletimer_expiry(), when we call
    ax25_release() to deallocate ax25_dev.
    
    One of the UAF bugs caused by ax25_release() is shown below:
    
          (Thread 1)                    |      (Thread 2)
    ax25_dev_device_up() //(1)          |
    ...                                 | ax25_kill_by_device()
    ax25_bind()          //(2)          |
    ax25_connect()                      | ...
     ax25_std_establish_data_link()     |
      ax25_start_t1timer()              | ax25_dev_device_down() //(3)
       mod_timer(&ax25->t1timer,..)     |
                                        | ax25_release()
       (wait a time)                    |  ...
                                        |  ax25_dev_put(ax25_dev) //(4)FREE
       ax25_t1timer_expiry()            |
        ax25->ax25_dev->values[..] //USE|  ...
         ...                            |
    
    We increase the refcount of ax2...
    82e31755
af_ax25.c 44.6 KB