From a97331a732b668bddc332edccffe7e678c503191 Mon Sep 17 00:00:00 2001 From: Sarannya S Date: Wed, 28 Dec 2022 17:33:28 +0530 Subject: [PATCH] net: qrtr: haven: 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 haven transport should return immediately and print a warning. Change-Id: Ieccd3f99ec0cf321f136600760e7f66e125f765a Signed-off-by: Sarannya S --- net/qrtr/haven.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/qrtr/haven.c b/net/qrtr/haven.c index b37e779c7e7f..c66564c0f00b 100644 --- a/net/qrtr/haven.c +++ b/net/qrtr/haven.c @@ -148,6 +148,9 @@ static void haven_rx_peak(struct haven_pipe *pipe, void *data, 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);