public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Qing Zhao <qing.zhao@oracle.com>
To: Richard Biener <richard.guenther@gmail.com>,
	Jakub Jelinek <jakub@redhat.com>
Cc: Richard Sandiford <richard.sandiford@arm.com>,
	Nick Alcock via Gcc-patches <gcc-patches@gcc.gnu.org>,
	kees cook <keescook@chromium.org>
Subject: Re: [patch][version5]add -ftrivial-auto-var-init and variable attribute "uninitialized" to gcc
Date: Sun, 25 Jul 2021 16:26:36 +0000	[thread overview]
Message-ID: <2C3413FF-4386-4556-BABC-3DD9E5C5EFAD@oracle.com> (raw)
In-Reply-To: <3F8F960D-FC12-4520-90B3-C03569FDF649@oracle.com>



> On Jul 25, 2021, at 10:59 AM, Qing Zhao via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
> 
> Hi,
> 
> This is the 5th version of the patch for the new security feature for GCC.
> 
> I have tested it with bootstrap on both x86 and aarch64, regression testing on both x86 and aarch64.
> Also compile and run CPU2017, without any issue.

NOTE here, for CPU2017 -ftrivial-auto-var-init=pattern, I opened bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101586
And then the compilation and running of CPU2017 is done with my 5th patch + the patch provided from Jakub for PR101586.

Qing

> Please take a look and let me know your comments and suggestions.
> 
> thanks.
> 
> Qing
> 
> ******Compare with the 4th version, the following are the major changes:
> 
> 1. delete the code for handling "grp_to_be_debug_replaced" since they are not needed per Martin Jambor's suggestion.
> 2. for Pattern init, call __builtin_clear_padding after the call to .DEFERRED_INIT to initialize the paddings to zeroes;
> 3. for partially or fully initialized auto variables, call   __builtin_clear_padding before the real initialization to initialize
>    the paddings to zeroes.
> 4. Update the documentation with padding initialization to zeroes.
> 5. in order to reuse __builtin_clear_padding for auto init purpose, add one more dummy argument to indiciate whether it's for auto init or not,
>   if for auto init, do not emit error messages to avoid confusing users.
> 6. Add new testing cases to verify padding initializations.
> 7. rename some of the old testing cases to make the file name reflecting the testing purpose per Kees Cook's suggestions.
> 
> ******Please see version 4 at:
> https://gcc.gnu.org/pipermail/gcc-patches/2021-July/574642.html
> 
> ******ChangeLog is:
> gcc/ChangeLog:
> 
> 2021-07-23  qing zhao  <qing.zhao@oracle.com>
> 
>        * builtins.c (expand_builtin_memset): Make external visible.
>        * builtins.h (expand_builtin_memset): Declare extern.
>        * common.opt (ftrivial-auto-var-init=): New option.
>        * doc/extend.texi: Document the uninitialized attribute.
>        * doc/invoke.texi: Document -ftrivial-auto-var-init.
>        * flag-types.h (enum auto_init_type): New enumerated type
>        auto_init_type.
>        * gimple-fold.c (clear_padding_type): Add one new parameter.
>        (clear_padding_union): Likewise.
>        (clear_padding_emit_loop): Likewise.
>        (clear_type_padding_in_mask): Likewise.
>        (gimple_fold_builtin_clear_padding): Handle this new parameter.
>        * gimplify.c (gimple_add_init_for_auto_var): New function.
>        (maybe_with_size_expr): Forword declaration.
>        (build_deferred_init): New function.
>        (gimple_add_padding_init_for_auto_var): New function.
>        (gimplify_decl_expr): Add initialization to automatic variables per
>        users' requests.
>        (gimplify_call_expr): Add one new parameter for call to
>        __builtin_clear_padding.
>        (gimplify_modify_expr_rhs): Add padding initialization before
>        gimplify_init_constructor.
>        * internal-fn.c (INIT_PATTERN_VALUE): New macro.
>        (expand_DEFERRED_INIT): New function.
>        * internal-fn.def (DEFERRED_INIT): New internal function.
>        * tree-cfg.c (verify_gimple_call): Verify calls to .DEFERRED_INIT.
>        * tree-sra.c (generate_subtree_deferred_init): New function.
>        (sra_modify_deferred_init): Likewise.
>        (sra_modify_function_body): Handle calls to DEFERRED_INIT specially.
>        * tree-ssa-structalias.c (find_func_aliases_for_call): Likewise.
>        * tree-ssa-uninit.c (warn_uninit): Handle calls to DEFERRED_INIT
>        specially.
>        (check_defs): Likewise.
>        (warn_uninitialized_vars): Likewise.
>        * tree-ssa.c (ssa_undefined_value_p): Likewise.
> 
> gcc/c-family/ChangeLog:
> 
> 2021-07-23  qing zhao  <qing.zhao@oracle.com>
> 
>        * c-attribs.c (handle_uninitialized_attribute): New function.
>        (c_common_attribute_table): Add "uninitialized" attribute.
> 
> gcc/testsuite/ChangeLog:
> 
> 
> 2021-07-23  qing zhao  <qing.zhao@oracle.com>
> 
>        * c-c++-common/auto-init-1.c: New test.
>        * c-c++-common/auto-init-10.c: New test.
>        * c-c++-common/auto-init-11.c: New test.
>        * c-c++-common/auto-init-12.c: New test.
>        * c-c++-common/auto-init-13.c: New test.
>        * c-c++-common/auto-init-14.c: New test.
>        * c-c++-common/auto-init-15.c: New test.
>        * c-c++-common/auto-init-16.c: New test.
>        * c-c++-common/auto-init-2.c: New test.
>        * c-c++-common/auto-init-3.c: New test.
>        * c-c++-common/auto-init-4.c: New test.
>        * c-c++-common/auto-init-5.c: New test.
>        * c-c++-common/auto-init-6.c: New test.
>        * c-c++-common/auto-init-7.c: New test.
>        * c-c++-common/auto-init-8.c: New test.
>        * c-c++-common/auto-init-9.c: New test.
>        * c-c++-common/auto-init-esra.c: New test.
>        * c-c++-common/auto-init-padding-1.c: New test.
>        * c-c++-common/auto-init-padding-2.c: New test.
>        * c-c++-common/auto-init-padding-3.c: New test.
>        * g++.dg/auto-init-uninit-pred-1_a.C: New test.
>        * g++.dg/auto-init-uninit-pred-1_b.C: New test.
>        * g++.dg/auto-init-uninit-pred-2_a.C: New test.
>        * g++.dg/auto-init-uninit-pred-2_b.C: New test.
>        * g++.dg/auto-init-uninit-pred-3_a.C: New test.
>        * g++.dg/auto-init-uninit-pred-3_b.C: New test.
>        * g++.dg/auto-init-uninit-pred-4.C: New test.
>        * g++.dg/auto-init-uninit-pred-loop-1_a.cc: New test.
>        * g++.dg/auto-init-uninit-pred-loop-1_b.cc: New test.
>        * g++.dg/auto-init-uninit-pred-loop-1_c.cc: New test.
>        * g++.dg/auto-init-uninit-pred-loop_1.cc: New test.
>        * gcc.dg/auto-init-uninit-1.c: New test.
>        * gcc.dg/auto-init-uninit-11.c: New test.
>        * gcc.dg/auto-init-uninit-12.c: New test.
>        * gcc.dg/auto-init-uninit-13.c: New test.
>        * gcc.dg/auto-init-uninit-14.c: New test.
>        * gcc.dg/auto-init-uninit-15.c: New test.
>        * gcc.dg/auto-init-uninit-16.c: New test.
>        * gcc.dg/auto-init-uninit-17.c: New test.
>        * gcc.dg/auto-init-uninit-18.c: New test.
>        * gcc.dg/auto-init-uninit-19.c: New test.
>        * gcc.dg/auto-init-uninit-2.c: New test.
>        * gcc.dg/auto-init-uninit-20.c: New test.
>        * gcc.dg/auto-init-uninit-21.c: New test.
>        * gcc.dg/auto-init-uninit-22.c: New test.
>        * gcc.dg/auto-init-uninit-23.c: New test.
>        * gcc.dg/auto-init-uninit-24.c: New test.
>        * gcc.dg/auto-init-uninit-25.c: New test.
>        * gcc.dg/auto-init-uninit-26.c: New test.
>        * gcc.dg/auto-init-uninit-3.c: New test.
>        * gcc.dg/auto-init-uninit-34.c: New test.
>        * gcc.dg/auto-init-uninit-36.c: New test.
>        * gcc.dg/auto-init-uninit-37.c: New test.
>        * gcc.dg/auto-init-uninit-4.c: New test.
>        * gcc.dg/auto-init-uninit-5.c: New test.
>        * gcc.dg/auto-init-uninit-6.c: New test.
>        * gcc.dg/auto-init-uninit-8.c: New test.
>        * gcc.dg/auto-init-uninit-9.c: New test.
>        * gcc.dg/auto-init-uninit-A.c: New test.
>        * gcc.dg/auto-init-uninit-B.c: New test.
>        * gcc.dg/auto-init-uninit-C.c: New test.
>        * gcc.dg/auto-init-uninit-H.c: New test.
>        * gcc.dg/auto-init-uninit-I.c: New test.
>        * gcc.target/aarch64/auto-init-1.c: New test.
>        * gcc.target/aarch64/auto-init-2.c: New test.
>        * gcc.target/aarch64/auto-init-3.c: New test.
>        * gcc.target/aarch64/auto-init-4.c: New test.
>        * gcc.target/aarch64/auto-init-5.c: New test.
>        * gcc.target/aarch64/auto-init-6.c: New test.
>        * gcc.target/aarch64/auto-init-7.c: New test.
>        * gcc.target/aarch64/auto-init-8.c: New test.
>        * gcc.target/aarch64/auto-init-padding-1.c: New test.
>        * gcc.target/aarch64/auto-init-padding-10.c: New test.
>        * gcc.target/aarch64/auto-init-padding-11.c: New test.
>        * gcc.target/aarch64/auto-init-padding-12.c: New test.
>        * gcc.target/aarch64/auto-init-padding-2.c: New test.
>        * gcc.target/aarch64/auto-init-padding-3.c: New test.
>        * gcc.target/aarch64/auto-init-padding-4.c: New test.
>        * gcc.target/aarch64/auto-init-padding-5.c: New test.
>        * gcc.target/aarch64/auto-init-padding-6.c: New test.
>        * gcc.target/aarch64/auto-init-padding-7.c: New test.
>        * gcc.target/aarch64/auto-init-padding-8.c: New test.
>        * gcc.target/aarch64/auto-init-padding-9.c: New test.
>        * gcc.target/i386/auto-init-1.c: New test.
>        * gcc.target/i386/auto-init-2.c: New test.
>        * gcc.target/i386/auto-init-21.c: New test.
>        * gcc.target/i386/auto-init-22.c: New test.
>        * gcc.target/i386/auto-init-23.c: New test.
>        * gcc.target/i386/auto-init-24.c: New test.
>        * gcc.target/i386/auto-init-3.c: New test.
>        * gcc.target/i386/auto-init-4.c: New test.
>        * gcc.target/i386/auto-init-5.c: New test.
>        * gcc.target/i386/auto-init-6.c: New test.
>        * gcc.target/i386/auto-init-7.c: New test.
>        * gcc.target/i386/auto-init-8.c: New test.
>        * gcc.target/i386/auto-init-padding-1.c: New test.
>        * gcc.target/i386/auto-init-padding-10.c: New test.
>        * gcc.target/i386/auto-init-padding-11.c: New test.
>        * gcc.target/i386/auto-init-padding-12.c: New test.
>        * gcc.target/i386/auto-init-padding-2.c: New test.
>        * gcc.target/i386/auto-init-padding-3.c: New test.
>        * gcc.target/i386/auto-init-padding-4.c: New test.
>        * gcc.target/i386/auto-init-padding-5.c: New test.
>        * gcc.target/i386/auto-init-padding-6.c: New test.
>        * gcc.target/i386/auto-init-padding-7.c: New test.
>        * gcc.target/i386/auto-init-padding-8.c: New test.
>        * gcc.target/i386/auto-init-padding-9.c: New test.
> 
> ******The complete 5th version of the patch is:
> 
> 
> <0001-the-5th-version.patch>


  reply	other threads:[~2021-07-25 16:26 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-25 15:59 Qing Zhao
2021-07-25 16:26 ` Qing Zhao [this message]
2021-07-26 11:00 ` Martin Jambor
2021-07-26 15:25   ` Qing Zhao
2021-07-26 15:55     ` Qing Zhao
2021-07-26 16:09     ` Martin Jambor
2021-07-26 16:38       ` Qing Zhao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2C3413FF-4386-4556-BABC-3DD9E5C5EFAD@oracle.com \
    --to=qing.zhao@oracle.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=keescook@chromium.org \
    --cc=richard.guenther@gmail.com \
    --cc=richard.sandiford@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).