From patchwork Thu Apr 6 21:18:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 9668465 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 7A34A602B3 for ; Thu, 6 Apr 2017 21:21:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B633C285A1 for ; Thu, 6 Apr 2017 21:21:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AA9C4285E7; Thu, 6 Apr 2017 21:21:03 +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 B6E3A285A1 for ; Thu, 6 Apr 2017 21:21:02 +0000 (UTC) Received: (qmail 32551 invoked by uid 550); 6 Apr 2017 21:19:42 -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 29909 invoked from network); 6 Apr 2017 21:19:23 -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=YYVNP150ng+NbPAQULqRioj086/e256zqWCujPOm5LQ=; b=MiYARr4Zz0pDhqRC9k2SxCaslNiijrOZR+iaz+HckY7Q4z9vaQURovgXTMe2cL2noz y974rqVzMKo5N3NO8Z5lRj5EKbJIHk21aMG1zj8vY94bhy8JLlgwyoPtjxwehFAsxw0+ lK3VE0qrQTbBQzOLFXNRT09J+oQ+ta4VQF2Is= 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=YYVNP150ng+NbPAQULqRioj086/e256zqWCujPOm5LQ=; b=haZkcbhmiVUA9R17COm2RAQ5IqdBLchPd6l5lS8yveJzuJdfdQ5LZAac7h6cp2duZf yssQ7RHesq646O7ybWTo+RiK4dpTjTsTUKS+Kp02AlYCYJZgQ0eDHRamDhJquS3BWEiy W81Vy+5ANbEphnME6WYGOlnExRi6VSwrraZ//MOceK56BKS/4Yt1ejM26URycopL84qs KD6mVEotXP2FXNBldcDK5B/NVEiXX5I/nfu8zFK65flpJDlFYSg6KaMn9I1jrqwTMaVe +wuGNTG4DhzGMYkN6dV7AhdTu/K3QN40CzcBgTl7nVecc+ekW08/gC1t+PQanMu7C6u5 NyFg== X-Gm-Message-State: AFeK/H2gBOHIGHARJwL+4fQgAQgHwl+ykNgn8kkFgDPRmH3ORoOG7VvDeTXmEHNth8T4GwT3 X-Received: by 10.99.149.16 with SMTP id p16mr37693736pgd.112.1491513552061; Thu, 06 Apr 2017 14:19:12 -0700 (PDT) From: Kees Cook To: kernel-hardening@lists.openwall.com Cc: Kees Cook , Michael Leibowitz Date: Thu, 6 Apr 2017 14:18:33 -0700 Message-Id: <1491513513-84351-19-git-send-email-keescook@chromium.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1491513513-84351-1-git-send-email-keescook@chromium.org> References: <1491513513-84351-1-git-send-email-keescook@chromium.org> Subject: [kernel-hardening] [PATCH 18/18] 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. Signed-off-by: Kees Cook --- drivers/acpi/acpica/hwxfsleep.c | 17 ++++++++++++----- include/acpi/platform/acenv.h | 4 ++++ include/acpi/platform/aclinux.h | 2 ++ scripts/gcc-plugins/randomize_layout_plugin.c | 4 ---- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/drivers/acpi/acpica/hwxfsleep.c b/drivers/acpi/acpica/hwxfsleep.c index 5733b1167e46..f737e54412f6 100644 --- a/drivers/acpi/acpica/hwxfsleep.c +++ b/drivers/acpi/acpica/hwxfsleep.c @@ -70,11 +70,18 @@ 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 716bb877b3fd..3d4366996b2f 100644 --- a/scripts/gcc-plugins/randomize_layout_plugin.c +++ b/scripts/gcc-plugins/randomize_layout_plugin.c @@ -329,10 +329,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)));