From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5011CC433DF for ; Thu, 4 Jun 2020 04:02:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0E9C920679 for ; Thu, 4 Jun 2020 04:02:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="nmlYusCX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0E9C920679 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A8B5F28000A; Thu, 4 Jun 2020 00:02:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A61E38000E; Thu, 4 Jun 2020 00:02:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9773828000A; Thu, 4 Jun 2020 00:02:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0035.hostedemail.com [216.40.44.35]) by kanga.kvack.org (Postfix) with ESMTP id 7BCBC8000E for ; Thu, 4 Jun 2020 00:02:35 -0400 (EDT) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 3BEC5440E for ; Thu, 4 Jun 2020 04:02:35 +0000 (UTC) X-FDA: 76890182670.24.stamp30_33a0913823009 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin24.hostedemail.com (Postfix) with ESMTP id 1FD101A4A5 for ; Thu, 4 Jun 2020 04:02:35 +0000 (UTC) X-HE-Tag: stamp30_33a0913823009 X-Filterd-Recvd-Size: 5979 Received: from mail-pj1-f67.google.com (mail-pj1-f67.google.com [209.85.216.67]) by imf22.hostedemail.com (Postfix) with ESMTP for ; Thu, 4 Jun 2020 04:02:34 +0000 (UTC) Received: by mail-pj1-f67.google.com with SMTP id q24so517942pjd.1 for ; Wed, 03 Jun 2020 21:02:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=dDMZ76EfQNqsSp5sb7mLI8JiO94mOeQpyrT6zdtd3HQ=; b=nmlYusCXDFiVqFXgxwlUm0gg3wIorQtKPNmSn8kUxXy2o8ATDLsqSlFD0o61OtpLts 2zSeOvR5nnDD2//h685p30vwSekGc1q/jRAs6eegsS86q8t4Z7JAaLx7yfVY1EK9Xiau DCT2MBSjsLxms0BiWDCQF4Q6VgKuWrTFT33kU= 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=dDMZ76EfQNqsSp5sb7mLI8JiO94mOeQpyrT6zdtd3HQ=; b=VP2qyxSP1W7qcw+XKIn7WervPn4ga1Rye6GRFDN92PWlDjhW2GndSfb542/hkLnCA4 3w9g3ClBBBxnInquWGAagIm4/s136bGHK8ere/CTpwgYjW74NRj/bI5qA57JCNZqeXXC Dw5j96t/I4adWMuoKCvhTbOnqO2LAv62p88FBKWhLq4Q3FZ4vppQ9B2JjXGsb/ZT8ZdR K8rBRkAbePG9O3qtTHznZPUnrXn8UrY5x4Mp3Ty31eAtEds8jXd6ASGUOl1cRi0nSIbT RrYaDlb805o3SzRaYCzHnPGkWSDTsBUQJdRMb7rrGXiCzcwvF6m5WBF3/L5uct5Fslue b48w== X-Gm-Message-State: AOAM5336f4D4W5PjLQaFk2/j5poW9VbsVOf1PmLy7uRhdV4MMnLi1+Q9 LdsHvPZkYzySKdVhY+ryBJz6Pw== X-Google-Smtp-Source: ABdhPJxQ/Dd1yetZm6iahM4ViylSUD/mRnchtrTt1NIbGDNSI6TVF94FWNWMrr2lFeqPK0TXyTqNmA== X-Received: by 2002:a17:902:b710:: with SMTP id d16mr2968382pls.28.1591243353758; Wed, 03 Jun 2020 21:02:33 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id q6sm1193902pff.163.2020.06.03.21.02.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2020 21:02:32 -0700 (PDT) Date: Wed, 3 Jun 2020 21:02:31 -0700 From: Kees Cook To: Nathan Chancellor Cc: linux-kernel@vger.kernel.org, Linus Torvalds , Miguel Ojeda , Alexander Potapenko , Joe Perches , Andy Whitcroft , x86@kernel.org, drbd-dev@lists.linbit.com, linux-block@vger.kernel.org, b43-dev@lists.infradead.org, netdev@vger.kernel.org, linux-wireless@vger.kernel.org, linux-ide@vger.kernel.org, linux-clk@vger.kernel.org, linux-spi@vger.kernel.org, linux-mm@kvack.org, clang-built-linux@googlegroups.com Subject: Re: [PATCH 09/10] treewide: Remove uninitialized_var() usage Message-ID: <202006032048.E7B1D18A1@keescook> References: <20200603233203.1695403-1-keescook@chromium.org> <20200603233203.1695403-10-keescook@chromium.org> <20200604033315.GA1131596@ubuntu-n2-xlarge-x86> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200604033315.GA1131596@ubuntu-n2-xlarge-x86> X-Rspamd-Queue-Id: 1FD101A4A5 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, Jun 03, 2020 at 08:33:15PM -0700, Nathan Chancellor wrote: > On Wed, Jun 03, 2020 at 04:32:02PM -0700, Kees Cook wrote: > > Using uninitialized_var() is dangerous as it papers over real bugs[1] > > (or can in the future), and suppresses unrelated compiler warnings > > (e.g. "unused variable"). If the compiler thinks it is uninitialized, > > either simply initialize the variable or make compiler changes. > > > > I preparation for removing[2] the[3] macro[4], remove all remaining > > needless uses with the following script: > > > > git grep '\buninitialized_var\b' | cut -d: -f1 | sort -u | \ > > xargs perl -pi -e \ > > 's/\buninitialized_var\(([^\)]+)\)/\1/g; > > s:\s*/\* (GCC be quiet|to make compiler happy) \*/$::g;' > > > > drivers/video/fbdev/riva/riva_hw.c was manually tweaked to avoid > > pathological white-space. > > > > No outstanding warnings were found building allmodconfig with GCC 9.3.0 > > for x86_64, i386, arm64, arm, powerpc, powerpc64le, s390x, mips, sparc64, > > alpha, and m68k. > > > > [1] https://lore.kernel.org/lkml/20200603174714.192027-1-glider@google.com/ > > [2] https://lore.kernel.org/lkml/CA+55aFw+Vbj0i=1TGqCR5vQkCzWJ0QxK6CernOU6eedsudAixw@mail.gmail.com/ > > [3] https://lore.kernel.org/lkml/CA+55aFwgbgqhbp1fkxvRKEpzyR5J8n1vKT1VZdz9knmPuXhOeg@mail.gmail.com/ > > [4] https://lore.kernel.org/lkml/CA+55aFz2500WfbKXAx8s67wrm9=yVJu65TpLgN_ybYNv0VEOKA@mail.gmail.com/ > > > > Signed-off-by: Kees Cook > > > > > diff --git a/arch/powerpc/kvm/book3s_pr.c b/arch/powerpc/kvm/book3s_pr.c > > index a0f6813f4560..a71fa7204882 100644 > > --- a/arch/powerpc/kvm/book3s_pr.c > > +++ b/arch/powerpc/kvm/book3s_pr.c > > @@ -1829,7 +1829,7 @@ static int kvmppc_vcpu_run_pr(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu) > > { > > int ret; > > #ifdef CONFIG_ALTIVEC > > - unsigned long uninitialized_var(vrsave); > > + unsigned long vrsave; > > #endif > > This variable is actually unused: > > ../arch/powerpc/kvm/book3s_pr.c:1832:16: warning: unused variable 'vrsave' [-Wunused-variable] > unsigned long vrsave; > ^ > 1 warning generated. > > It has been unused since commit 99dae3bad28d ("KVM: PPC: Load/save > FP/VMX/VSX state directly to/from vcpu struct"). > > $ git grep vrsave 99dae3bad28d8fdd32b7bfdd5e2ec7bb2d4d019d arch/powerpc/kvm/book3s_pr.c > 99dae3bad28d8fdd32b7bfdd5e2ec7bb2d4d019d:arch/powerpc/kvm/book3s_pr.c: unsigned long uninitialized_var(vrsave); > > I would nuke the whole '#ifdef' block. Ah, thanks! I wonder why I don't have CONFIG_ALTIVEC in any of my ppc builds. Hmmm. -Kees -- Kees Cook