From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by sourceware.org (Postfix) with ESMTPS id 4874E385C405 for ; Wed, 28 Jul 2021 20:21:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4874E385C405 Received: by mail-pj1-x102c.google.com with SMTP id a4-20020a17090aa504b0290176a0d2b67aso11958240pjq.2 for ; Wed, 28 Jul 2021 13:21:25 -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:content-transfer-encoding :in-reply-to; bh=1z8bYpkVtR9J0iI1i1oV/jcI71qC+f0QvAzVGXAvkbo=; b=evBnM2W2YCp86iRsPu221ALox11tvpzaUlcVFZZKuXpWWT0zHHnEmmWQmHtbpliLG1 HKgQG6pVihehDZT02TdmROuMIuxqsrk0g2DjwzGaxYbPxdOjtChmpT5IlQwUes8KZ+zS hXJ6ZDL6PCTZXp6u6AdsEwQ8y/GisVnGSAIOOEQ6zrr9+FpI/KvEhjzOuY0hbnjldL8w SE95SzePSvWuekNQUo0XWKvJO1ZHIcE7Z0+lXkOAvqnz+80Ky5K5puh/fQBswd4ythMr 52aG1Wfux0DNaVFI8mnSTS/1D9l5JL5dkdd1WEysmaev9ochALZ7CUO+RgDrHJVH3Zpn FFeg== X-Gm-Message-State: AOAM532FlczZQJkXc9XZ1z1V/cxwdjUepte3U37ten+GR2sbAojRpKpc doNBkN0OUwOId9LGgT0/HFfqkeaF+0WNdg== X-Google-Smtp-Source: ABdhPJwkuNLsuDwsiIbvi5GGX2R7dhu84q2lEV9pEKfSvPc3CuUAMpy1KRSnMPsMMq9kKzR9MCKyfw== X-Received: by 2002:a17:902:7144:b029:12b:24ce:a83c with SMTP id u4-20020a1709027144b029012b24cea83cmr1401060plm.54.1627503684008; Wed, 28 Jul 2021 13:21:24 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id m11sm789068pgn.56.2021.07.28.13.21.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Jul 2021 13:21:23 -0700 (PDT) Date: Wed, 28 Jul 2021 13:21:22 -0700 From: Kees Cook To: Qing Zhao Cc: Richard Biener , Martin Jambor , Jakub Jelinek , Nick Alcock via Gcc-patches , Richard Biener Subject: Re: [patch][version 6] add -ftrivial-auto-var-init and variable attribute "uninitialized" to gcc Message-ID: <202107281222.BF0BB3D8B6@keescook> References: <52E29277-1403-4755-901A-528116C43FB8@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <52E29277-1403-4755-901A-528116C43FB8@oracle.com> X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, JMQ_SPF_NEUTRAL, KAM_SHORT, 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, 28 Jul 2021 20:21:28 -0000 On Tue, Jul 27, 2021 at 03:26:00AM +0000, Qing Zhao wrote: > This is the 6th 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 CPU2017 (running is ongoing), without any issue. (With the fix to bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101586). > > Please take a look and let me know any issue. Good news, this passes all my initialization tests in the kernel. Yay! :) However, I see an unexpected side-effect from some static initializations: net/core/sock.c: In function 'sock_no_sendpage': net/core/sock.c:2849:23: warning: 'msg' is used uninitialized [-Wuninitialized] 2849 | struct msghdr msg = {.msg_flags = flags}; | ^~~ It seems like -Wuninitialized has suddenly stopped noticing explicit static initializers when there are bit fields in the struct. Here's a minimized case: $ cat init.c struct weird { int bit : 1; int val; }; int func(int val) { struct weird obj = { .val = val }; return obj.val; } $ gcc -c -o init.o -Wall -O2 -ftrivial-auto-var-init=zero init.c init.c: In function ‘func’: init.c:8:22: warning: ‘obj’ is used uninitialized [-Wuninitialized] 8 | struct weird obj = { .val = val }; | ^~~ init.c:8:22: note: ‘obj’ declared here 8 | struct weird obj = { .val = val }; | ^~~ -- Kees Cook