mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-14 08:36:12 -04:00
mhi: core: Read transfer length from an event properly
When MHI Driver receives an EOT event, it reads xfer_len from the event in the last TRE. The value is under control of the MHI device and never validated by Host MHI driver. The value should never be larger than the real size of the buffer but a malicious device can set the value 0xFFFF as maximum. This causes driver to memory overflow (both read or write). Fix this issue by reading minimum of transfer length from event and the buffer length provided. Change-Id: Iac095dfc85f70ffbb0fdb6cf9b2331469439e1ff Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
This commit is contained in:
parent
bf4eaa44f7
commit
860f9f889e
1 changed files with 3 additions and 1 deletions
|
|
@ -1070,7 +1070,9 @@ static int parse_rsc_event(struct mhi_controller *mhi_cntrl,
|
|||
|
||||
result.transaction_status = (ev_code == MHI_EV_CC_OVERFLOW) ?
|
||||
-EOVERFLOW : 0;
|
||||
result.bytes_xferd = xfer_len;
|
||||
|
||||
/* truncate to buf len if xfer_len is larger */
|
||||
result.bytes_xferd = min_t(u16, xfer_len, buf_info->len);
|
||||
result.buf_addr = buf_info->cb_buf;
|
||||
result.dir = mhi_chan->dir;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue