linux_dsm_epyc7002/drivers/scsi/aacraid
Arnd Bergmann d18539754d scsi: aacraid: address UBSAN warning regression
As reported by Meelis Roos, my previous patch causes an incorrect
calculation of the timeout, through an undefined signed integer
overflow:

[   12.228155] UBSAN: Undefined behaviour in drivers/scsi/aacraid/commsup.c:2514:49
[   12.228229] signed integer overflow:
[   12.228283] 964297611 * 250 cannot be represented in type 'long int'

The problem is that doing a multiplication with HZ first and then
dividing by USEC_PER_SEC worked correctly for 32-bit microseconds,
but not for 32-bit nanoseconds, which would require up to 41 bits.

This reworks the calculation to first convert the nanoseconds into
jiffies, which should give us the same result as before and not overflow.

Unfortunately I did not understand the exact intention of the algorithm,
in particular the part where we add half a second, so it's possible that
there is still a preexisting problem in this function. I added a comment
that this would be handled more nicely using usleep_range(), which
generally works better for waking up at a particular time than the
current schedule_timeout() based implementation. I did not feel
comfortable trying to implement that without being sure what the
intent is here though.

Fixes: 820f188659 ("scsi: aacraid: use timespec64 instead of timeval")
Tested-by: Meelis Roos <mroos@linux.ee>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2017-11-29 00:07:20 -05:00
..
aachba.c scsi: aacraid: Fix 2T+ drives on SmartIOC-2000 2017-09-15 15:49:43 -04:00
aacraid.h scsi: aacraid: Perform initialization reset only once 2017-11-20 22:32:00 -05:00
commctrl.c scsi: aacraid: Don't copy uninitialized stack memory to userspace 2017-06-26 15:01:03 -04:00
comminit.c scsi: aacraid: Fix controller initialization failure 2017-10-16 23:17:52 -04:00
commsup.c scsi: aacraid: address UBSAN warning regression 2017-11-29 00:07:20 -05:00
dpcsup.c scsi: aacraid: Update copyrights 2017-02-03 10:35:04 -05:00
linit.c scsi: aacraid: Perform initialization reset only once 2017-11-20 22:32:00 -05:00
Makefile [SCSI] aacraid: Add new code for PMC-Sierra's SRC based controller family 2011-03-23 11:36:58 -05:00
nark.c scsi: aacraid: Update copyrights 2017-02-03 10:35:04 -05:00
rkt.c scsi: aacraid: Update copyrights 2017-02-03 10:35:04 -05:00
rx.c scsi: aacraid: Perform initialization reset only once 2017-11-20 22:32:00 -05:00
sa.c scsi: aacraid: Update copyrights 2017-02-03 10:35:04 -05:00
src.c scsi: aacraid: Perform initialization reset only once 2017-11-20 22:32:00 -05:00
TODO [SCSI] aacraid: Newer adapter communication iterface support 2005-10-28 11:41:53 -05:00