All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/2] net: tulip: add checks to avoid OOB access
@ 2020-03-03 10:47 P J P
  2020-03-03 10:47 ` [PATCH v3 1/2] net: tulip: check frame size and r/w data length P J P
                   ` (5 more replies)
  0 siblings, 6 replies; 14+ messages in thread
From: P J P @ 2020-03-03 10:47 UTC (permalink / raw)
  To: Jason Wang
  Cc: Li Qiang, Sven Schnelle, Qemu Developers, Ziming Zhang, Prasad J Pandit

From: Prasad J Pandit <pjp@fedoraproject.org>

Hello,

* This series adds checks to avoid potential OOB access and infinite loop
  issues while processing rx/tx data.

* Tulip tx descriptors are capped at 128 to avoid infinite loop in
  tulip_xmit_list_update(), wrt Tulip kernel driver
  -> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/net/ethernet/dec/tulip/tulip.h#n319

* Update v3: add .can_receive routine
  -> https://lists.gnu.org/archive/html/qemu-devel/2020-02/msg06275.html

Thank you.
--
Prasad J Pandit (2):
  net: tulip: check frame size and r/w data length
  net: tulip: add .can_recieve routine

 hw/net/tulip.c | 49 ++++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 40 insertions(+), 9 deletions(-)

--
2.24.1



^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v3 1/2] net: tulip: check frame size and r/w data length
  2020-03-03 10:47 [PATCH v3 0/2] net: tulip: add checks to avoid OOB access P J P
@ 2020-03-03 10:47 ` P J P
  2020-03-03 10:47 ` [PATCH v3 2/2] net: tulip: add .can_recieve routine P J P
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 14+ messages in thread
From: P J P @ 2020-03-03 10:47 UTC (permalink / raw)
  To: Jason Wang
  Cc: Li Qiang, Sven Schnelle, Qemu Developers, Ziming Zhang, Prasad J Pandit

From: Prasad J Pandit <pjp@fedoraproject.org>

Tulip network driver while copying tx/rx buffers does not check
frame size against r/w data length. This may lead to OOB buffer
access. Add check to avoid it.

Limit iterations over descriptors to avoid potential infinite
loop issue in tulip_xmit_list_update.

Reported-by: Li Qiang <pangpei.lq@antfin.com>
Reported-by: Ziming Zhang <ezrakiez@gmail.com>
Reported-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
---
 hw/net/tulip.c | 36 +++++++++++++++++++++++++++---------
 1 file changed, 27 insertions(+), 9 deletions(-)

Update v3: return a value from tulip_copy_tx_buffers() and avoid infinite loop
  -> 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 cfac2719d3..fbe40095da 100644
--- a/hw/net/tulip.c
+++ b/hw/net/tulip.c
@@ -170,6 +170,10 @@ static void tulip_copy_rx_bytes(TULIPState *s, struct tulip_descriptor *desc)
         } else {
             len = s->rx_frame_len;
         }
+
+        if (s->rx_frame_len + len >= sizeof(s->rx_frame)) {
+            return;
+        }
         pci_dma_write(&s->dev, desc->buf_addr1, s->rx_frame +
             (s->rx_frame_size - s->rx_frame_len), len);
         s->rx_frame_len -= len;
@@ -181,6 +185,10 @@ static void tulip_copy_rx_bytes(TULIPState *s, struct tulip_descriptor *desc)
         } else {
             len = s->rx_frame_len;
         }
+
+        if (s->rx_frame_len + len >= sizeof(s->rx_frame)) {
+            return;
+        }
         pci_dma_write(&s->dev, desc->buf_addr2, s->rx_frame +
             (s->rx_frame_size - s->rx_frame_len), len);
         s->rx_frame_len -= len;
@@ -227,7 +235,8 @@ static ssize_t tulip_receive(TULIPState *s, const uint8_t *buf, size_t size)
 
     trace_tulip_receive(buf, size);
 
-    if (size < 14 || size > 2048 || s->rx_frame_len || tulip_rx_stopped(s)) {
+    if (size < 14 || size > sizeof(s->rx_frame) - 4
+        || s->rx_frame_len || tulip_rx_stopped(s)) {
         return 0;
     }
 
@@ -275,7 +284,6 @@ static ssize_t tulip_receive_nc(NetClientState *nc,
     return tulip_receive(qemu_get_nic_opaque(nc), buf, size);
 }
 
-
 static NetClientInfo net_tulip_info = {
     .type = NET_CLIENT_DRIVER_NIC,
     .size = sizeof(NICState),
@@ -558,7 +566,7 @@ static void tulip_tx(TULIPState *s, struct tulip_descriptor *desc)
         if ((s->csr[6] >> CSR6_OM_SHIFT) & CSR6_OM_MASK) {
             /* Internal or external Loopback */
             tulip_receive(s, s->tx_frame, s->tx_frame_len);
-        } else {
+        } else if (s->tx_frame_len <= sizeof(s->tx_frame)) {
             qemu_send_packet(qemu_get_queue(s->nic),
                 s->tx_frame, s->tx_frame_len);
         }
@@ -570,23 +578,31 @@ static void tulip_tx(TULIPState *s, struct tulip_descriptor *desc)
     }
 }
 
-static void tulip_copy_tx_buffers(TULIPState *s, struct tulip_descriptor *desc)
+static int tulip_copy_tx_buffers(TULIPState *s, struct tulip_descriptor *desc)
 {
     int len1 = (desc->control >> TDES1_BUF1_SIZE_SHIFT) & TDES1_BUF1_SIZE_MASK;
     int len2 = (desc->control >> TDES1_BUF2_SIZE_SHIFT) & TDES1_BUF2_SIZE_MASK;
 
+    if (s->tx_frame_len + len1 >= sizeof(s->tx_frame)) {
+        return -1;
+    }
     if (len1) {
         pci_dma_read(&s->dev, desc->buf_addr1,
             s->tx_frame + s->tx_frame_len, len1);
         s->tx_frame_len += len1;
     }
 
+    if (s->tx_frame_len + len2 >= sizeof(s->tx_frame)) {
+        return -1;
+    }
     if (len2) {
         pci_dma_read(&s->dev, desc->buf_addr2,
             s->tx_frame + s->tx_frame_len, len2);
         s->tx_frame_len += len2;
     }
     desc->status = (len1 + len2) ? 0 : 0x7fffffff;
+
+    return 0;
 }
 
 static void tulip_setup_filter_addr(TULIPState *s, uint8_t *buf, int n)
@@ -651,13 +667,15 @@ static uint32_t tulip_ts(TULIPState *s)
 
 static void tulip_xmit_list_update(TULIPState *s)
 {
+#define TULIP_DESC_MAX 128
+    uint8_t i = 0;
     struct tulip_descriptor desc;
 
     if (tulip_ts(s) != CSR5_TS_SUSPENDED) {
         return;
     }
 
-    for (;;) {
+    for (i = 0; i < TULIP_DESC_MAX; i++) {
         tulip_desc_read(s, s->current_tx_desc, &desc);
         tulip_dump_tx_descriptor(s, &desc);
 
@@ -675,10 +693,10 @@ static void tulip_xmit_list_update(TULIPState *s)
                 s->tx_frame_len = 0;
             }
 
-            tulip_copy_tx_buffers(s, &desc);
-
-            if (desc.control & TDES1_LS) {
-                tulip_tx(s, &desc);
+            if (!tulip_copy_tx_buffers(s, &desc)) {
+                if (desc.control & TDES1_LS) {
+                    tulip_tx(s, &desc);
+                }
             }
         }
         tulip_desc_write(s, s->current_tx_desc, &desc);
-- 
2.24.1



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v3 2/2] net: tulip: add .can_recieve routine
  2020-03-03 10:47 [PATCH v3 0/2] net: tulip: add checks to avoid OOB access P J P
  2020-03-03 10:47 ` [PATCH v3 1/2] net: tulip: check frame size and r/w data length P J P
@ 2020-03-03 10:47 ` P J P
  2020-03-06 13:08   ` Stefan Hajnoczi
  2020-03-03 10:54 ` [PATCH v3 0/2] net: tulip: add checks to avoid OOB access no-reply
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 14+ messages in thread
From: P J P @ 2020-03-03 10:47 UTC (permalink / raw)
  To: Jason Wang
  Cc: Li Qiang, Sven Schnelle, Qemu Developers, Ziming Zhang, Prasad J Pandit

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)
-- 
2.24.1



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH v3 0/2] net: tulip: add checks to avoid OOB access
  2020-03-03 10:47 [PATCH v3 0/2] net: tulip: add checks to avoid OOB access P J P
  2020-03-03 10:47 ` [PATCH v3 1/2] net: tulip: check frame size and r/w data length P J P
  2020-03-03 10:47 ` [PATCH v3 2/2] net: tulip: add .can_recieve routine P J P
@ 2020-03-03 10:54 ` no-reply
  2020-03-05 12:16   ` P J P
  2020-03-03 10:54 ` no-reply
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 14+ messages in thread
From: no-reply @ 2020-03-03 10:54 UTC (permalink / raw)
  To: ppandit; +Cc: pjp, jasowang, qemu-devel, pangpei.lq, svens, ezrakiez

Patchew URL: https://patchew.org/QEMU/20200303104724.233375-1-ppandit@redhat.com/



Hi,

This series seems to have some coding style problems. See output below for
more information:

Subject: [PATCH v3 0/2] net: tulip: add checks to avoid OOB access
Message-id: 20200303104724.233375-1-ppandit@redhat.com
Type: series

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

fatal: unable to access 'https://github.com/patchew-project/qemu/': Failed connect to github.com:443; No route to host
Traceback (most recent call last):
  File "patchew-tester2/src/patchew-cli", line 531, in test_one
    git_clone_repo(clone, r["repo"], r["head"], logf, True)
  File "patchew-tester2/src/patchew-cli", line 54, in git_clone_repo
    stdout=logf, stderr=logf)
  File "/opt/rh/rh-python36/root/usr/lib64/python3.6/subprocess.py", line 291, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['git', 'fetch', '3c8cf5a9c21ff8782164d1def7f44bd888713384']' returned non-zero exit status 128.



The full log is available at
http://patchew.org/logs/20200303104724.233375-1-ppandit@redhat.com/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v3 0/2] net: tulip: add checks to avoid OOB access
  2020-03-03 10:47 [PATCH v3 0/2] net: tulip: add checks to avoid OOB access P J P
                   ` (2 preceding siblings ...)
  2020-03-03 10:54 ` [PATCH v3 0/2] net: tulip: add checks to avoid OOB access no-reply
@ 2020-03-03 10:54 ` no-reply
  2020-03-03 10:54 ` no-reply
  2020-03-03 10:56 ` no-reply
  5 siblings, 0 replies; 14+ messages in thread
From: no-reply @ 2020-03-03 10:54 UTC (permalink / raw)
  To: ppandit; +Cc: pjp, jasowang, qemu-devel, pangpei.lq, svens, ezrakiez

Patchew URL: https://patchew.org/QEMU/20200303104724.233375-1-ppandit@redhat.com/



Hi,

This series failed the docker-mingw@fedora build test. Please find the testing commands and
their output below. If you have Docker installed, you can probably reproduce it
locally.

=== TEST SCRIPT BEGIN ===
#! /bin/bash
export ARCH=x86_64
make docker-image-fedora V=1 NETWORK=1
time make docker-test-mingw@fedora J=14 NETWORK=1
=== TEST SCRIPT END ===




The full log is available at
http://patchew.org/logs/20200303104724.233375-1-ppandit@redhat.com/testing.docker-mingw@fedora/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v3 0/2] net: tulip: add checks to avoid OOB access
  2020-03-03 10:47 [PATCH v3 0/2] net: tulip: add checks to avoid OOB access P J P
                   ` (3 preceding siblings ...)
  2020-03-03 10:54 ` no-reply
@ 2020-03-03 10:54 ` no-reply
  2020-03-03 10:56 ` no-reply
  5 siblings, 0 replies; 14+ messages in thread
From: no-reply @ 2020-03-03 10:54 UTC (permalink / raw)
  To: ppandit; +Cc: pjp, jasowang, qemu-devel, pangpei.lq, svens, ezrakiez

Patchew URL: https://patchew.org/QEMU/20200303104724.233375-1-ppandit@redhat.com/



Hi,

This series failed build test on FreeBSD host. Please find the details below.

=== TEST SCRIPT BEGIN ===
#!/bin/bash
# Testing script will be invoked under the git checkout with
# HEAD pointing to a commit that has the patches applied on top of "base"
# branch
if qemu-system-x86_64 --help >/dev/null 2>&1; then
  QEMU=qemu-system-x86_64
elif /usr/libexec/qemu-kvm --help >/dev/null 2>&1; then
  QEMU=/usr/libexec/qemu-kvm
else
  exit 1
fi
make vm-build-freebsd J=21 QEMU=$QEMU
exit 0
=== TEST SCRIPT END ===




The full log is available at
http://patchew.org/logs/20200303104724.233375-1-ppandit@redhat.com/testing.FreeBSD/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v3 0/2] net: tulip: add checks to avoid OOB access
  2020-03-03 10:47 [PATCH v3 0/2] net: tulip: add checks to avoid OOB access P J P
                   ` (4 preceding siblings ...)
  2020-03-03 10:54 ` no-reply
@ 2020-03-03 10:56 ` no-reply
  5 siblings, 0 replies; 14+ messages in thread
From: no-reply @ 2020-03-03 10:56 UTC (permalink / raw)
  To: ppandit; +Cc: pjp, jasowang, qemu-devel, pangpei.lq, svens, ezrakiez

Patchew URL: https://patchew.org/QEMU/20200303104724.233375-1-ppandit@redhat.com/



Hi,

This series failed the docker-quick@centos7 build test. Please find the testing commands and
their output below. If you have Docker installed, you can probably reproduce it
locally.

=== TEST SCRIPT BEGIN ===
#!/bin/bash
make docker-image-centos7 V=1 NETWORK=1
time make docker-test-quick@centos7 SHOW_ENV=1 J=14 NETWORK=1
=== TEST SCRIPT END ===




The full log is available at
http://patchew.org/logs/20200303104724.233375-1-ppandit@redhat.com/testing.docker-quick@centos7/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v3 0/2] net: tulip: add checks to avoid OOB access
  2020-03-03 10:54 ` [PATCH v3 0/2] net: tulip: add checks to avoid OOB access no-reply
@ 2020-03-05 12:16   ` P J P
  0 siblings, 0 replies; 14+ messages in thread
From: P J P @ 2020-03-05 12:16 UTC (permalink / raw)
  To: jasowang, svens; +Cc: pangpei.lq, qemu-devel, ezrakiez

+-- On Tue, 3 Mar 2020, no-reply@patchew.org wrote --+
| Patchew URL: https://patchew.org/QEMU/20200303104724.233375-1-ppandit@redhat.com/
| fatal: unable to access 'https://github.com/patchew-project/qemu/': Failed connect to github.com:443; No route to host

@Jason, @Sven,
 These errors seem unrelated to the patch series. Please see patch v3 when you 
get time.

Thank you.
--
 - P J P
8685 545E B54C 486B C6EB 271E E285 8B5A F050 DE8D



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v3 2/2] net: tulip: add .can_recieve routine
  2020-03-03 10:47 ` [PATCH v3 2/2] net: tulip: add .can_recieve routine P J P
@ 2020-03-06 13:08   ` Stefan Hajnoczi
  2020-03-16 18:01     ` P J P
  0 siblings, 1 reply; 14+ messages in thread
From: Stefan Hajnoczi @ 2020-03-06 13:08 UTC (permalink / raw)
  To: P J P
  Cc: Prasad J Pandit, Jason Wang, Qemu Developers, Li Qiang,
	Sven Schnelle, Ziming Zhang

[-- Attachment #1: Type: text/plain, Size: 828 bytes --]

On Tue, Mar 03, 2020 at 04:17:24PM +0530, P J P wrote:
> 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;
> +}

Are the required qemu_flush_queued_packets() calls in place so that
packet transfer wakes up again when .can_receive() transitions from
false to true?

(If qemu_flush_queued_packets() is missing then transmission hangs after
.can_receive() becomes false.)

Stefan

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v3 2/2] net: tulip: add .can_recieve routine
  2020-03-06 13:08   ` Stefan Hajnoczi
@ 2020-03-16 18:01     ` P J P
  2020-03-17  5:50       ` Jason Wang
  0 siblings, 1 reply; 14+ messages in thread
From: P J P @ 2020-03-16 18:01 UTC (permalink / raw)
  To: Stefan Hajnoczi
  Cc: Li Qiang, Jason Wang, Sven Schnelle, Qemu Developers, Ziming Zhang

  Hello Stefan, Jason,

+-- On Fri, 6 Mar 2020, Stefan Hajnoczi wrote --+
| > +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;
| > +}
| 
| Are the required qemu_flush_queued_packets() calls in place so that
| packet transfer wakes up again when .can_receive() transitions from
| false to true?

  Yes, qemu_flush_queued_packets() calls are in tulip_write(). Do we need to 
call tulip_can_receive() before each call?

Thank you.
--
Prasad J Pandit / Red Hat Product Security Team
8685 545E B54C 486B C6EB 271E E285 8B5A F050 DE8D



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v3 2/2] net: tulip: add .can_recieve routine
  2020-03-16 18:01     ` P J P
@ 2020-03-17  5:50       ` Jason Wang
  2020-03-17 10:49         ` P J P
  0 siblings, 1 reply; 14+ messages in thread
From: Jason Wang @ 2020-03-17  5:50 UTC (permalink / raw)
  To: P J P, Stefan Hajnoczi
  Cc: Li Qiang, Sven Schnelle, Qemu Developers, Ziming Zhang


On 2020/3/17 上午2:01, P J P wrote:
>    Hello Stefan, Jason,
>
> +-- On Fri, 6 Mar 2020, Stefan Hajnoczi wrote --+
> | > +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;
> | > +}
> |
> | Are the required qemu_flush_queued_packets() calls in place so that
> | packet transfer wakes up again when .can_receive() transitions from
> | false to true?
>
>    Yes, qemu_flush_queued_packets() calls are in tulip_write(). Do we need to
> call tulip_can_receive() before each call?


Probably not, just need to make sure the check in tulip_rx_stopped(s) 
matches the action that triggers qemu_flush_queued_packets() in 
tulip_write() is sufficient.

This to make sure net core can restore the receiving.

Btw, what's the point of checking rx_frame_len here?

Thanks


>
> Thank you.
> --
> Prasad J Pandit / Red Hat Product Security Team
> 8685 545E B54C 486B C6EB 271E E285 8B5A F050 DE8D



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v3 2/2] net: tulip: add .can_recieve routine
  2020-03-17  5:50       ` Jason Wang
@ 2020-03-17 10:49         ` P J P
  2020-03-18  2:07           ` Jason Wang
  0 siblings, 1 reply; 14+ messages in thread
From: P J P @ 2020-03-17 10:49 UTC (permalink / raw)
  To: Jason Wang
  Cc: Stefan Hajnoczi, Sven Schnelle, Qemu Developers, Ziming Zhang, Li Qiang

+-- On Tue, 17 Mar 2020, Jason Wang wrote --+
| > +-- On Fri, 6 Mar 2020, Stefan Hajnoczi wrote --+
| > | > +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;
| > | > +    }
|
| Btw, what's the point of checking rx_frame_len here?

tulip_can_recive() is called from tulip_receive(). IIUC non zero(0) 
'rx_frame_len' hints that s->rs_frame[] buffer still has unread data bytes and 
it can not receive new bytes. The check was earlier in tulip_receive().

Thank you.
--
Prasad J Pandit / Red Hat Product Security Team
8685 545E B54C 486B C6EB 271E E285 8B5A F050 DE8D



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v3 2/2] net: tulip: add .can_recieve routine
  2020-03-17 10:49         ` P J P
@ 2020-03-18  2:07           ` Jason Wang
  2020-03-19  9:58             ` P J P
  0 siblings, 1 reply; 14+ messages in thread
From: Jason Wang @ 2020-03-18  2:07 UTC (permalink / raw)
  To: P J P
  Cc: Stefan Hajnoczi, Sven Schnelle, Qemu Developers, Ziming Zhang, Li Qiang


On 2020/3/17 下午6:49, P J P wrote:
> +-- On Tue, 17 Mar 2020, Jason Wang wrote --+
> | > +-- On Fri, 6 Mar 2020, Stefan Hajnoczi wrote --+
> | > | > +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;
> | > | > +    }
> |
> | Btw, what's the point of checking rx_frame_len here?
>
> tulip_can_recive() is called from tulip_receive(). IIUC non zero(0)
> 'rx_frame_len' hints that s->rs_frame[] buffer still has unread data bytes and
> it can not receive new bytes. The check was earlier in tulip_receive().


Right, so need to make sure qemu_flush_ququed_packets() was called when 
rx_frame_len is zero.

Thanks



>
> Thank you.
> --
> Prasad J Pandit / Red Hat Product Security Team
> 8685 545E B54C 486B C6EB 271E E285 8B5A F050 DE8D



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v3 2/2] net: tulip: add .can_recieve routine
  2020-03-18  2:07           ` Jason Wang
@ 2020-03-19  9:58             ` P J P
  0 siblings, 0 replies; 14+ messages in thread
From: P J P @ 2020-03-19  9:58 UTC (permalink / raw)
  To: Jason Wang
  Cc: Stefan Hajnoczi, Sven Schnelle, Qemu Developers, Ziming Zhang, Li Qiang

  Hello Jason,

+-- On Wed, 18 Mar 2020, Jason Wang wrote --+
| Right, so need to make sure qemu_flush_ququed_packets() was called when 
| rx_frame_len is zero.

  Sent patch v4, with this call. Please see when you've time.

Thank you.
--
Prasad J Pandit / Red Hat Product Security Team
8685 545E B54C 486B C6EB 271E E285 8B5A F050 DE8D



^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2020-03-19  9:59 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-03 10:47 [PATCH v3 0/2] net: tulip: add checks to avoid OOB access P J P
2020-03-03 10:47 ` [PATCH v3 1/2] net: tulip: check frame size and r/w data length P J P
2020-03-03 10:47 ` [PATCH v3 2/2] net: tulip: add .can_recieve routine P J P
2020-03-06 13:08   ` Stefan Hajnoczi
2020-03-16 18:01     ` P J P
2020-03-17  5:50       ` Jason Wang
2020-03-17 10:49         ` P J P
2020-03-18  2:07           ` Jason Wang
2020-03-19  9:58             ` P J P
2020-03-03 10:54 ` [PATCH v3 0/2] net: tulip: add checks to avoid OOB access no-reply
2020-03-05 12:16   ` P J P
2020-03-03 10:54 ` no-reply
2020-03-03 10:54 ` no-reply
2020-03-03 10:56 ` no-reply

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.