Thread (3 messages) 3 messages, 2 authors, 2020-09-11

Re: [PATCH v2] hv_netvsc: Add validation for untrusted Hyper-V values

From: Andrea Parri <parri.andrea@gmail.com>
Date: 2020-09-11 08:43:14
Also in: linux-hyperv, lkml

quoted
@@ -740,12 +755,45 @@ static void netvsc_send_completion(struct
net_device *ndev,
 				   int budget)
 {
 	const struct nvsp_message *nvsp_packet = hv_pkt_data(desc);
+	u32 msglen = hv_pkt_datalen(desc);
+
+	/* Ensure packet is big enough to read header fields */
+	if (msglen < sizeof(struct nvsp_message_header)) {
+		netdev_err(ndev, "nvsp_message length too small: %u\n",
msglen);
+		return;
+	}

 	switch (nvsp_packet->hdr.msg_type) {
 	case NVSP_MSG_TYPE_INIT_COMPLETE:
+		if (msglen < sizeof(struct nvsp_message_init_complete)) {
This and other similar places should include header size:
		if (msglen < sizeof(struct nvsp_message_header) + sizeof(struct nvsp_message_init_complete)) {
Thanks for pointing this out; fixing for v3...

  Andrea
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help