From patchwork Fri May 26 20:17:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 9751113 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6876C60246 for ; Fri, 26 May 2017 20:20:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5B0A328334 for ; Fri, 26 May 2017 20:20:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4E0DA28347; Fri, 26 May 2017 20:20:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id 496C128334 for ; Fri, 26 May 2017 20:20:48 +0000 (UTC) Received: (qmail 9522 invoked by uid 550); 26 May 2017 20:18:49 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 9375 invoked from network); 26 May 2017 20:18:44 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=L8OpIYiJnq/mLguQ+Nbckj6ATDF4zxIDFssdOWEMpX0=; b=anAxi/gPMdEbA9vbIYqbxjbYmY5pJR5d06y8cEnW2vb4r5X0+mJgtZxsgBYBImEoC8 a5nLY++e3RovLv9UispmxsVr4OiNa/abJItgzs/deZ4jak2Teny12CxlPfrcKidQOfPN 5372Is/9tn8Kvjoq2t3TdVtCC/RZwPM/yobJA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=L8OpIYiJnq/mLguQ+Nbckj6ATDF4zxIDFssdOWEMpX0=; b=q5R0XVFqN9gpMgyteBwaXxIzb0rkfLpnoTyhNUEu4sNqaUl+y9jqBfwhWyMMOZKQdP bfJm4xAL+2FyRjlAhetorpq9micNvmqe0NlrTOMY095yUX41Kr9yLjkZsUOishQWNfcK FSpv2OVmB3iPGuEoAd38rrWCbFar//P5UpF7lgCos2VEXaOSinsNFAmvTBwT1cStT0xs bnE5pm7DOTsuz8kkq2g3ffOZQERong6m+PEaRImejQwtMKouXZ/2p5YQrCOJeBSF98xc 5NGnZmE2vZIuqsYgUla2kSX1aTlgXqegvBXnMeIPh4XIDB0cXGHMmPMfdGFI4p2puITF M68g== X-Gm-Message-State: AODbwcDPTbyeHP5fFbOv1+m5mWfX2VpApPbnvLW2vX5O4OwcOvBRF1P3 fCBFZHNVGnAxyCRZ X-Received: by 10.84.229.79 with SMTP id d15mr60045325pln.93.1495829912906; Fri, 26 May 2017 13:18:32 -0700 (PDT) From: Kees Cook To: kernel-hardening@lists.openwall.com Cc: Kees Cook , Bob Moore , Lv Zheng , "Rafael J . Wysocki" , Laura Abbott , x86@kernel.org, linux-kernel@vger.kernel.org Date: Fri, 26 May 2017 13:17:24 -0700 Message-Id: <1495829844-69341-21-git-send-email-keescook@chromium.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1495829844-69341-1-git-send-email-keescook@chromium.org> References: <1495829844-69341-1-git-send-email-keescook@chromium.org> Subject: [kernel-hardening] [PATCH v2 20/20] ACPICA: Use designated initializers X-Virus-Scanned: ClamAV using ClamSMTP The struct layout randomization plugin detects and randomizes any structs that contain only function pointers. Once layout is randomized, all initialization must be designated or the compiler will misalign the assignments. This switches all the ACPICA function pointer struct to use designated initializers, using the proposed upstream ACPICA macro: https://github.com/acpica/acpica/pull/248/ Cc: Bob Moore Cc: Lv Zheng Cc: Rafael J. Wysocki Signed-off-by: Kees Cook --- drivers/acpi/acpica/hwxfsleep.c | 14 +++++++++----- include/acpi/platform/acenv.h | 4 ++++ include/acpi/platform/aclinux.h | 2 ++ scripts/gcc-plugins/randomize_layout_plugin.c | 4 ---- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/drivers/acpi/acpica/hwxfsleep.c b/drivers/acpi/acpica/hwxfsleep.c index 5733b1167e46..558fe4cdf29a 100644 --- a/drivers/acpi/acpica/hwxfsleep.c +++ b/drivers/acpi/acpica/hwxfsleep.c @@ -70,11 +70,15 @@ static acpi_status acpi_hw_sleep_dispatch(u8 sleep_state, u32 function_id); /* Legacy functions are optional, based upon ACPI_REDUCED_HARDWARE */ static struct acpi_sleep_functions acpi_sleep_dispatch[] = { - {ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_sleep), - acpi_hw_extended_sleep}, - {ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_wake_prep), - acpi_hw_extended_wake_prep}, - {ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_wake), acpi_hw_extended_wake} + {ACPI_STRUCT_INIT (legacy_function, + ACPI_HW_OPTIONAL_FUNCTION (acpi_hw_legacy_sleep)), + ACPI_STRUCT_INIT (extended_function, acpi_hw_extended_sleep) }, + {ACPI_STRUCT_INIT (legacy_function, + ACPI_HW_OPTIONAL_FUNCTION (acpi_hw_legacy_wake_prep)), + ACPI_STRUCT_INIT (extended_function, acpi_hw_extended_wake_prep) }, + {ACPI_STRUCT_INIT (legacy_function, + ACPI_HW_OPTIONAL_FUNCTION (acpi_hw_legacy_wake)), + ACPI_STRUCT_INIT (extended_function, acpi_hw_extended_wake) } }; /* diff --git a/include/acpi/platform/acenv.h b/include/acpi/platform/acenv.h index 09994b063243..912563c66948 100644 --- a/include/acpi/platform/acenv.h +++ b/include/acpi/platform/acenv.h @@ -382,4 +382,8 @@ #define ACPI_INIT_FUNCTION #endif +#ifndef ACPI_STRUCT_INIT +#define ACPI_STRUCT_INIT(field, value) value +#endif + #endif /* __ACENV_H__ */ diff --git a/include/acpi/platform/aclinux.h b/include/acpi/platform/aclinux.h index a39e3f67616f..047f13865608 100644 --- a/include/acpi/platform/aclinux.h +++ b/include/acpi/platform/aclinux.h @@ -178,6 +178,8 @@ #define ACPI_MSG_BIOS_ERROR KERN_ERR "ACPI BIOS Error (bug): " #define ACPI_MSG_BIOS_WARNING KERN_WARNING "ACPI BIOS Warning (bug): " +#define ACPI_STRUCT_INIT(field, value) .field = value + #else /* !__KERNEL__ */ #define ACPI_USE_STANDARD_HEADERS diff --git a/scripts/gcc-plugins/randomize_layout_plugin.c b/scripts/gcc-plugins/randomize_layout_plugin.c index bb2c6789c4b7..e1526554487e 100644 --- a/scripts/gcc-plugins/randomize_layout_plugin.c +++ b/scripts/gcc-plugins/randomize_layout_plugin.c @@ -346,10 +346,6 @@ static int relayout_struct(tree type) !strcmp((const char *)ORIG_TYPE_NAME(type), "RAWPCIFACTORY")) return 0; - /* Skip ACPICA structs until refreshed with designated_init. */ - if (!strcmp((const char *)ORIG_TYPE_NAME(type), "acpi_sleep_functions")) - return 0; - /* throw out any structs in uapi */ xloc = expand_location(DECL_SOURCE_LOCATION(TYPE_FIELDS(type)));