Possible double free in iowarrior.ko

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello.

While searching for races in the Linux kernel I've come across "drivers/usb/misc/iowarrior.ko" module. Here are questions that I came up with while analyzing results. Lines are given using the info from Linux v4.12.

Consider the following case:

Thread 1:                    Thread 2:
iowarrior_release            iowarrior_disconnect
                               mutex_lock(&dev->mutex)
                               dev->present = 0
                               (iowarrior.c: line 889)
  mutex_lock(&dev->mutex)      mutex_unlock(&dev->mutex)
  dev->opened = 0
  (iowarrior.c: line 666)      if(dev->opened){
  if(dev->present){               //dev->opened == 0
    //dev->present ==0
  } else {                     } else {
    mutex_unlock(&dev->mutex)    iowarrior_delete(dev)
    iowarrior_delete(dev)      }
  }

In this case double free of several pointers inside iowarrior_delete becomes possible and no calls to usb_kill_urb() and wake_up_interruptible() are present. Is this feasible from your point of view? If so, maybe it is a good idea to move mutex_unlock(&dev->mutex) in iowarrior_disconnect() further down like in iowarrior_release() in both 'if' branches?

Thank you for your time

-- Anton Volkov
Linux Verification Center, ISPRAS
web: http://linuxtesting.org
e-mail: avolkov@xxxxxxxxx
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux