wil6210: add block size checks during FW load
When loading FW from file add block size checks to ensure a corrupted FW file will not cause the driver to write outside the device memory. Signed-off-by: Lior David <qca_liord@qca.qualcomm.com> Signed-off-by: Maya Erez <qca_merez@qca.qualcomm.com> Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
This commit is contained in:
@@ -140,13 +140,15 @@ static u32 wmi_addr_remap(u32 x)
|
||||
/**
|
||||
* Check address validity for WMI buffer; remap if needed
|
||||
* @ptr - internal (linker) fw/ucode address
|
||||
* @size - if non zero, validate the block does not
|
||||
* exceed the device memory (bar)
|
||||
*
|
||||
* Valid buffer should be DWORD aligned
|
||||
*
|
||||
* return address for accessing buffer from the host;
|
||||
* if buffer is not valid, return NULL.
|
||||
*/
|
||||
void __iomem *wmi_buffer(struct wil6210_priv *wil, __le32 ptr_)
|
||||
void __iomem *wmi_buffer_block(struct wil6210_priv *wil, __le32 ptr_, u32 size)
|
||||
{
|
||||
u32 off;
|
||||
u32 ptr = le32_to_cpu(ptr_);
|
||||
@@ -161,10 +163,17 @@ void __iomem *wmi_buffer(struct wil6210_priv *wil, __le32 ptr_)
|
||||
off = HOSTADDR(ptr);
|
||||
if (off > wil->bar_size - 4)
|
||||
return NULL;
|
||||
if (size && ((off + size > wil->bar_size) || (off + size < off)))
|
||||
return NULL;
|
||||
|
||||
return wil->csr + off;
|
||||
}
|
||||
|
||||
void __iomem *wmi_buffer(struct wil6210_priv *wil, __le32 ptr_)
|
||||
{
|
||||
return wmi_buffer_block(wil, ptr_, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check address validity
|
||||
*/
|
||||
|
Reference in New Issue
Block a user