From patchwork Tue Jun 16 15:34:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 188074 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp3786221ilo; Tue, 16 Jun 2020 09:10:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwMJ0ZnQTQrJcmKxD7zkiXZ0BwWryigbYgsaK1WH5QSUtFrQSmzB5f0oYMsmYD0h3GCUWFx X-Received: by 2002:a50:9ee4:: with SMTP id a91mr3444825edf.172.1592323811859; Tue, 16 Jun 2020 09:10:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592323811; cv=none; d=google.com; s=arc-20160816; b=dlP7HJ2xCgNNuH4vDhoopyIWJtBwIbLBxmMLxI+WxY/0pGANzqXHDgTnGWSUQ9IqJX Sjs8yqQS5z3wPcjcKBUU+TGve4TuJfy7xqdPQ1051CaDlRjJZPuWTaZIVd9LL5wygYup zOv3zhT/5agdetDiwmAcj4GLwWDdYylw7VjaUOE580hViWdjoO1KQYczMFq4xhnBGcE+ EIeJzYfWytpyhRs75Rc0I/G9/yay2t+srQKfDBANqeHgVEMnl2nYUnJ0MmqOVEqueLcp kLMqXfsop7W6yw80FvgXFcOUiMu709yITzs/LMpig/UFfR4h656zH4XTE/Vrep+VB/DV jLeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8VQU9jJM7kgAPOE33cFcrweAxsHkqLB/pIcZ3pe1+DY=; b=lf55Iy6qGp1ICKCom5IUfjxijNKZAKix6p+Q4lWDRc4AwH23WEZ2E6bOz/f6mH4qQQ e1P9mrZ+RW9FEIJbnlZZeSVdGHcpvx7+GDn9vflcJDCW+bykSGceKljeiy6WcZ5wHXRl FHH72ayCKDqVx/AzxZydRozDYG6VZOS1xlnjf/WFKEClxxuDXNv0UNs6HEBFtVMFK3kv 1l9NJfo38HrjJjuzKTaYHlg9OpOenH5kMzlu28ID3fmRuBQApXmPgYeivDA6XfDoBth2 VxIMR7ETWSJ5dCNV5ETWyY/6sd61269ZPKjb3MTooYJk6Hbexl34Cy/M9ndJwsqlmvDS wCog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2RhHzeF6; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y22si11500681ejq.391.2020.06.16.09.10.11; Tue, 16 Jun 2020 09:10:11 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2RhHzeF6; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730211AbgFPQKC (ORCPT + 15 others); Tue, 16 Jun 2020 12:10:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:35654 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731524AbgFPPo4 (ORCPT ); Tue, 16 Jun 2020 11:44:56 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4EA4B21475; Tue, 16 Jun 2020 15:44:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592322295; bh=qPXtMOTdflutZMIJ3Kxe+EfHyqUsxZqyhk7CaUbd0Do=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2RhHzeF6FcWwjVkj0fJ2D+N6ImbGM64JMTwLvH3N27tjqVQHxjOyfS0BSgIh/VMmT Ohzv0EeTYiJID8rabn64Eb1dRiTJ4i2PSoP1tAaVYQ81+9sh6t3GftnGg7YNwZDo2b Ft8RQ3tKrcn30HaEjqDNtJae9SgPX+AoVwQcjX34= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Will Deacon , Ard Biesheuvel , Nick Desaulniers , Jeremy Linton , Lorenzo Pieralisi Subject: [PATCH 5.7 076/163] arm64: acpi: fix UBSAN warning Date: Tue, 16 Jun 2020 17:34:10 +0200 Message-Id: <20200616153110.486696417@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200616153106.849127260@linuxfoundation.org> References: <20200616153106.849127260@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Nick Desaulniers commit a194c33f45f83068ef13bf1d16e26d4ca3ecc098 upstream. Will reported a UBSAN warning: UBSAN: null-ptr-deref in arch/arm64/kernel/smp.c:596:6 member access within null pointer of type 'struct acpi_madt_generic_interrupt' CPU: 0 PID: 0 Comm: swapper Not tainted 5.7.0-rc6-00124-g96bc42ff0a82 #1 Call trace: dump_backtrace+0x0/0x384 show_stack+0x28/0x38 dump_stack+0xec/0x174 handle_null_ptr_deref+0x134/0x174 __ubsan_handle_type_mismatch_v1+0x84/0xa4 acpi_parse_gic_cpu_interface+0x60/0xe8 acpi_parse_entries_array+0x288/0x498 acpi_table_parse_entries_array+0x178/0x1b4 acpi_table_parse_madt+0xa4/0x110 acpi_parse_and_init_cpus+0x38/0x100 smp_init_cpus+0x74/0x258 setup_arch+0x350/0x3ec start_kernel+0x98/0x6f4 This is from the use of the ACPI_OFFSET in arch/arm64/include/asm/acpi.h. Replace its use with offsetof from include/linux/stddef.h which should implement the same logic using __builtin_offsetof, so that UBSAN wont warn. Reported-by: Will Deacon Suggested-by: Ard Biesheuvel Signed-off-by: Nick Desaulniers Reviewed-by: Jeremy Linton Acked-by: Lorenzo Pieralisi Cc: stable@vger.kernel.org Link: https://lore.kernel.org/lkml/20200521100952.GA5360@willie-the-truck/ Link: https://lore.kernel.org/r/20200608203818.189423-1-ndesaulniers@google.com Signed-off-by: Will Deacon Signed-off-by: Greg Kroah-Hartman --- arch/arm64/include/asm/acpi.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/arch/arm64/include/asm/acpi.h +++ b/arch/arm64/include/asm/acpi.h @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -31,14 +32,14 @@ * is therefore used to delimit the MADT GICC structure minimum length * appropriately. */ -#define ACPI_MADT_GICC_MIN_LENGTH ACPI_OFFSET( \ +#define ACPI_MADT_GICC_MIN_LENGTH offsetof( \ struct acpi_madt_generic_interrupt, efficiency_class) #define BAD_MADT_GICC_ENTRY(entry, end) \ (!(entry) || (entry)->header.length < ACPI_MADT_GICC_MIN_LENGTH || \ (unsigned long)(entry) + (entry)->header.length > (end)) -#define ACPI_MADT_GICC_SPE (ACPI_OFFSET(struct acpi_madt_generic_interrupt, \ +#define ACPI_MADT_GICC_SPE (offsetof(struct acpi_madt_generic_interrupt, \ spe_interrupt) + sizeof(u16)) /* Basic configuration for ACPI */