[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAGxU2F6UCiFQrXu4Nn=jNPbuE8i5hYe=Hkwak43kTMQoCQQy2A@mail.gmail.com>
Date: Thu, 21 Apr 2022 18:14:19 +0200
From: Stefano Garzarella <sgarzare@...hat.com>
To: Andrea Parri <parri.andrea@...il.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,
Linux Virtualization <virtualization@...ts.linux-foundation.org>,
netdev <netdev@...r.kernel.org>,
kernel list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 3/5] hv_sock: Add validation for untrusted Hyper-V values
On Thu, Apr 21, 2022 at 5:30 PM Andrea Parri <parri.andrea@...il.com> wrote:
>
> > > @@ -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...)
I see the warn here:
https://patchwork.kernel.org/project/netdevbpf/patch/20220420200720.434717-4-parri.andrea@gmail.com/
in the kernel doc [1] we still say we prefer 80 columns, so I try to
follow, especially when it doesn't make things worse.
[1] https://docs.kernel.org/process/coding-style.html#breaking-long-lines-and-strings
>
>
> > 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.)
Yep.
Thanks,
Stefano
Powered by blists - more mailing lists