From: Andrea Parri <parri.andrea@gmail.com>
To: Stefano Garzarella <sgarzare@redhat.com>
Cc: KY Srinivasan <kys@microsoft.com>,
Haiyang Zhang <haiyangz@microsoft.com>,
Stephen Hemminger <sthemmin@microsoft.com>,
Wei Liu <wei.liu@kernel.org>, Dexuan Cui <decui@microsoft.com>,
Michael Kelley <mikelley@microsoft.com>,
David Miller <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
linux-hyperv@vger.kernel.org,
virtualization@lists.linux-foundation.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/5] hv_sock: Add validation for untrusted Hyper-V values
Date: Thu, 21 Apr 2022 17:30:37 +0200 [thread overview]
Message-ID: <20220421152827.GB4679@anparri> (raw)
In-Reply-To: <20220421140805.qg4cwqhsq5vuqkut@sgarzare-redhat>
> > @@ -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
next prev parent reply other threads:[~2022-04-21 15:30 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-20 20:07 [PATCH 0/5] hv_sock: Hardening changes Andrea Parri (Microsoft)
2022-04-20 20:07 ` [PATCH 1/5] hv_sock: Check hv_pkt_iter_first_raw()'s return value Andrea Parri (Microsoft)
2022-04-20 23:07 ` Michael Kelley (LINUX)
2022-04-21 13:50 ` Stefano Garzarella
2022-04-20 20:07 ` [PATCH 2/5] hv_sock: Copy packets sent by Hyper-V out of the ring buffer Andrea Parri (Microsoft)
2022-04-20 23:08 ` Michael Kelley (LINUX)
2022-04-21 13:58 ` Stefano Garzarella
2022-04-21 15:21 ` Andrea Parri
2022-04-20 20:07 ` [PATCH 3/5] hv_sock: Add validation for untrusted Hyper-V values Andrea Parri (Microsoft)
2022-04-20 23:09 ` Michael Kelley (LINUX)
2022-04-21 14:08 ` Stefano Garzarella
2022-04-21 15:30 ` Andrea Parri [this message]
2022-04-21 16:14 ` Stefano Garzarella
2022-04-20 20:07 ` [PATCH 4/5] Drivers: hv: vmbus: Accept hv_sock offers in isolated guests Andrea Parri (Microsoft)
2022-04-20 23:10 ` Michael Kelley (LINUX)
2022-04-20 20:07 ` [PATCH 5/5] Drivers: hv: vmbus: Refactor the ring-buffer iterator functions Andrea Parri (Microsoft)
2022-04-20 23:15 ` Michael Kelley (LINUX)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220421152827.GB4679@anparri \
--to=parri.andrea@gmail.com \
--cc=davem@davemloft.net \
--cc=decui@microsoft.com \
--cc=haiyangz@microsoft.com \
--cc=kuba@kernel.org \
--cc=kys@microsoft.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mikelley@microsoft.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sgarzare@redhat.com \
--cc=sthemmin@microsoft.com \
--cc=virtualization@lists.linux-foundation.org \
--cc=wei.liu@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).