From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTP id 6ECBA5A004F for ; Fri, 28 Jun 2024 09:57:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1719561438; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KvR3/Xtgmk2xRyDxDMNvavxcl03M3fMkmaDzfS5z26M=; b=T1h3DeHKH/MZ2s4tQ4S+MOZREvR6StAGbkGVdS//rRgP7ZJZK3K7Y5U8evI8xgfnrqk/OM 2ESj2Z2iQkSNZRupAuAdv8cQSwfQml7OS9cwuD4vdcl2P8jz9DFUES5bY/KNpxtaEMplh2 MPqOINF4l5V7Gyl1147Z8hthK103fsk= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-614-X2T_XhuhPK-0cZPx478EDg-1; Fri, 28 Jun 2024 03:57:14 -0400 X-MC-Unique: X2T_XhuhPK-0cZPx478EDg-1 Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-44501497419so6167081cf.3 for ; Fri, 28 Jun 2024 00:57:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719561434; x=1720166234; h=content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=KvR3/Xtgmk2xRyDxDMNvavxcl03M3fMkmaDzfS5z26M=; b=kULb+5vgGT9bSnLnQKjeZb1tjn1Q5rAldqLtCl4KmPt+x+opw6FVn3o1+33ysbINeW C6i990hXiXCbDcydx5v0YumSOcQxW4wSfSVWlya+orCPfd3jBTC7IJc/cGZASf7P513Q d7UDsgdjs3Hivl0xzPjwqPtZmAfR/sKuN9tDnn85XlQfYVYgLdLc65ddjttrKE5+Ldsi q/Nyl/UqTxwpVob5AaC8e/azSD/0CJiuy38XA5HeGH4aGfHX01e0LSl9K72FwVmbGfFk 51WzA4uvtJVuLT8rxh/j3UCS76UAEvCMTmMZBqexyDPQTIkurNHuTD5wr43V1tbH9nwN a+QA== X-Gm-Message-State: AOJu0YwcLSZECgSx8S/FQwhBvQze8Feglchclvlqj/Zbz9UhBjQ1ugIB cZDYLPHbseurlEMTvK2OTp53ULsJ6AcNH1dCpTrdJIE+Vf4/SU4bDmiw1hv9MeVgzFNUVE+kME/ ky6Lw+Jfxqac6qUhdorqfgqASkedExVbt8lYPFddx58eKzmuj0Q== X-Received: by 2002:a05:622a:5cc:b0:441:3395:ece0 with SMTP id d75a77b69052e-444d9220932mr167067761cf.37.1719561434205; Fri, 28 Jun 2024 00:57:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFNNJmc96SZ1tivXiaKzG3XvITvCMYGN1pUjQnKdoXvd7MT52Mgj51BDNu+McqtvRZxOa1XFA== X-Received: by 2002:a05:622a:5cc:b0:441:3395:ece0 with SMTP id d75a77b69052e-444d9220932mr167067681cf.37.1719561433740; Fri, 28 Jun 2024 00:57:13 -0700 (PDT) Received: from maya.cloud.tilaa.com (maya.cloud.tilaa.com. [164.138.29.33]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-446513d31a1sm5277271cf.18.2024.06.28.00.57.10 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Jun 2024 00:57:10 -0700 (PDT) Date: Fri, 28 Jun 2024 09:56:35 +0200 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH 4/4] tap: Drop frames from guest whose length is more than remaining buffer Message-ID: <20240628095628.412a3f15@elisabeth> In-Reply-To: References: <20240626234536.3306466-1-sbrivio@redhat.com> <20240626234536.3306466-5-sbrivio@redhat.com> <20240627102057.2f452002@elisabeth> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: RORGKXL2H5XYJ32CKJCJ56JXRAL7H24V X-Message-ID-Hash: RORGKXL2H5XYJ32CKJCJ56JXRAL7H24V X-MailFrom: sbrivio@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top, Matej Hrica X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Fri, 28 Jun 2024 17:19:37 +1000 David Gibson wrote: > On Thu, Jun 27, 2024 at 10:21:04AM +0200, Stefano Brivio wrote: > > On Thu, 27 Jun 2024 11:30:02 +1000 > > David Gibson wrote: > > > > > On Thu, Jun 27, 2024 at 01:45:36AM +0200, Stefano Brivio wrote: > > > > This was reported by Matej a while ago, but we forgot to fix it. Even > > > > if the hypervisor is necessarily trusted by passt, as it can in any > > > > case terminate the guest or disrupt guest connectivity, it's a good > > > > idea to be robust against possible issues. > > > > > > > > Instead of resetting the connection to the hypervisor, just skip the > > > > offending frame, as we had a few cases where QEMU would get the > > > > length descriptor wrong, in the past. > > > > > > > > Reported-by: Matej Hrica > > > > Suggested-by: Matej Hrica > > > > Signed-off-by: Stefano Brivio > > > > --- > > > > tap.c | 3 +++ > > > > 1 file changed, 3 insertions(+) > > > > > > > > diff --git a/tap.c b/tap.c > > > > index 7f8c26d..bb993e0 100644 > > > > --- a/tap.c > > > > +++ b/tap.c > > > > @@ -1026,6 +1026,9 @@ redo: > > > > > > So.. I just realised there's a different pre-existing problem here, > > > above what's quoted in the patch we have: > > > > > > ssize_t l2len = ntohl(*(uint32_t *)p); > > > > > > On a platform where ssize_t is only 32-bits we could get a negative > > > value here, which would be very bad. > > > > We can't, because the length is anyway limited to the maximum IPv4 path > > MTU in any hypervisor we might be talking to. > > Only if we trust the hypervisor. And that the user didn't > misconfigure us to point the socket at something that's not actually a > hypervisor. And that it's not some future version of the hypervisor > configured to use a different framing format. And that our code is > robust enough to never get out of sync on the stream. > > I really think it's better to read this into a u32, and range sanity > check it before we do anything else. Right... see v2? -- Stefano