diff mbox series

[RFC,v1,01/10] net: qrtr: ns: validate msglen before ctrl_pkt use

Message ID 20241018181842.1368394-2-denkenz@gmail.com
State New
Headers show
Series [RFC,v1,01/10] net: qrtr: ns: validate msglen before ctrl_pkt use | expand

Commit Message

Denis Kenzior Oct. 18, 2024, 6:18 p.m. UTC
The qrtr_ctrl_pkt structure is currently accessed without checking
if the received payload is large enough to hold the structure's fields.
Add a check to ensure the payload length is sufficient.

Signed-off-by: Denis Kenzior <denkenz@gmail.com>
Reviewed-by: Marcel Holtmann <marcel@holtmann.org>
Reviewed-by: Andy Gross <agross@kernel.org>
---
 net/qrtr/ns.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Denis Kenzior Oct. 22, 2024, 2:23 p.m. UTC | #1
Hi Chris,

>> +        if ((size_t)msglen < sizeof(pkt))
> 
> sizeof(*pkt)?
> 

Indeed.  Thank you for catching that, will fix in the next version.

Regards,
-Denis
diff mbox series

Patch

diff --git a/net/qrtr/ns.c b/net/qrtr/ns.c
index 3de9350cbf30..6158e08c0252 100644
--- a/net/qrtr/ns.c
+++ b/net/qrtr/ns.c
@@ -619,6 +619,9 @@  static void qrtr_ns_worker(struct work_struct *work)
 			break;
 		}
 
+		if ((size_t)msglen < sizeof(pkt))
+			break;
+
 		pkt = recv_buf;
 		cmd = le32_to_cpu(pkt->cmd);
 		if (cmd < ARRAY_SIZE(qrtr_ctrl_pkt_strings) &&