Skip to contentSkip to conversation

scsi/qla2xxx: a possible sleep-in-atomic bug in qlt_get_tag

BUG Jia-Ju Bai 2 participants 3 messages Dec 13, 2017 SCSI

lore
Share & tools
lore

Jia-Ju Bai

author
#0 lore raw

The driver may sleep under a spinlock.
The function call paths are:
qlt_handle_abts_recv_work (acquire the spinlock)
qlt_response_pkt_all_vps

    qlt_response_pkt
      qlt_handle_cmd_for_atio
        qlt_get_tag
          percpu_ida_alloc --> may sleep

qla82xx_msix_rsp_q (acquire the spinlock)
qla24xx_process_response_queue

    qlt_handle_abts_recv
      qlt_response_pkt_all_vps
        qlt_response_pkt
          qlt_handle_cmd_for_atio
            qlt_get_tag
              percpu_ida_alloc --> may sleep-in-atomic

qla24xx_intr_handler (acquire the spinlock)
qla24xx_process_response_queue

    qlt_handle_abts_recv
      qlt_response_pkt
        qlt_handle_cmd_for_atio
          qlt_get_tag
            percpu_ida_alloc --> may sleep

I do not find a good way to fix it, so I only report.
This possible bug is found by my static analysis tool (DSAC) and checked by my code review.

Thanks,
Jia-Ju Bai

#1 lore raw
Quoted 26 lines · Jia-Ju Bai

The driver may sleep under a spinlock.
The function call paths are:
qlt_handle_abts_recv_work (acquire the spinlock)
   qlt_response_pkt_all_vps
     qlt_response_pkt
       qlt_handle_cmd_for_atio
         qlt_get_tag
           percpu_ida_alloc --> may sleep

qla82xx_msix_rsp_q (acquire the spinlock) qla24xx_process_response_queue qlt_handle_abts_recv qlt_response_pkt_all_vps qlt_response_pkt qlt_handle_cmd_for_atio
             qlt_get_tag
               percpu_ida_alloc --> may sleep-in-atomic

qla24xx_intr_handler (acquire the spinlock)
   qla24xx_process_response_queue
     qlt_handle_abts_recv
       qlt_response_pkt
         qlt_handle_cmd_for_atio
           qlt_get_tag
             percpu_ida_alloc --> may sleep

Quoted 3 lines

I do not find a good way to fix it, so I only report. This possible bug is found by my static analysis tool (DSAC) and checked by my code review.

The report is incorrect: percpu_ida_alloc with state==TASK_RUNNING is atomic (and interrupt) safe which appears to be the case here.

James

author
#2 lore raw
Quoted 27 lines · James Bottomley
Quoted 26 lines · Jia-Ju Bai

The driver may sleep under a spinlock.
The function call paths are:
qlt_handle_abts_recv_work (acquire the spinlock)

    qlt_response_pkt_all_vps
      qlt_response_pkt
        qlt_handle_cmd_for_atio
          qlt_get_tag
            percpu_ida_alloc --> may sleep

qla82xx_msix_rsp_q (acquire the spinlock)

    qla24xx_process_response_queue
      qlt_handle_abts_recv
        qlt_response_pkt_all_vps
          qlt_response_pkt
            qlt_handle_cmd_for_atio
              qlt_get_tag
                percpu_ida_alloc --> may sleep-in-atomic

qla24xx_intr_handler (acquire the spinlock)

    qla24xx_process_response_queue
      qlt_handle_abts_recv
        qlt_response_pkt
          qlt_handle_cmd_for_atio
            qlt_get_tag
              percpu_ida_alloc --> may sleep
Quoted 8 lines
Quoted 3 lines

I do not find a good way to fix it, so I only report. This possible bug is found by my static analysis tool (DSAC) and checked by my code review.

The report is incorrect: percpu_ida_alloc with state==TASK_RUNNING is atomic (and interrupt) safe which appears to be the case here.

James

Thanks for your reply :)
I have checked the definition of percpu_ida_alloc, and I think you are right. Sorry for my incorrect bug report.

Thanks,
Jia-Ju Bai