From patchwork Thu Jul 13 14:05:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Tremer X-Patchwork-Id: 6992 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384 client-signature ECDSA (secp384r1) client-digest SHA384) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4R1xGJ05sSz3xHy for ; Thu, 13 Jul 2023 14:05:43 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4R1xGG394Vzdc; Thu, 13 Jul 2023 14:05:42 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4R1xGG1RJTz2y1l; Thu, 13 Jul 2023 14:05:42 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4R1xGD6hynz2xJm for ; Thu, 13 Jul 2023 14:05:40 +0000 (UTC) Received: from michael.haj.ipfire.org (michael.haj.ipfire.org [172.28.1.242]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384 client-signature ECDSA (secp384r1) client-digest SHA384) (Client CN "michael.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4R1xGD1Qk0zMS; Thu, 13 Jul 2023 14:05:40 +0000 (UTC) Received: by michael.haj.ipfire.org (Postfix, from userid 0) id 4R1xGC6ltWzThQ4; Thu, 13 Jul 2023 14:05:39 +0000 (UTC) From: Michael Tremer To: development@lists.ipfire.org Subject: [PATCH] fireinfo: Fix SEGV in detect_hypervisor() Date: Thu, 13 Jul 2023 14:05:38 +0000 Message-Id: <20230713140538.987905-1-michael.tremer@ipfire.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael Tremer Errors-To: development-bounces@lists.ipfire.org Sender: "Development" Fixes: #13155 - _fireinfo.detect_hypervisor() rises Segmentation fault Signed-off-by: Michael Tremer Acked-by: Peter Müller --- lfs/fireinfo | 1 + ...-one-error-when-detecting-hypervisor.patch | 38 +++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 src/patches/fireinfo-virt-fix-off-by-one-error-when-detecting-hypervisor.patch diff --git a/lfs/fireinfo b/lfs/fireinfo index 8b38885d6..629626d1e 100644 --- a/lfs/fireinfo +++ b/lfs/fireinfo @@ -75,6 +75,7 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/fireinfo/fireinfo-2.2.0-python-3.8.patch cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/fireinfo/fireinfo-system-blacklist-jetways-product-uuid.patch cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/fireinfo/fireinfo-system-ignore-when-the-serial-number-is-ssn.patch + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/fireinfo-virt-fix-off-by-one-error-when-detecting-hypervisor.patch cd $(DIR_APP) && [ -x "configure" ] || sh ./autogen.sh cd $(DIR_APP) && ./configure --prefix=/usr diff --git a/src/patches/fireinfo-virt-fix-off-by-one-error-when-detecting-hypervisor.patch b/src/patches/fireinfo-virt-fix-off-by-one-error-when-detecting-hypervisor.patch new file mode 100644 index 000000000..0799ecce5 --- /dev/null +++ b/src/patches/fireinfo-virt-fix-off-by-one-error-when-detecting-hypervisor.patch @@ -0,0 +1,38 @@ +From e3e68b9baa9723916b1999394432e9ad260cfaa2 Mon Sep 17 00:00:00 2001 +From: Michael Tremer +Date: Sat, 1 Jul 2023 09:08:48 +0000 +Subject: [PATCH] virt: Fix off-by-one error when detecting hypervisor + +Reported-by: Mauro Condarelli +Fixes: #13155 - _fireinfo.detect_hypervisor() rises Segmentation fault +Signed-off-by: Michael Tremer +--- + src/_fireinfo/fireinfo.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/_fireinfo/fireinfo.c b/src/_fireinfo/fireinfo.c +index 1d3f424..18edf34 100644 +--- a/src/_fireinfo/fireinfo.c ++++ b/src/_fireinfo/fireinfo.c +@@ -32,8 +32,8 @@ enum hypervisors { + HYPER_KVM, + HYPER_MSHV, + HYPER_VMWARE, ++ // Must always be last + HYPER_OTHER, +- HYPER_LAST /* for loop - must be last*/ + }; + + const char *hypervisor_ids[] = { +@@ -157,7 +157,7 @@ int detect_hypervisor(int *hypervisor) { + *hypervisor = HYPER_OTHER; + + if (*sig.text) { +- for (int id = HYPER_NONE + 1; id < HYPER_LAST; id++) { ++ for (int id = HYPER_NONE + 1; id < HYPER_OTHER; id++) { + if (strcmp(hypervisor_ids[id], sig.text) == 0) { + *hypervisor = id; + break; +-- +2.39.2 +