Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1506002ybg; Tue, 2 Jun 2020 11:49:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxQvgoBicBCH+H3lyuVSMHpfmNoNdW7q8bfgnoDSmbpjW5hv8hAZGnKlSicBRa6uqux5VZq X-Received: by 2002:a17:906:48d8:: with SMTP id d24mr24676859ejt.369.1591123763422; Tue, 02 Jun 2020 11:49:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591123763; cv=none; d=google.com; s=arc-20160816; b=oKy0gdXeMJD8fNv8sOAxykQJa0QMpcxESH2aPjmctEJwXPf4u/bhFRoE4Vvq3v0rst M75xidP6Gv79u1TDJ6hAg0JqWbPA9YW3890UeEw5GoIiOpNXnF7addNEPsg6b5a7iPEE I12+2Rf1oCvY0ltnEGVptth42dbmpQNYWlekoVz64ckaELxFIhV+p+voU7MYAwiJG2gb nL6j783Z1avG6jsnDy8++XJO8oa/VmlLJconX5d9NFazA3q6CDfJbNbst8YaFbT6RSSn iXFDTfUa0IC3+7/QQu8oCeKNXx5+CCJaa8mVrevx+EucF4I2Q1ajBE1lQ4A1jWvy9hc2 YMeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=d4Fn6K9sSJmLeIDx+5ZYAe4QSbvn6y+nwpagCeGiUag=; b=Mudj9/28+YgV+a05xTi8pqGTuGZU/xXBsFyilr8c0O8lPlblsOhVr1O8mx0YimE/hb KpzK3IXrNmKHfe9jMLsJoY3uk7gEOf+YACK9VaMELcAlINsR0UyN4jkUpBEt63RtAvC8 3U8OZpvnKatz85A8QltLasVq95RmtSh845H2VNj/sm+UC/YT/iFeqz3Cpvj4zaLwzg6k 9XSiu/cfOaPK659CClO2c0na72zbXwaMNci2z5iwa2mM8t/3OS8lVuoP+1Y4WlpOtRkH 9TGwkZbY7NCM3g9naZetFKKNWERzHHKmNw99ag6rbgI5gE8ASJry/a6YyRFJ7+Yx0Evu Y3cA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=eKdiwwUZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ce20si2178795edb.478.2020.06.02.11.49.00; Tue, 02 Jun 2020 11:49:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@google.com header.s=20161025 header.b=eKdiwwUZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728059AbgFBSqp (ORCPT + 99 others); Tue, 2 Jun 2020 14:46:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727011AbgFBSqo (ORCPT ); Tue, 2 Jun 2020 14:46:44 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17202C08C5C2 for ; Tue, 2 Jun 2020 11:46:44 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id m2so1963937pjv.2 for ; Tue, 02 Jun 2020 11:46:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=d4Fn6K9sSJmLeIDx+5ZYAe4QSbvn6y+nwpagCeGiUag=; b=eKdiwwUZgObjzDiAaWXu1fITlLXmWFNVxyer43d44+MrNvL++Xiz3qSBGvd3qGRHjI Tttx99hIYk/PtTW7oaCImk873psV+O0OzGhBXZ/uP9j5e0HmzUb/zO/QWkfmFl2vI2Kx PJB9AzlQsUHdGfyk1Q1wimhqFQbpxBSBHlBtOPR+Jsot0TQVv/8KFMZ0z76tCvV50LQW DWjAQ0Dr3AHCr/t/5eDi1u7XwiAkTtGOa01iij+qy8b+nONExiTZz0fOchK5yF/tO5zp hVKs02MSt1EtfZRUA3Qu/ce5Dk2Z/2sDkv60pJ4ehO06t140xSTjfjem19mVvbE+RZte VtDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=d4Fn6K9sSJmLeIDx+5ZYAe4QSbvn6y+nwpagCeGiUag=; b=cghxUpJguYF7IYkSTi9YNenWXK2+AM7AJRmrpuVWgze1iZ53ajyjgkrVxzv0IIRlBc Aq8fHFoIYtV86Raop5B+sddGC0KHR5jkWHctx+qxxOsdIquP2QSzm3E6CB7WEYEqkU+B H1llOCAIPj2Xs5a7Wlao+dN57ztqfWaVuoIxMxWnviW3fsiMnAIGNUfU5hBPQVA2MOqo zy2r8gajeDg0xoXMNlzcHJA/z/AT/t4E/JwXQrxfuNgbySXnPgTGzZH2go258A/bpNGW 7ktCcWY5w4W7Vlr6jzX3QzIlg314+WLDEK4sIguEnmXjUvvPLpqL+A8zZynNi7jAVnxJ wCeQ== X-Gm-Message-State: AOAM532lZudskrk8r9PfRV3XyDM4J0B1AxSWseRMx6F8VZEJeC9xqj53 /4DZpvAc0O4Y1fOYppM3VSD4YYUd2C+3TLPCGlJkwg== X-Received: by 2002:a17:902:341:: with SMTP id 59mr24917643pld.119.1591123603136; Tue, 02 Jun 2020 11:46:43 -0700 (PDT) MIME-Version: 1.0 References: <20200601231805.207441-1-ndesaulniers@google.com> In-Reply-To: From: Nick Desaulniers Date: Tue, 2 Jun 2020 11:46:31 -0700 Message-ID: Subject: Re: [PATCH] ACPICA: fix UBSAN warning using __builtin_offsetof To: "Kaneda, Erik" Cc: "Moore, Robert" , "Wysocki, Rafael J" , Len Brown , Ard Biesheuvel , "dvyukov@google.com" , "glider@google.com" , "guohanjun@huawei.com" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , "lorenzo.pieralisi@arm.com" , "mark.rutland@arm.com" , "pcc@google.com" , "rjw@rjwysocki.net" , "will@kernel.org" , "stable@vger.kernel.org" , "linux-acpi@vger.kernel.org" , "devel@acpica.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 1, 2020 at 5:03 PM Kaneda, Erik wrote: > > > Hi, > > > Will reported UBSAN warnings: > > UBSAN: null-ptr-deref in drivers/acpi/acpica/tbfadt.c:459:37 > > UBSAN: null-ptr-deref in arch/arm64/kernel/smp.c:596:6 > > > > Looks like the emulated offsetof macro ACPI_OFFSET is causing these. We > > can avoid this by using the compiler builtin, __builtin_offsetof. > > I'll take a look at this tomorrow > > > > The non-kernel runtime of UBSAN would print: > > runtime error: member access within null pointer of type for this macro. > > actypes.h is owned by ACPICA so we typically do not allow compiler-specific > extensions because the code is intended to be compiled using the C99 standard > without compiler extensions. We could allow this sort of thing in a Linux-specific > header file like include/acpi/platform/aclinux.h but I'll take a look at the error as well.. If I'm not allowed to touch that header, it looks like I can include (rather than my host's ) to get a definition of `offsetof` thats implemented in terms of `__builtin_offsetof`. I should be able to use that to replace uses of ACPI_OFFSET. Are any of these off limits? $ grep -rn ACPI_OFFSET arch/arm64/include/asm/acpi.h:34:#define ACPI_MADT_GICC_MIN_LENGTH ACPI_OFFSET( \ arch/arm64/include/asm/acpi.h:41:#define ACPI_MADT_GICC_SPE (ACPI_OFFSET(struct acpi_madt_generic_interrupt, \ include/acpi/actbl.h:376:#define ACPI_FADT_OFFSET(f) (u16) ACPI_OFFSET (struct acpi_table_fadt, f) drivers/acpi/acpica/acresrc.h:84:#define ACPI_RS_OFFSET(f) (u8) ACPI_OFFSET (struct acpi_resource,f) drivers/acpi/acpica/acresrc.h:85:#define AML_OFFSET(f) (u8) ACPI_OFFSET (union aml_resource,f) drivers/acpi/acpica/acinterp.h:17:#define ACPI_EXD_OFFSET(f) (u8) ACPI_OFFSET (union acpi_operand_object,f) drivers/acpi/acpica/acinterp.h:18:#define ACPI_EXD_NSOFFSET(f) (u8) ACPI_OFFSET (struct acpi_namespace_node,f) drivers/acpi/acpica/rsdumpinfo.c:16:#define ACPI_RSD_OFFSET(f) (u8) ACPI_OFFSET (union acpi_resource_data,f) drivers/acpi/acpica/rsdumpinfo.c:17:#define ACPI_PRT_OFFSET(f) (u8) ACPI_OFFSET (struct acpi_pci_routing_table,f) -- Thanks, ~Nick Desaulniers