Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b3010c56 authored by Sarannya S's avatar Sarannya S Committed by Gerrit - the friendly Code Review server
Browse files

net: qrtr: fifo: Add bounds check on tx path



Add bounds check on values read from shared memory in the tx path. In
cases where the VM is misbehaving, the qrtr transport should exit and
print a warning when bogus values may cause out of bounds to be read.

Change-Id: Ic4bdb838ea7f72703327020ec31db2f4150b3474
Signed-off-by: default avatarSarannya S <quic_sarannya@quicinc.com>
parent 3909c0b8
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -125,6 +125,9 @@ static size_t fifo_tx_avail(struct fifo_pipe *pipe)
	else
		avail = tail - head;

	if (WARN_ON_ONCE(avail > pipe->length))
		avail = 0;

	return avail;
}

@@ -135,6 +138,8 @@ static void fifo_tx_write(struct fifo_pipe *pipe,
	u32 head;

	head = le32_to_cpu(*pipe->head);
	if (WARN_ON_ONCE(head > pipe->length))
		return;

	len = min_t(size_t, count, pipe->length - head);
	if (len)