net: qrtr: Add bounds check in rx path

Validate the values read from shared memory in the receive path.
In the case where a VM is misbehaving, the qrtr transport should
return immediately and print a warning.

Change-Id: Ibb20ddbebcffbdff904fc7041fd452b09e0c96af
Signed-off-by: Sarannya S <quic_sarannya@quicinc.com>
This commit is contained in:
Sarannya S 2022-12-28 16:35:41 +05:30 committed by Gerrit - the friendly Code Review server
parent 875a0589dd
commit c7bf3d5d15

View File

@ -90,6 +90,9 @@ static void fifo_rx_peak(struct fifo_pipe *pipe,
if (tail >= pipe->length)
tail -= pipe->length;
if (WARN_ON_ONCE(tail > pipe->length))
return;
len = min_t(size_t, count, pipe->length - tail);
if (len)
memcpy_fromio(data, pipe->fifo + tail, len);