From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by passt.top (Postfix, from userid 1000) id 549675A031D; Thu, 27 Jun 2024 01:45:36 +0200 (CEST) From: Stefano Brivio To: passt-dev@passt.top Subject: [PATCH 4/4] tap: Drop frames from guest whose length is more than remaining buffer Date: Thu, 27 Jun 2024 01:45:36 +0200 Message-ID: <20240626234536.3306466-5-sbrivio@redhat.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240626234536.3306466-1-sbrivio@redhat.com> References: <20240626234536.3306466-1-sbrivio@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: 7JOKSOMM453HXEACYDOUI7TEBIAXCNEO X-Message-ID-Hash: 7JOKSOMM453HXEACYDOUI7TEBIAXCNEO X-MailFrom: sbrivio@passt.top 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: 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: 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: p += sizeof(uint32_t); n -= sizeof(uint32_t); + if (l2len > (ssize_t)TAP_BUF_BYTES - n) + goto next; + /* At most one packet might not fit in a single read, and this * needs to be blocking. */ -- 2.43.0