Re: [BUG] scsi/qla2xxx: a possible sleep-in-atomic bug in qlt_get_tag

From: James Bottomley
Date: Tue Dec 12 2017 - 23:42:31 EST


On Wed, 2017-12-13 at 11:18 +0800, Jia-Ju Bai wrote:
> 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.

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

James