From: "Jan Beulich" Subject: [PATCH] x86/ACPI/x2APIC: guard against out of range ACPI or APIC IDs Date: Wed, 30 Oct 2013 14:28:04 +0000 Message-ID: <5271258402000078000FE219@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part380B1664.0__=" Return-path: Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1VbWkg-0004Tm-Ij for xen-devel@lists.xenproject.org; Wed, 30 Oct 2013 14:28:06 +0000 List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel Cc: Keir Fraser List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part380B1664.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Other than for the legacy APIC, the x2APIC MADT entries have valid ranges possibly extending beyond what our internal arrays can handle, and hence we need to guard ourselves against corrupting memory here. Signed-off-by: Jan Beulich --- a/xen/arch/x86/acpi/boot.c +++ b/xen/arch/x86/acpi/boot.c @@ -97,7 +97,20 @@ acpi_parse_x2apic(struct acpi_subtable_h =20 acpi_table_print_madt_entry(header); =20 - /* Record local apic id only when enabled */ + /* Record local apic id only when enabled and fitting. */ + if (processor->local_apic_id >=3D MAX_APICS || + processor->uid >=3D MAX_MADT_ENTRIES) { + printk("%sAPIC ID %#x and/or ACPI ID %#x beyond limit" + " - processor ignored\n", + processor->lapic_flags & ACPI_MADT_ENABLED ? + KERN_WARNING "WARNING: " : KERN_INFO, + processor->local_apic_id, processor->uid); + /* + * Must not return an error here, to prevent + * acpi_table_parse_entries() from terminating early. + */ + return 0 /* -ENOSPC */; + } if (processor->lapic_flags & ACPI_MADT_ENABLED) { x86_acpiid_to_apicid[processor->uid] =3D processor->local_apic_id; --=__Part380B1664.0__= Content-Type: text/plain; name="x86-too-large-ACPI-ID.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-too-large-ACPI-ID.patch" x86/ACPI/x2APIC: guard against out of range ACPI or APIC IDs=0A=0AOther = than for the legacy APIC, the x2APIC MADT entries have valid=0Aranges = possibly extending beyond what our internal arrays can handle,=0Aand hence = we need to guard ourselves against corrupting memory here.=0A=0ASigned-off-= by: Jan Beulich =0A=0A--- a/xen/arch/x86/acpi/boot.c=0A+= ++ b/xen/arch/x86/acpi/boot.c=0A@@ -97,7 +97,20 @@ acpi_parse_x2apic(struct= acpi_subtable_h=0A =0A acpi_table_print_madt_entry(header);=0A = =0A- /* Record local apic id only when enabled */=0A+ /* Record = local apic id only when enabled and fitting. */=0A+ if (processor->loca= l_apic_id >=3D MAX_APICS ||=0A+ processor->uid >=3D MAX_MADT_ENTRIES) = {=0A+ printk("%sAPIC ID %#x and/or ACPI ID %#x beyond limit"=0A+ = " - processor ignored\n",=0A+ processor->l= apic_flags & ACPI_MADT_ENABLED ?=0A+ KERN_WARNIN= G "WARNING: " : KERN_INFO,=0A+ processor->local_apic_id, = processor->uid);=0A+ /*=0A+ * Must not return an = error here, to prevent=0A+ * acpi_table_parse_entries() from = terminating early.=0A+ */=0A+ return 0 /* -ENOSPC = */;=0A+ }=0A if (processor->lapic_flags & ACPI_MADT_ENABLED) {=0A = x86_acpiid_to_apicid[processor->uid] =3D=0A processor->= local_apic_id;=0A --=__Part380B1664.0__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=__Part380B1664.0__=--