From nobody Sun Apr 12 22:42:06 2026 Received: from cstnet.cn (smtp81.cstnet.cn [159.226.251.81]) (using TLSv1.2 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8611C34D3B0 for ; Fri, 3 Apr 2026 05:33:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.226.251.81 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775194438; cv=none; b=lYERHQzgh1uivHnZ28nWy3Q3Zo7l2YEy91KE2O3kZ7tYsVrYjHRz6zvzZY2QJtsUFWHaz3zfEqXCsDSgz4tbXsBznuI1U32c2c6jo+B+Di8li18mZDVysI2ouNdtQapT0KmofxTw0PzFZB3Ni5vR0usy+3yC/WWnIaBdINS2yw8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775194438; c=relaxed/simple; bh=HcemLQISZWdnXw8z7yxJscnGpuA1oGG1IO/cKUniuH0=; h=From:Date:Message-ID:To:Cc:Subject; b=VV4RX2GlQ038uRKHFHZT1S6rsI+dc8+yS5PcljNt7DXyhA7TZdh8lDMrzt9KG8z4JI7THO/kz8e1pCCxp8JBk1E8teRMUZhHF/62cSyIGHad+sPEBj2EIs7QjwI+YxhB8GhGl8raMWDgG51Ewp4KBfrvksdRqwmkGNm0RrK9P9A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iscas.ac.cn; spf=pass smtp.mailfrom=iscas.ac.cn; arc=none smtp.client-ip=159.226.251.81 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iscas.ac.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=iscas.ac.cn Received: from 0002-arm-xen.resend.eml (unknown [111.196.245.197]) by APP-03 (Coremail) with SMTP id rQCowACHqeA9Uc9pjEK7DA--.32598S2; Fri, 03 Apr 2026 13:33:49 +0800 (CST) From: Pengpeng Hou Date: Fri, 3 Apr 2026 10:42:09 +0800 Message-ID: <20260403151502.2-dt-arm-xen-resend-pengpeng@iscas.ac.cn> To: Stefano Stabellini Cc: xen-devel@lists.xenproject.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, pengpeng@iscas.ac.cn Subject: [PATCH] ARM: xen: validate hypervisor compatible before parsing its version X-CM-TRANSID: rQCowACHqeA9Uc9pjEK7DA--.32598S2 X-Coremail-Antispam: 1UD129KBjvJXoW7Zr4rtFWkCF4rJr1kZF1UKFg_yoW8Zw4fpF Zakr9avFWrt3WxWa4IyFyv9Fy5GF4kXrW2qFykZ3Wjyrnrtw1rXrWIvF1SvFn3ArW8W343 ZrWjyFn5AF47X3DanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUkq14x267AKxVWUJVW8JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26ryj6F1UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4j 6F4UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s 0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xII jxv20xvE14v26r106r15McIj6I8E87Iv67AKxVW8JVWxJwAm72CE4IkC6x0Yz7v_Jr0_Gr 1lF7xvr2IY64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7MxkF7I0En4kS14v26r126r1D MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr 0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUAVWUtwCIc40Y0x0E wIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVWUJV W8JwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr0_Cr1lIxAI cVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7VUjG-e7UUUUU== X-CM-SenderInfo: pshqw1xhqjqxpvfd2hldfou0/ Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" fdt_find_hyper_node() reads the raw compatible property and then derives hyper_node.version from a prefix match before later printing it with %s. Flat DT properties are external boot input, and this path does not prove that the compatible string is NUL-terminated within its declared bounds. Fetch the first compatible entry with fdt_stringlist_get() so malformed unterminated properties are rejected before the version suffix is parsed. Signed-off-by: Pengpeng Hou --- arch/arm/xen/enlighten.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c index 4feed2c2498d..f69290a4c639 100644 --- a/arch/arm/xen/enlighten.c +++ b/arch/arm/xen/enlighten.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -218,8 +219,9 @@ static __initdata struct { static int __init fdt_find_hyper_node(unsigned long node, const char *unam= e, int depth, void *data) { - const void *s =3D NULL; + const char *s =3D NULL; int len; + size_t prefix_len =3D strlen(hyper_node.prefix); =20 if (depth !=3D 1 || strcmp(uname, "hypervisor") !=3D 0) return 0; @@ -227,10 +229,10 @@ static int __init fdt_find_hyper_node(unsigned long n= ode, const char *uname, if (of_flat_dt_is_compatible(node, hyper_node.compat)) hyper_node.found =3D true; =20 - s =3D of_get_flat_dt_prop(node, "compatible", &len); - if (strlen(hyper_node.prefix) + 3 < len && - !strncmp(hyper_node.prefix, s, strlen(hyper_node.prefix))) - hyper_node.version =3D s + strlen(hyper_node.prefix); + s =3D fdt_stringlist_get(initial_boot_params, node, "compatible", 0, &len= ); + if (s && len > prefix_len + 2 && + !strncmp(hyper_node.prefix, s, prefix_len)) + hyper_node.version =3D s + prefix_len; =20 /* * Check if Xen supports EFI by checking whether there is the --=20 2.50.1 (Apple Git-155)