linux/drivers/scsi/bnx2fc
Maurizio Lombardi c2dd893a3b scsi: bnx2fc: fix race condition in bnx2fc_get_host_stats()
If multiple tasks attempt to read the stats, it may happen that the
start_req_done completion is re-initialized while still being used by
another task, causing a list corruption.

This patch fixes the bug by adding a mutex to serialize the calls to
bnx2fc_get_host_stats().

WARNING: at lib/list_debug.c:48 list_del+0x6e/0xa0() (Not tainted)
Hardware name: PowerEdge R820
list_del corruption. prev->next should be ffff882035627d90, but was ffff884069541588

Pid: 40267, comm: perl Not tainted 2.6.32-642.3.1.el6.x86_64 #1
Call Trace:
 [<ffffffff8107c691>] ? warn_slowpath_common+0x91/0xe0
 [<ffffffff8107c796>] ? warn_slowpath_fmt+0x46/0x60
 [<ffffffff812ad16e>] ? list_del+0x6e/0xa0
 [<ffffffff81547eed>] ? wait_for_common+0x14d/0x180
 [<ffffffff8106c4a0>] ? default_wake_function+0x0/0x20
 [<ffffffff81547fd3>] ? wait_for_completion_timeout+0x13/0x20
 [<ffffffffa05410b1>] ? bnx2fc_get_host_stats+0xa1/0x280 [bnx2fc]
 [<ffffffffa04cf630>] ? fc_stat_show+0x90/0xc0 [scsi_transport_fc]
 [<ffffffffa04cf8b6>] ? show_fcstat_tx_frames+0x16/0x20 [scsi_transport_fc]
 [<ffffffff8137c647>] ? dev_attr_show+0x27/0x50
 [<ffffffff8113b9be>] ? __get_free_pages+0xe/0x50
 [<ffffffff812170e1>] ? sysfs_read_file+0x111/0x200
 [<ffffffff8119a305>] ? vfs_read+0xb5/0x1a0
 [<ffffffff8119b0b6>] ? fget_light_pos+0x16/0x50
 [<ffffffff8119a651>] ? sys_read+0x51/0xb0
 [<ffffffff810ee1fe>] ? __audit_syscall_exit+0x25e/0x290
 [<ffffffff8100b0d2>] ? system_call_fastpath+0x16/0x1b

Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
Acked-by: Chad Dupuis <chad.dupuis@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2017-05-24 15:14:42 -04:00
..
57xx_hsi_bnx2fc.h bnx2fc: Remove 'NetXtreme II' from source files. 2015-11-09 17:29:04 -08:00
Kconfig bnx2fc: Remove 'NetXtreme II' from source files. 2015-11-09 17:29:04 -08:00
Makefile [SCSI] bnx2fc: Reduce object size by consolidating formats 2012-07-20 08:58:17 +01:00
bnx2fc.h scsi: bnx2fc: fix race condition in bnx2fc_get_host_stats() 2017-05-24 15:14:42 -04:00
bnx2fc_constants.h bnx2fc: Remove 'NetXtreme II' from source files. 2015-11-09 17:29:04 -08:00
bnx2fc_debug.c bnx2fc: Remove 'NetXtreme II' from source files. 2015-11-09 17:29:04 -08:00
bnx2fc_debug.h bnx2fc: Remove 'NetXtreme II' from source files. 2015-11-09 17:29:04 -08:00
bnx2fc_els.c scsi: bnx2fc: Mark symbols static where possible 2016-09-09 07:11:07 -04:00
bnx2fc_fcoe.c scsi: bnx2fc: fix race condition in bnx2fc_get_host_stats() 2017-05-24 15:14:42 -04:00
bnx2fc_hwi.c scsi: bnx2fc: Mark symbols static where possible 2016-09-09 07:11:07 -04:00
bnx2fc_io.c locking/atomic, kref: Add kref_read() 2017-01-14 11:37:18 +01:00
bnx2fc_tgt.c scsi: libfc: Replace ->rport_logoff callback with function call 2016-11-08 17:29:55 -05:00