From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by sourceware.org (Postfix) with ESMTPS id C4288394C04D for ; Wed, 14 Jul 2021 02:42:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C4288394C04D Received: by mail-pg1-x52e.google.com with SMTP id 62so770993pgf.1 for ; Tue, 13 Jul 2021 19:42:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=eHR8ynpiaVCEP2XFdTXcGE36iMZNSZP7yJV/GzErIQE=; b=d0b2cKWAwgW7HSFOv9d3T5jRHbwD6gpogmG35y7hMD6p1ARPJjmLk/mRgO9akKPgh7 Nfr/QjhH1xQPyqfX7tootelJ4XTbeOF0AjYU3kb41syYXx3kKGeobXsz+T1mT7CgXbbc 48jN5wZhuURv7NlSk2H2FdBNrOudddwJzO3vMBp6AEOOI+DBqlJ+jExduQYMsF66fUsL tdFA1lrkMM5fxZsQJpJNqhPrkIfvavUcCSYK8jesOarwNCDw4PCnq15dIUqEiZTUEg5m 8YrIbOOv5ERwkzx098a+59drGfuSSVG8fIdbFjTuKj5rdiDzj4mUQO2YqsbvvIGbxGWl JMww== X-Gm-Message-State: AOAM53329LjLCXkzBARVgZ/W+wv9rNtI1kN+k6ShpVFJWK38wRijzu5A p7hlNybF+X3kbOiYDrnn0tsT7g== X-Google-Smtp-Source: ABdhPJyVeZyppWK3J4qiIUtAUBZdTztlkUBbhoqXaKytSG0lw7Qk4sZHd7asil7k+618MYHjTY6wPw== X-Received: by 2002:a63:1661:: with SMTP id 33mr7039291pgw.443.1626230574942; Tue, 13 Jul 2021 19:42:54 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id j19sm496538pgm.44.2021.07.13.19.42.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jul 2021 19:42:54 -0700 (PDT) Date: Tue, 13 Jul 2021 19:42:52 -0700 From: Kees Cook To: Qing Zhao Cc: Richard Biener , Richard Sandiford , gcc-patches Qing Zhao via Subject: Re: [patch][version 4]add -ftrivial-auto-var-init and variable attribute "uninitialized" to gcc Message-ID: <202107131940.52CA80264@keescook> References: <202107121030.295D4E590@keescook> <80CAE4C0-237B-4F1A-9569-7EC789563CB8@oracle.com> <202107131227.C6DF131@keescook> <6550FBBC-E954-478D-8BAC-F7B0392ED2F5@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6550FBBC-E954-478D-8BAC-F7B0392ED2F5@oracle.com> X-Spam-Status: No, score=-3.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 Jul 2021 02:42:57 -0000 On Tue, Jul 13, 2021 at 11:16:59PM +0000, Qing Zhao wrote: > Hi, Kees, > > I took a look at the kernel testing case you attached in the previous email, and found the testing failed with the following case: > > #define INIT_STRUCT_static_all = { .one = arg->one, \ > .two = arg->two, \ > .three = arg->three, \ > .four = arg->four, \ > } > > i.e, when the structure type auto variable has been explicitly initialized in the source code. -ftrivial-auto-var-init in the 4th version > does not initialize the paddings for such variables. > > But in the previous version of the patches ( 2 or 3), -ftrivial-auto-var-init initializes the paddings for such variables. > > I intended to remove this part of the code from the 4th version of the patch since the implementation for initializing such paddings is completely different from > the initializing of the whole structure as a whole with memset in this version of the implementation. > > If we really need this functionality, I will add another separate patch for this additional functionality, but not with this patch. Yes, this is required to get proper coverage for initialization in the kernel (or, really, any program). Without this, things are still left uninitialized in the padding of structs. A separate patch is fine by me; my only desire is to still have it be part of -ftrivial-auto-var-init when it's all done. :) Thanks! -- Kees Cook