qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2] net: tulip: check frame size and r/w data length


From: P J P
Subject: Re: [PATCH v2] net: tulip: check frame size and r/w data length
Date: Tue, 3 Mar 2020 16:27:05 +0530 (IST)

+-- On Mon, 24 Feb 2020, Jason Wang wrote --+
| > +        if (s->rx_frame_len + len >= sizeof(s->rx_frame)) {
| > +            return;
| > +        }
| What's the goal of this checking?

  To avoid potential OOB access while in pci_dma_write().

| >           pci_dma_write(&s->dev, desc->buf_addr2, s->rx_frame +
| >               (s->rx_frame_size - s->rx_frame_len), len);
|
| > +    if (size < 14 || size > sizeof(s->rx_frame) - 4
| > +        || s->rx_frame_len || tulip_rx_stopped(s)) {
| >           return 0;
| It's better to move those checks in .can_receive().

  I tried to move these checks to .can_recieve, but tulip_receive()
is called from tulip_receive_nc() and tulip_tx() and the 'size' check could
not be moved to can_receive().

| > +        } else if (s->tx_frame_len < sizeof(s->tx_frame)) {
| Should we use <= here?

  Done.
 
| > +    if (s->tx_frame_len + len1 >= sizeof(s->tx_frame)) {
| > +        return;
| > +    }
| I think it's better to add a return value here to make sure caller
| tulip_xmit_list_update() can exit the loop early

  Done.
 
| One more thing.
| It looks to me there could be a user trigger-able infinite loop in
| tun_list_update() through always set TDES0_OWN in its descriptors?

  Yes, defined TULIP_DESC_MAX=128 to restrict loop iterations to 128 
descriptors to avoid potential infinite loop.
  -> 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/net/ethernet/dec/tulip/tulip.h#n319

Sent patch v3 with above changes; Sorry about the delay.

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]