Skip to content

Commit c42a875

Browse files
Sarannya Sbgcngm
Sarannya S
authored andcommitted
net: ipc_router: 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 ipcrtr fifo xport should exit and print a warning when bogus values may cause out of bounds to be read. Change-Id: I2d219b36a4d7ddb137f232f47f4fe2e662add98d Signed-off-by: Sarannya S <[email protected]>
1 parent fb5dd42 commit c42a875

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

net/ipc_router/ipc_router_fifo_xprt.c

+5
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ static size_t fifo_tx_avail(struct msm_ipc_pipe *pipe)
129129
else
130130
avail = tail - head;
131131

132+
if (WARN_ON_ONCE(avail > pipe->length))
133+
avail = 0;
134+
132135
return avail;
133136
}
134137

@@ -139,6 +142,8 @@ static void fifo_tx_write(struct msm_ipc_pipe *pipe,
139142
u32 head;
140143

141144
head = le32_to_cpu(*pipe->head);
145+
if (WARN_ON_ONCE(head > pipe->length))
146+
return;
142147

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

0 commit comments

Comments
 (0)