Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1828905imm; Mon, 3 Sep 2018 10:29:54 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZ73kTTOe2RlJ2ypAz0G8VV59rFNTNoHo5wmPfCBoyvPtGtvDBHasCQbPqSUy0G5UMFemXo X-Received: by 2002:a17:902:8ec8:: with SMTP id x8-v6mr29557068plo.308.1535995794111; Mon, 03 Sep 2018 10:29:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535995794; cv=none; d=google.com; s=arc-20160816; b=J3mFPastZmkYLIDgWEzR5GbwONh265GsFqv0VhqL93eZt7L0W1Mjds4eW2flGRXGOB xRrDXZ/D9kFC858Nz9T4KCQl9jqcuYJ1xjMNzJUnlsepJsyA7XIP35z1wWOsEjH6ZuAG vGQuFw6E6ZnM6gPSiJnp7s5RFWtLnGn/bC0OCBn4n9HfVjkNhmMUwcPJJlY79fXHRu+d wLT6K6q6283OeaWbrbwRdNwUN4tFRkmUMHvC1aTel+yxYVnYkEBdqa/neQH4//OOQHwh ZINApU9xUz3crvs8BsCRBhrqo7O2qMeuYIksgXTnNJ6SbXczTWBRuM0+ypsgptxQFdhA lTxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=bmHkfaoVASc2Zs7FWkKUJabnjhfQB2+8hDyPZLXh+T8=; b=zOpI4g0taA5yluna4crz8PDkpe6Ro2yn1Wt/cedWHSFVlsEK1Pm5CyrTaZ8gR9zsEW 8Xlx28Bn6PTT9BH+l+4Ef0V4a58ho3t5h/myjCcX8QPOqBCX+xtv/+qikA6a8e32xoJu 14nmDb1pRuW56WvmzqyI6Cx8O8bXvdmWFRp6ih4Jx4UYL0MbkOlMkOPniHPwFKBpRJBm agKeW+wfevxeye2rYNbAggqua1yExslqwBho28kBkuw4l6PCjOl9M+Rtcpgq8jU0YvTO WwLgmkG7HqjALlvH4w7ZeLQJpYmhRhoE2LNzwoZ2JcinWgcfunX5bS4wC2MfJscdu7/p HRAg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i26-v6si18904775pgn.589.2018.09.03.10.29.39; Mon, 03 Sep 2018 10:29:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731171AbeICVti (ORCPT + 99 others); Mon, 3 Sep 2018 17:49:38 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:46436 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731162AbeICVth (ORCPT ); Mon, 3 Sep 2018 17:49:37 -0400 Received: from localhost (ip-213-127-74-90.ip.prioritytelecom.net [213.127.74.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 34071D18; Mon, 3 Sep 2018 17:28:29 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Valdis Kletnieks , Kees Cook , Lance Albertson Subject: [PATCH 4.14 165/165] gcc-plugins: Use dynamic initializers Date: Mon, 3 Sep 2018 18:57:31 +0200 Message-Id: <20180903165705.371605015@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180903165655.003605184@linuxfoundation.org> References: <20180903165655.003605184@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 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 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Kees Cook commit b86729109c5fd0a480300f40608aac68764b5adf upstream. GCC 8 changed the order of some fields and is very picky about ordering in static initializers, so instead just move to dynamic initializers, and drop the redundant already-zero field assignments. Suggested-by: Valdis Kletnieks Signed-off-by: Kees Cook Cc: Lance Albertson Signed-off-by: Greg Kroah-Hartman --- scripts/gcc-plugins/latent_entropy_plugin.c | 17 +---- scripts/gcc-plugins/randomize_layout_plugin.c | 75 +++++++------------------- scripts/gcc-plugins/structleak_plugin.c | 19 ++---- 3 files changed, 33 insertions(+), 78 deletions(-) --- a/scripts/gcc-plugins/latent_entropy_plugin.c +++ b/scripts/gcc-plugins/latent_entropy_plugin.c @@ -255,21 +255,14 @@ static tree handle_latent_entropy_attrib return NULL_TREE; } -static struct attribute_spec latent_entropy_attr = { - .name = "latent_entropy", - .min_length = 0, - .max_length = 0, - .decl_required = true, - .type_required = false, - .function_type_required = false, - .handler = handle_latent_entropy_attribute, -#if BUILDING_GCC_VERSION >= 4007 - .affects_type_identity = false -#endif -}; +static struct attribute_spec latent_entropy_attr = { }; static void register_attributes(void *event_data __unused, void *data __unused) { + latent_entropy_attr.name = "latent_entropy"; + latent_entropy_attr.decl_required = true; + latent_entropy_attr.handler = handle_latent_entropy_attribute; + register_attribute(&latent_entropy_attr); } --- a/scripts/gcc-plugins/randomize_layout_plugin.c +++ b/scripts/gcc-plugins/randomize_layout_plugin.c @@ -580,68 +580,35 @@ static void finish_type(void *event_data return; } -static struct attribute_spec randomize_layout_attr = { - .name = "randomize_layout", - // related to args - .min_length = 0, - .max_length = 0, - .decl_required = false, - // need type declaration - .type_required = true, - .function_type_required = false, - .handler = handle_randomize_layout_attr, -#if BUILDING_GCC_VERSION >= 4007 - .affects_type_identity = true -#endif -}; +static struct attribute_spec randomize_layout_attr = { }; +static struct attribute_spec no_randomize_layout_attr = { }; +static struct attribute_spec randomize_considered_attr = { }; +static struct attribute_spec randomize_performed_attr = { }; -static struct attribute_spec no_randomize_layout_attr = { - .name = "no_randomize_layout", - // related to args - .min_length = 0, - .max_length = 0, - .decl_required = false, - // need type declaration - .type_required = true, - .function_type_required = false, - .handler = handle_randomize_layout_attr, +static void register_attributes(void *event_data, void *data) +{ + randomize_layout_attr.name = "randomize_layout"; + randomize_layout_attr.type_required = true; + randomize_layout_attr.handler = handle_randomize_layout_attr; #if BUILDING_GCC_VERSION >= 4007 - .affects_type_identity = true + randomize_layout_attr.affects_type_identity = true; #endif -}; -static struct attribute_spec randomize_considered_attr = { - .name = "randomize_considered", - // related to args - .min_length = 0, - .max_length = 0, - .decl_required = false, - // need type declaration - .type_required = true, - .function_type_required = false, - .handler = handle_randomize_considered_attr, + no_randomize_layout_attr.name = "no_randomize_layout"; + no_randomize_layout_attr.type_required = true; + no_randomize_layout_attr.handler = handle_randomize_layout_attr; #if BUILDING_GCC_VERSION >= 4007 - .affects_type_identity = false + no_randomize_layout_attr.affects_type_identity = true; #endif -}; -static struct attribute_spec randomize_performed_attr = { - .name = "randomize_performed", - // related to args - .min_length = 0, - .max_length = 0, - .decl_required = false, - // need type declaration - .type_required = true, - .function_type_required = false, - .handler = handle_randomize_performed_attr, -#if BUILDING_GCC_VERSION >= 4007 - .affects_type_identity = false -#endif -}; + randomize_considered_attr.name = "randomize_considered"; + randomize_considered_attr.type_required = true; + randomize_considered_attr.handler = handle_randomize_considered_attr; + + randomize_performed_attr.name = "randomize_performed"; + randomize_performed_attr.type_required = true; + randomize_performed_attr.handler = handle_randomize_performed_attr; -static void register_attributes(void *event_data, void *data) -{ register_attribute(&randomize_layout_attr); register_attribute(&no_randomize_layout_attr); register_attribute(&randomize_considered_attr); --- a/scripts/gcc-plugins/structleak_plugin.c +++ b/scripts/gcc-plugins/structleak_plugin.c @@ -57,21 +57,16 @@ static tree handle_user_attribute(tree * return NULL_TREE; } -static struct attribute_spec user_attr = { - .name = "user", - .min_length = 0, - .max_length = 0, - .decl_required = false, - .type_required = false, - .function_type_required = false, - .handler = handle_user_attribute, -#if BUILDING_GCC_VERSION >= 4007 - .affects_type_identity = true -#endif -}; +static struct attribute_spec user_attr = { }; static void register_attributes(void *event_data, void *data) { + user_attr.name = "user"; + user_attr.handler = handle_user_attribute; +#if BUILDING_GCC_VERSION >= 4007 + user_attr.affects_type_identity = true; +#endif + register_attribute(&user_attr); }