mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-26 10:49:33 +00:00
scsi: megaraid_sas: fix panic on loading firmware crashdump
While loading fw crashdump in function fw_crash_buffer_show(), left bytes in one dma chunk was not checked, if copying size over it, overflow access will cause kernel panic. Signed-off-by: Junxiao Bi <junxiao.bi@oracle.com> Acked-by: Sumit Saxena <sumit.saxena@broadcom.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
parent
359603a384
commit
3b5f307ef3
1 changed files with 3 additions and 0 deletions
|
@ -3163,6 +3163,7 @@ fw_crash_buffer_show(struct device *cdev,
|
||||||
(struct megasas_instance *) shost->hostdata;
|
(struct megasas_instance *) shost->hostdata;
|
||||||
u32 size;
|
u32 size;
|
||||||
unsigned long dmachunk = CRASH_DMA_BUF_SIZE;
|
unsigned long dmachunk = CRASH_DMA_BUF_SIZE;
|
||||||
|
unsigned long chunk_left_bytes;
|
||||||
unsigned long src_addr;
|
unsigned long src_addr;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
u32 buff_offset;
|
u32 buff_offset;
|
||||||
|
@ -3186,6 +3187,8 @@ fw_crash_buffer_show(struct device *cdev,
|
||||||
}
|
}
|
||||||
|
|
||||||
size = (instance->fw_crash_buffer_size * dmachunk) - buff_offset;
|
size = (instance->fw_crash_buffer_size * dmachunk) - buff_offset;
|
||||||
|
chunk_left_bytes = dmachunk - (buff_offset % dmachunk);
|
||||||
|
size = (size > chunk_left_bytes) ? chunk_left_bytes : size;
|
||||||
size = (size >= PAGE_SIZE) ? (PAGE_SIZE - 1) : size;
|
size = (size >= PAGE_SIZE) ? (PAGE_SIZE - 1) : size;
|
||||||
|
|
||||||
src_addr = (unsigned long)instance->crash_buf[buff_offset / dmachunk] +
|
src_addr = (unsigned long)instance->crash_buf[buff_offset / dmachunk] +
|
||||||
|
|
Loading…
Reference in a new issue