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

From: Andrea Parri
Date: Fri Sep 11 2020 - 04:43:14 EST


> > @@ -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