qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] net/tap: drop too small packets
@ 2025-07-16  7:28 Vladimir Sementsov-Ogievskiy
  2025-07-18  8:28 ` Lei Yang
  0 siblings, 1 reply; 2+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2025-07-16  7:28 UTC (permalink / raw)
  To: qemu-devel, jasowang; +Cc: vsementsov, d-tatianin, leiyang

Theoretically tap_read_packet() may return size less than
s->host_vnet_hdr_len, and next, we'll work with negative size
(in case of !s->using_vnet_hdr). Let's avoid it.

Don't proceed with size == s->host_vnet_hdr_len as well in case
of !s->using_vnet_hdr, it doesn't make sense.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
---

v2: change "<" -> "<="

 net/tap.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/net/tap.c b/net/tap.c
index 23536c09b46..2a859360193 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -190,6 +190,11 @@ static void tap_send(void *opaque)
             break;
         }
 
+        if (s->host_vnet_hdr_len && size <= s->host_vnet_hdr_len) {
+            /* Invalid packet */
+            break;
+        }
+
         if (s->host_vnet_hdr_len && !s->using_vnet_hdr) {
             buf  += s->host_vnet_hdr_len;
             size -= s->host_vnet_hdr_len;
-- 
2.48.1



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

* Re: [PATCH v2] net/tap: drop too small packets
  2025-07-16  7:28 [PATCH v2] net/tap: drop too small packets Vladimir Sementsov-Ogievskiy
@ 2025-07-18  8:28 ` Lei Yang
  0 siblings, 0 replies; 2+ messages in thread
From: Lei Yang @ 2025-07-18  8:28 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy; +Cc: qemu-devel, jasowang, d-tatianin

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

Tested this patch v2 again,everything works fine.

Tested-by: Lei Yang <leiyang@redhat.com>

On Wed, Jul 16, 2025 at 3:29 PM Vladimir Sementsov-Ogievskiy <
vsementsov@yandex-team.ru> wrote:

> Theoretically tap_read_packet() may return size less than
> s->host_vnet_hdr_len, and next, we'll work with negative size
> (in case of !s->using_vnet_hdr). Let's avoid it.
>
> Don't proceed with size == s->host_vnet_hdr_len as well in case
> of !s->using_vnet_hdr, it doesn't make sense.
>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
> ---
>
> v2: change "<" -> "<="
>
>  net/tap.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/net/tap.c b/net/tap.c
> index 23536c09b46..2a859360193 100644
> --- a/net/tap.c
> +++ b/net/tap.c
> @@ -190,6 +190,11 @@ static void tap_send(void *opaque)
>              break;
>          }
>
> +        if (s->host_vnet_hdr_len && size <= s->host_vnet_hdr_len) {
> +            /* Invalid packet */
> +            break;
> +        }
> +
>          if (s->host_vnet_hdr_len && !s->using_vnet_hdr) {
>              buf  += s->host_vnet_hdr_len;
>              size -= s->host_vnet_hdr_len;
> --
> 2.48.1
>
>

[-- Attachment #2: Type: text/html, Size: 1879 bytes --]

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

end of thread, other threads:[~2025-07-18  8:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-16  7:28 [PATCH v2] net/tap: drop too small packets Vladimir Sementsov-Ogievskiy
2025-07-18  8:28 ` Lei Yang

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