• Stephen M. Cameron's avatar
    cciss: fix broken mutex usage in ioctl · 03f47e88
    Stephen M. Cameron authored
    If a new logical drive is added and the CCISS_REGNEWD ioctl is invoked
    (as is normal with the Array Configuration Utility) the process will
    hang as below.  It attempts to acquire the same mutex twice, once in
    do_ioctl() and once in cciss_unlocked_open().  The BKL was recursive,
    the mutex isn't.
    
      Linux version 3.10.0-rc2 (scameron@localhost.localdomain) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC) ) #1 SMP Fri May 24 14:32:12 CDT 2013
      [...]
      acu             D 0000000000000001     0  3246   3191 0x00000080
      Call Trace:
        schedule+0x29/0x70
        schedule_preempt_disabled+0xe/0x10
        __mutex_lock_slowpath+0x17b/0x220
        mutex_lock+0x2b/0x50
        cciss_unlocked_open+0x2f/0x110 [cciss]
        __blkdev_get+0xd3/0x470
        blkdev_get+0x5c/0x1e0
        register_disk+0x182/0x1a0
        add_disk+0x17c/0x310
        cciss_add_disk+0x13a/0x170 [cciss]
        cciss_update_drive_info+0x39b/0x480 [cciss]
        rebuild_lun_table+0x258/0x370 [cciss]
        cciss_ioctl+0x34f/0x470 [cciss]
        do_ioctl+0x49/0x70 [cciss]
        __blkdev_driver_ioctl+0x28/0x30
        blkdev_ioctl+0x200/0x7b0
        block_ioctl+0x3c/0x40
        do_vfs_ioctl+0x89/0x350
        SyS_ioctl+0xa1/0xb0
        system_call_fastpath+0x16/0x1b
    
    This mutex usage was added into the ioctl path when the big kernel lock
    was removed.  As it turns out, these paths are all thread safe anyway
    (or can easily be made so) and we don't want ioctl() to be single
    threaded in any case.
    Signed-off-by: default avatarStephen M. Cameron <scameron@beardog.cce.hp.com>
    Cc: Jens Axboe <axboe@kernel.dk>
    Cc: Mike Miller <mike.miller@hp.com>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    03f47e88
cciss.c 149 KB