From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: P J P <ppandit@redhat.com>, Jason Wang <jasowang@redhat.com>
Cc: Prasad J Pandit <pjp@fedoraproject.org>,
Stefan Hajnoczi <stefanha@gmail.com>,
Qemu Developers <qemu-devel@nongnu.org>,
Li Qiang <pangpei.lq@antfin.com>,
Sven Schnelle <svens@stackframe.org>,
Ziming Zhang <ezrakiez@gmail.com>
Subject: Re: [PATCH v4 2/3] net: tulip: add .can_recieve routine
Date: Thu, 19 Mar 2020 11:24:09 +0100 [thread overview]
Message-ID: <ceb92631-f9f9-52bf-a5b3-87c01370d6c3@redhat.com> (raw)
In-Reply-To: <20200319095211.741445-3-ppandit@redhat.com>
Typo "can_recieve" -> "can_receive" in subject.
On 3/19/20 10:52 AM, P J P wrote:
> From: Prasad J Pandit <pjp@fedoraproject.org>
>
> Define .can_receive routine to do sanity checks before receiving
> packet data.
>
> Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
> ---
> hw/net/tulip.c | 15 ++++++++++++++-
> 1 file changed, 14 insertions(+), 1 deletion(-)
>
> Update v3: define .can_receive routine
> -> https://lists.gnu.org/archive/html/qemu-devel/2020-02/msg06275.html
>
> diff --git a/hw/net/tulip.c b/hw/net/tulip.c
> index fbe40095da..757f12c710 100644
> --- a/hw/net/tulip.c
> +++ b/hw/net/tulip.c
> @@ -229,6 +229,18 @@ static bool tulip_filter_address(TULIPState *s, const uint8_t *addr)
> return ret;
> }
>
> +static int
> +tulip_can_receive(NetClientState *nc)
> +{
> + TULIPState *s = qemu_get_nic_opaque(nc);
> +
> + if (s->rx_frame_len || tulip_rx_stopped(s)) {
> + return false;
> + }
> +
> + return true;
> +}
> +
> static ssize_t tulip_receive(TULIPState *s, const uint8_t *buf, size_t size)
> {
> struct tulip_descriptor desc;
> @@ -236,7 +248,7 @@ static ssize_t tulip_receive(TULIPState *s, const uint8_t *buf, size_t size)
> trace_tulip_receive(buf, size);
>
> if (size < 14 || size > sizeof(s->rx_frame) - 4
> - || s->rx_frame_len || tulip_rx_stopped(s)) {
> + || !tulip_can_receive(s->nic->ncs)) {
> return 0;
> }
>
> @@ -288,6 +300,7 @@ static NetClientInfo net_tulip_info = {
> .type = NET_CLIENT_DRIVER_NIC,
> .size = sizeof(NICState),
> .receive = tulip_receive_nc,
> + .can_receive = tulip_can_receive,
> };
>
> static const char *tulip_reg_name(const hwaddr addr)
>
next prev parent reply other threads:[~2020-03-19 10:25 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-19 9:52 [PATCH v4 0/3] net: tulip: add checks to avoid OOB access P J P
2020-03-19 9:52 ` [PATCH v4 1/3] net: tulip: check frame size and r/w data length P J P
2020-03-19 9:52 ` [PATCH v4 2/3] net: tulip: add .can_recieve routine P J P
2020-03-19 10:24 ` Philippe Mathieu-Daudé [this message]
2020-03-19 17:47 ` P J P
2020-03-19 9:52 ` [PATCH v4 3/3] net: tulip: flush queued packets post receive P J P
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=ceb92631-f9f9-52bf-a5b3-87c01370d6c3@redhat.com \
--to=philmd@redhat.com \
--cc=ezrakiez@gmail.com \
--cc=jasowang@redhat.com \
--cc=pangpei.lq@antfin.com \
--cc=pjp@fedoraproject.org \
--cc=ppandit@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@gmail.com \
--cc=svens@stackframe.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).