[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220421152827.GB4679@anparri>
Date: Thu, 21 Apr 2022 17:30:37 +0200
From: Andrea Parri <parri.andrea@...il.com>
To: Stefano Garzarella <sgarzare@...hat.com>
Cc: KY Srinivasan <kys@...rosoft.com>,
Haiyang Zhang <haiyangz@...rosoft.com>,
Stephen Hemminger <sthemmin@...rosoft.com>,
Wei Liu <wei.liu@...nel.org>, Dexuan Cui <decui@...rosoft.com>,
Michael Kelley <mikelley@...rosoft.com>,
David Miller <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>, linux-hyperv@...r.kernel.org,
virtualization@...ts.linux-foundation.org, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 3/5] hv_sock: Add validation for untrusted Hyper-V values
> > @@ -577,12 +577,19 @@ static bool hvs_dgram_allow(u32 cid, u32 port)
> > static int hvs_update_recv_data(struct hvsock *hvs)
> > {
> > struct hvs_recv_buf *recv_buf;
> > - u32 payload_len;
> > + u32 pkt_len, payload_len;
> > +
> > + pkt_len = hv_pkt_len(hvs->recv_desc);
> > +
> > + /* Ensure the packet is big enough to read its header */
> > + if (pkt_len < HVS_HEADER_LEN)
> > + return -EIO;
> >
> > recv_buf = (struct hvs_recv_buf *)(hvs->recv_desc + 1);
> > payload_len = recv_buf->hdr.data_size;
> >
> > - if (payload_len > HVS_MTU_SIZE)
> > + /* Ensure the packet is big enough to read its payload */
> > + if (payload_len > pkt_len - HVS_HEADER_LEN || payload_len > HVS_MTU_SIZE)
>
> checkpatch warns that we exceed 80 characters, I do not have a strong
> opinion on this, but if you have to resend better break the condition into 2
> lines.
Will break if preferred. (but does it really warn?? I understand that
the warning was deprecated and the "limit" increased to 100 chars...)
> Maybe even update or remove the comment? (it only describes the first
> condition, but the conditions are pretty clear, so I don't think it adds
> much).
Works for me. (taking it as this applies to the previous comment too.)
Thanks,
Andrea
Powered by blists - more mailing lists