Message ID | CAPgLHd-Z2B88ZxCKmKuRTcndJXt2y3N00MazBxD7aXKUVhywqg@mail.gmail.com |
---|---|
State | Changes Requested, archived |
Delegated to: | David Miller |
Headers | show |
From: Wei Yongjun <weiyj.lk@gmail.com> Date: Mon, 30 Jan 2012 16:12:45 +0800 > + /* > + * Make sure we got a valid packet message, now total_data_buflen > + * should be the data packet size plus the trailer padding size > + */ > + if (pkt->total_data_buflen < rndis_pkt->data_len) { > + netdev_err(dev->net_dev->ndev, "incoming packet message " > + "buffer overflow detected (got %u, min %u)" > + "...dropping this message!\n", > + pkt->total_data_buflen, rndis_pkt->data_len); > + return; > + } This is inappropriate. Any logging message that is potentially remotely triggerable must at a minimum be rate limited. But to be honest I'd much prefer a statistic counter for this kind of event, rather then a log message. I'm not applying this patch. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c index da181f9..7568984 100644 --- a/drivers/net/hyperv/rndis_filter.c +++ b/drivers/net/hyperv/rndis_filter.c @@ -321,6 +321,25 @@ static void rndis_filter_receive_data(struct rndis_device *dev, data_offset = RNDIS_HEADER_SIZE + rndis_pkt->data_offset; pkt->total_data_buflen -= data_offset; + + /* + * Make sure we got a valid packet message, now total_data_buflen + * should be the data packet size plus the trailer padding size + */ + if (pkt->total_data_buflen < rndis_pkt->data_len) { + netdev_err(dev->net_dev->ndev, "incoming packet message " + "buffer overflow detected (got %u, min %u)" + "...dropping this message!\n", + pkt->total_data_buflen, rndis_pkt->data_len); + return; + } + + /* + * Remove the rndis trailer padding from packet message + * rndis_pkt->data_len tell us the real data length, we only copy + * the data packet to the stack, without the rndis trailer padding + */ + pkt->total_data_buflen = rndis_pkt->data_len; pkt->data = (void *)((unsigned long)pkt->data + data_offset); pkt->is_data_pkt = true;