From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id E449F1FF0E9 for ; Thu, 16 Jul 2026 04:31:57 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 0A3F6213FA; Thu, 16 Jul 2026 04:31:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784169069; x=1784773869; darn=lists.proxmox.com; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=+8RPmdYNFuxWoI+38Xi6MpN4eI6XQsl9Mj+yBvYR5dg=; b=DfOM4MIRxwp5BljvG6vMuQkVT7dO1UoMIG3MpQaWAUb5deqMZ6oYU3027OsaWirzCE +XpNMgfe9Ne8/CYRC38GIGkEeBI1Lw6so5sg3DkJEFHtQgGVKyVKdMkyEwq56rDJBoeQ /xwx/6h7WKi8PeGK8FTB7JofQnX4FlEEwir3bI/E8NEgDGzZ7lsY8OiuQxKUrFw+vsOj UzeUYeYRiYYPzlOIoFvGJP8qz2fhHwdwe3ESiaXCLIXxrObXT/tdUm9IMNcDOw/p084l uOgD/rSEpqXOZX8ECYiDvGUX3dk748MjOiiHyqpRKwO/xeT95RrITG+KoyH6JBMl5dXC TSOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784169069; x=1784773869; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=+8RPmdYNFuxWoI+38Xi6MpN4eI6XQsl9Mj+yBvYR5dg=; b=OfPxEbzJZe6vWI2LxgmZpl1aiurWLddX7L8GF80XHTLqMeppIF8XwZJeF3XI4YVJde rTDcJkS9rPb2e6zcJR4sZzHGYgVN55W3UZL3WwurgdVN3TEYHTEANeY4Xvgv6TbwZNZf 8uFgb70XZuHw/mJis5e5ABQd9MKlkmU8ufiKJOyNmPT31+54XZo4pAvd/von4L3k9CQT 8KXaRcSVnT+9ji7/EY1+4M/cvrUitfvKzwHjS5ndQA/P5kegEbLlpFSlrohyis3icDGW VuuGinatKXw5AbXNCCX5W6F6GMnIO4zQnozQxfesDwEZYFxrXPefllXpN5+PEevp8d1h 962Q== X-Forwarded-Encrypted: i=1; AHgh+Rq+mqWKS8pe14kdgeNoPNsEyfO+yOSqdlXdYS9o/vKpUxCc6TwHco/oVz9BT3l4OLSXk4LXzK1Qtz4=@lists.proxmox.com X-Gm-Message-State: AOJu0YyxxrvGoMD4c4jRfYEECJhpdz2wZqxxHz2tYUlbnYQnNAJ+X1rK o7PD2n4Nk7TBI5FyLsZiV00h3PD20Im7MHYsC3yNyPvnL2S4Ae77peu0 X-Gm-Gg: AfdE7cl2eGn5UoNMg22INYx0XlMIbspZVNPkPcd9UBmrpbypXa63NGCpmMFxfKmeaDi tLaXbn0NUupITFCImjj2a4M/3jAZR/xsOWFmA0FglBiI0LMBoauocqtVJ7707Hy35qsiN9YQTFS xP39PWRQ2a0Das8jLXbJq2Bi2h891Fw5m3TEgmRwr/Xicn3dbd4M5VVcy6kLSHutSE3BSUIXeeB 62UGIag/xJl/KzhGJniv8wEHbcZFso9gsr/sMm/OSbnQrpPWXk57VyXAOEV5f0mwzfbVId+8OnO WK1MRfYVfVmgLGE11foRbjqtE8JVIEpprTSJbcbDys6Cc9xc7C/3ANu4fCBczWKZukwmU84AJEX VVdm2u9+X+iuoz+voBc5v+/xniOmMWv9mNYYBplaqN7DlpZeYdHPHB41TE+0ZgUZ+Q9JbFtfa4m WduUqwWX6Zlda/Cb4aZw2lfQ== X-Received: by 2002:a17:90b:1845:b0:381:bc4c:da56 with SMTP id 98e67ed59e1d1-38e1ae5e1e0mr8283949a91.19.1784169069104; Wed, 15 Jul 2026 19:31:09 -0700 (PDT) Message-ID: Date: Thu, 16 Jul 2026 10:31:06 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH qemu-server] query-machine-capabilities: check vendor string length for strncmp To: =?UTF-8?Q?Fabian_Gr=C3=BCnbichler?= , pve-devel@lists.proxmox.com References: <20260603055031.106241-1-wukaiyang@loongfans.cn> <1783951945.bjj3it71oe.astroid@yuna.none> Content-Language: en-US From: Kaiyang Wu In-Reply-To: <1783951945.bjj3it71oe.astroid@yuna.none> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain DMARC_PASS -0.1 DMARC pass policy FREEMAIL_ENVFROM_END_DIGIT 1 Envelope-from freemail username ends in digit FREEMAIL_FROM 0.001 Sender email is commonly abused enduser mail provider RCVD_IN_DNSWL_NONE -0.0001 Sender listed at https://www.dnswl.org/, no trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: YQCI2UTUP7MHKJBMIRNTWQCVR2MNEAI5 X-Message-ID-Hash: YQCI2UTUP7MHKJBMIRNTWQCVR2MNEAI5 X-MailFrom: wukaiyang2003@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Kaiyang Wu X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Intel TDX and AMD SEV are both x86_64 only extensions [0] [1]. I wonder if the best approach for this issue is to just add a conditional compilation check for x86_64 target architecture. If that works I will switch to compile time architecture check in v2. [0]: https://docs.kernel.org/arch/x86/tdx.html [1]: https://docs.kernel.org/virt/kvm/x86/amd-memory-encryption.html On 2026-07-13 22:15, Fabian Grünbichler wrote: > On June 3, 2026 7:50 am, Kaiyang Wu wrote: >> Fix build error on unknown vendors ('fallback'): >> >> error: ‘strncmp’ of strings of length 7 and 12 and bound of 12 evaluates to nonzero [-Werror=string-compare] >> >> Signed-off-by: Kaiyang Wu >> --- >> src/query-machine-capabilities/query-machine-capabilities.c | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/src/query-machine-capabilities/query-machine-capabilities.c b/src/query-machine-capabilities/query-machine-capabilities.c >> index abb47acd..25d06db7 100644 >> --- a/src/query-machine-capabilities/query-machine-capabilities.c >> +++ b/src/query-machine-capabilities/query-machine-capabilities.c >> @@ -204,7 +204,7 @@ int main() { >> eprintf("Error writing to file '" OUTPUT_PATH "': %s\n", strerror(errno)); >> } >> >> - if (strncmp(vendor, "AuthenticAMD", 12) == 0) { >> + if (strncmp(vendor, "AuthenticAMD", strnlen(vendor, 12)) == 0) { > > this is wrong - if the vendor is "Authentic" the code would now think > it's AMD.. the same would be true if vendor is "AuthenticAMDsomething", > because it would only look at the first 12 bytes (granted, that is a > pre-existing issue ;)). > > instead, we'd first need to check for the length, and if it is 12, do > the existing checks, if not, either add checks for other vendors, or > reject/abort.. > >> cpu_caps_amd_sev_t caps_sev; >> query_cpu_capabilities_sev(&caps_sev); >> >> @@ -222,7 +222,7 @@ int main() { >> caps_sev.sev_es_support ? "true" : "false", >> caps_sev.sev_snp_support ? "true" : "false" >> ); >> - } else if (strncmp(vendor, "GenuineIntel", 12) == 0) { >> + } else if (strncmp(vendor, "GenuineIntel", strnlen(vendor, 12)) == 0) { > > same applies here, but with `Genuine` (or any other substring prefix of > `GenuineIntel`).. > >> cpu_caps_intel_tdx_t caps_tdx; >> if (query_cpu_capabilities_tdx(&caps_tdx) == 0) { >> ret = fprintf(file, >> -- >> 2.52.0 >> >> >> >> >> >