• Charan Teja Reddy's avatar
    dmabuf: fix use-after-free of dmabuf's file->f_inode · 05cd8469
    Charan Teja Reddy authored
    It is observed 'use-after-free' on the dmabuf's file->f_inode with the
    race between closing the dmabuf file and reading the dmabuf's debug
    info.
    
    Consider the below scenario where P1 is closing the dma_buf file
    and P2 is reading the dma_buf's debug info in the system:
    
    P1						P2
    					dma_buf_debug_show()
    dma_buf_put()
      __fput()
        file->f_op->release()
        dput()
        ....
          dentry_unlink_inode()
            iput(dentry->d_inode)
            (where the inode is freed)
    					mutex_lock(&db_list.lock)
    					read 'dma_buf->file->f_inode'
    					(the same inode is freed by P1)
    					mutex_unlock(&db_list.lock)
          dentry->d_op->d_release()-->
            dma_buf_release()
              .....
              mutex_lock(&db_list.lock)
              removes the dmabuf from the list
              mutex_unlock(&db_list.lock)
    
    In the above scenario, when dma_buf_put() is called on a dma_buf, it
    first frees the dma_buf's file->f_inode(=dentry->d_inode) and then
    removes this dma_buf from the...
    05cd8469
dma-buf.c 38.7 KB