Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp845131ybg; Mon, 1 Jun 2020 16:20:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzbsstOI/YhpFpJj9IvZZ5PUQBs/G3GOXsQFwEzpmz+dOtOrmlPD8U6+WGSRiT0kV9P7DCI X-Received: by 2002:a05:6402:362:: with SMTP id s2mr7427615edw.337.1591053632097; Mon, 01 Jun 2020 16:20:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591053632; cv=none; d=google.com; s=arc-20160816; b=Vkeqg2a08oN+7VdROMNZCIdJ8ol8WiArNhqOhPWpWIBetO4+GWi5iqL6IGsRiVvWyV C9kH+xAehbzf4I1rXl+9HO5rRUnOlBfaOfssE8TlQ2By+9vTL6/VABTThsA0M90KN5j+ 9rRLJN7It/deMt6WbWIgNFVdIjJsqlmw82clGLaLuS0CERKxQ5uwbENq0sON0LxpgVxi OTH+NPLhFA1gD+gsjIWTRop5hflmi9J3s4g6Y2+6GaOO89I/ZjHvgQzZE7cZh5p2EnO0 mdAcCxstciBCn9VDk0PeKcR2zFuDF1Txo3qeQSQLO/5pT81WKVZWTUlWoSUThJW/kJuT CPDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=m13wCjxvuAss7NYvH083DUgqdGzlzjUJaqo6EGXo6l8=; b=tZ/EnpW3F58hupKpXvpf8/VowDEHsx0bRGiG3k/L4gGP7s2cCpKWNA/WxUAE1FUqH0 YTprhBlrNeYXsir0QeIlbTbxW0KjiXDs2i+Y0OWlT1L73T9PMcozUzBW0vTTmkduFdLg onexqxca0HwUlVg6RTOYkwHjk4hDVsf6HW/KYIuEzlqPWbpd4JMGDKfiEPNriDkZkTux jErdjIDTUR0dp2V6iMrV93ESMlR07VtwhFNi/WFINXKTrt0FNu44TbJGaMfrLe5ZNzGz UV8/8Fv2eHIR81lJfo2uNLxawek9SzbWS/RyJ0CLRC2GjB/lqF9YHgq+GvYLryU7dRCQ jqow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=hGSPlVHM; 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 i16si505321ejf.732.2020.06.01.16.20.08; Mon, 01 Jun 2020 16:20:32 -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=hGSPlVHM; 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 S1728031AbgFAXSU (ORCPT + 99 others); Mon, 1 Jun 2020 19:18:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726099AbgFAXST (ORCPT ); Mon, 1 Jun 2020 19:18:19 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 798CCC05BD43 for ; Mon, 1 Jun 2020 16:18:18 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id f16so2921988ybp.5 for ; Mon, 01 Jun 2020 16:18:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=m13wCjxvuAss7NYvH083DUgqdGzlzjUJaqo6EGXo6l8=; b=hGSPlVHMPFqP8l1gdyaycFTDNYeJq+dmve4OcRx0o+NeFXjZUheZXksaQ3egykT3/V y3TrMe5GShycYHLIG9qR1qiVRi7FAG/jm43g8+Ud2xrrKhyEfB4RKkxmvPirR5YEKEDZ ZETulQIHcmg24tf9rxwGMM7FbhCEyAx78T7pYUbp+woYvGe0RFIl3qSPbmvVSpXfKVCc Tghecr2RnKGgHCBnF88MYyD2bMpevoM/xqi5YP+CqERPdo96+ROU7B14cSkX/GKFXAC/ 06Xdutj2ar9pRf2+dnMQTRlul7bsHDMZ7dWvbohS19s78wWY/19IxeUhRQTS4s5V5a2s pn7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=m13wCjxvuAss7NYvH083DUgqdGzlzjUJaqo6EGXo6l8=; b=kPvO6Frax3UHYN+gQDsKerUtDFUq1YIZmwLGClr6Wg4NWnsjpB2N8K59LYDJ8YeMEO TDjxUMjTllHCV5Ns8qbHX9SdbvlABegn1NLBhskPFarv5Yc4MDn4FfLI0E8MHyxHyyBu dOXikERQiTPn/4iSHlsK3bO7zkrO7BhKVZERRK1Raii8aRtpqNHSmI0CWA//i/D3xnZj w/cYY6/NDUFXLk2cQJIzpMBTYYiKz/axEMlapsFds+ZVVYBFHVdYLKDdSDtrmSlkLiC6 +ReL1BORnocdapRrtgjgH6ElcFkss9rTdQlEv8Gv0rwE9Nwm+umwGC6qhrRTDaj5CuSH hufQ== X-Gm-Message-State: AOAM532OlPmeQ2vQc+eDmIElAGEj8m5drGU+TmSrfMnI5fUmQreS2t70 NjxlyAaBEnMe81dych2sSO42s9zIDMYD2tBzyAU= X-Received: by 2002:a25:d28d:: with SMTP id j135mr34423503ybg.208.1591053497544; Mon, 01 Jun 2020 16:18:17 -0700 (PDT) Date: Mon, 1 Jun 2020 16:18:05 -0700 In-Reply-To: Message-Id: <20200601231805.207441-1-ndesaulniers@google.com> Mime-Version: 1.0 References: X-Mailer: git-send-email 2.27.0.rc2.251.g90737beb825-goog Subject: [PATCH] ACPICA: fix UBSAN warning using __builtin_offsetof From: Nick Desaulniers To: Robert Moore , Erik Kaneda , "Rafael J. Wysocki" , Len Brown Cc: 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, ndesaulniers@google.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 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. The non-kernel runtime of UBSAN would print: runtime error: member access within null pointer of type for this macro. Link: https://lore.kernel.org/lkml/20200521100952.GA5360@willie-the-truck/ Cc: stable@vger.kernel.org Reported-by: Will Deacon Suggested-by: Ard Biesheuvel Signed-off-by: Nick Desaulniers --- include/acpi/actypes.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h index 4defed58ea33..04359c70b198 100644 --- a/include/acpi/actypes.h +++ b/include/acpi/actypes.h @@ -508,7 +508,7 @@ typedef u64 acpi_integer; #define ACPI_TO_POINTER(i) ACPI_CAST_PTR (void, (acpi_size) (i)) #define ACPI_TO_INTEGER(p) ACPI_PTR_DIFF (p, (void *) 0) -#define ACPI_OFFSET(d, f) ACPI_PTR_DIFF (&(((d *) 0)->f), (void *) 0) +#define ACPI_OFFSET(d, f) __builtin_offsetof(d, f) #define ACPI_PHYSADDR_TO_PTR(i) ACPI_TO_POINTER(i) #define ACPI_PTR_TO_PHYSADDR(i) ACPI_TO_INTEGER(i) -- 2.27.0.rc2.251.g90737beb825-goog