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=-3.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS autolearn=no 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 7EEBCC11D00 for ; Thu, 20 Feb 2020 23:06:24 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 44A8E206F4 for ; Thu, 20 Feb 2020 23:06:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="oNgGUgcX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 44A8E206F4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j4ut3-0005d7-01; Thu, 20 Feb 2020 23:05:40 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j4ut1-0005d2-QJ for xen-devel@lists.xenproject.org; Thu, 20 Feb 2020 23:05:39 +0000 X-Inumbo-ID: 82799c92-5435-11ea-bc8e-bc764e2007e4 Received: from mail-pf1-x442.google.com (unknown [2607:f8b0:4864:20::442]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 82799c92-5435-11ea-bc8e-bc764e2007e4; Thu, 20 Feb 2020 23:05:39 +0000 (UTC) Received: by mail-pf1-x442.google.com with SMTP id i6so155579pfc.1 for ; Thu, 20 Feb 2020 15:05:39 -0800 (PST) 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:content-transfer-encoding:in-reply-to; bh=c0kZSeFM/+814IXGYlA2mUh7BiAgeVF3A/1ZFnTcsZc=; b=oNgGUgcXPIIzpKoyYuQCg2iZgDGOqNq2Nuywq1XBACo+UkBmEshyJJcH4Rq/FYPAyV wmpxnA+i3Uj2NsKgZB7+n+cELRd+40ZezWMN3LL3O7GAvIzFSkQ7jxZrbtedJlR/P5zc qznGHo5Zt1TIpx7dru+9PdeL5yFGhMh8D4Ztc= 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=c0kZSeFM/+814IXGYlA2mUh7BiAgeVF3A/1ZFnTcsZc=; b=CMd0d3fEUL90cAKVMaaalfZi0DzcODEYLRI2shWRqlJqz/RpodkGIJvWma/ZZ4IJRg ltp42fhbct5ETHnuz2SSTb6Tq+pCL/hUVRSZKMwLcpTBlvQPuDiP5br4CQ5MbS5lAKcv K3ex8INwj2bd9uGbJwoDjx69CRsqWQkqfY5NnP2gWJ3hXOmVYVFVIymGcFONrBsPJUG7 pfjsy0ddaxpyT2u1mDEWhHx+vFjg+pB030RvKs1ORZpX8utCZmnweXhmg6fhgMRZPZMF m3hbv1gWobAfXzkMcVxnUY/a9Gm+1ICS2XZedUxK/3HHbXl6RPbF3H7tbUrCQabFF1H2 SlqA== X-Gm-Message-State: APjAAAVPaSfcI0yQucU+kag33+NsyvHU3MvksfEM4vrM+sx1IMEzT/Di ZSzb9RNxvc9UO5fzhw2czNUehA== X-Google-Smtp-Source: APXvYqxk+KNXpddw0Soriz9dh3hS8Ty+wHgvXPj77cXIpL/9OafL5vZZNFJjY0dqa57hetm/W/6LdA== X-Received: by 2002:aa7:8f33:: with SMTP id y19mr32954425pfr.47.1582239938288; Thu, 20 Feb 2020 15:05:38 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id g7sm660356pfq.33.2020.02.20.15.05.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Feb 2020 15:05:37 -0800 (PST) Date: Thu, 20 Feb 2020 15:05:36 -0800 From: Kees Cook To: Boris Ostrovsky Message-ID: <202002201505.C3863B2D0@keescook> References: <20200220062318.69299-1-keescook@chromium.org> <16a166da-c6e7-aa36-53a0-1b56197c8fc0@suse.com> <8a7f5bd7-2bb6-d187-cc6e-87ff01c440ce@oracle.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <8a7f5bd7-2bb6-d187-cc6e-87ff01c440ce@oracle.com> Subject: Re: [Xen-devel] [PATCH] x86/xen: Distribute switch variables for initialization X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: =?iso-8859-1?Q?J=FCrgen_Gro=DF?= , xen-devel@lists.xenproject.org, Stefano Stabellini , Alexander Potapenko , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" T24gVGh1LCBGZWIgMjAsIDIwMjAgYXQgMTE6MzM6NDFBTSAtMDUwMCwgQm9yaXMgT3N0cm92c2t5 IHdyb3RlOgo+IAo+IAo+IE9uIDIvMjAvMjAgMTozNyBBTSwgSsO8cmdlbiBHcm/DnyB3cm90ZToK PiA+IE9uIDIwLjAyLjIwIDA3OjIzLCBLZWVzIENvb2sgd3JvdGU6Cj4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cKaHR0cHM6Ly9saXN0cy54ZW5w cm9qZWN0Lm9yZy9tYWlsbWFuL2xpc3RpbmZvL3hlbi1kZXZlbA== 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=-3.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=no 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 A60D9C11D00 for ; Thu, 20 Feb 2020 23:05:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 76183206F4 for ; Thu, 20 Feb 2020 23:05:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="oNgGUgcX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729297AbgBTXFj (ORCPT ); Thu, 20 Feb 2020 18:05:39 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:34098 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727135AbgBTXFi (ORCPT ); Thu, 20 Feb 2020 18:05:38 -0500 Received: by mail-pg1-f194.google.com with SMTP id j4so2690701pgi.1 for ; Thu, 20 Feb 2020 15:05:38 -0800 (PST) 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:content-transfer-encoding:in-reply-to; bh=c0kZSeFM/+814IXGYlA2mUh7BiAgeVF3A/1ZFnTcsZc=; b=oNgGUgcXPIIzpKoyYuQCg2iZgDGOqNq2Nuywq1XBACo+UkBmEshyJJcH4Rq/FYPAyV wmpxnA+i3Uj2NsKgZB7+n+cELRd+40ZezWMN3LL3O7GAvIzFSkQ7jxZrbtedJlR/P5zc qznGHo5Zt1TIpx7dru+9PdeL5yFGhMh8D4Ztc= 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=c0kZSeFM/+814IXGYlA2mUh7BiAgeVF3A/1ZFnTcsZc=; b=Xe3rNAUv6yZUOZ7iQf3PcpnZZJ+CnzvfmUNjbfjv1C/JrOLMxX4RdeZb00Zva3244r VwXE9pb3iM12ZJ9elsRAKtw0EpRJFT0ywYAaUjwtwtnuPYlDLEbP7PoEyywKs4H4EfPv 7k6WNZMQEpdjxan6G70nCjQQ7W9iahrZBy6Sr4kgjCbRPlbyT5oUKqh5ncjt8fRG0+3l zsuuJiE6t+yLzv8JxxV7JwYTylCWrcWN/oNU6xVuiu8MFh5cZxbow0ztiFZDbqKZ6n6M 06fMJg9bbNx3lwDbDH+YI+3W2Y3TRlz8jCE2Coml6p7tfpVsuMwARrsGdqJwAfLAzM4J RiiA== X-Gm-Message-State: APjAAAWr3mfp/WLevn0pOPhvQ13MZXkrqsd5U9edSw3DTyyGrpXNo0+6 Z5tw6IRhhLpXbbrp4dwH27BOxw== X-Google-Smtp-Source: APXvYqxk+KNXpddw0Soriz9dh3hS8Ty+wHgvXPj77cXIpL/9OafL5vZZNFJjY0dqa57hetm/W/6LdA== X-Received: by 2002:aa7:8f33:: with SMTP id y19mr32954425pfr.47.1582239938288; Thu, 20 Feb 2020 15:05:38 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id g7sm660356pfq.33.2020.02.20.15.05.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Feb 2020 15:05:37 -0800 (PST) Date: Thu, 20 Feb 2020 15:05:36 -0800 From: Kees Cook To: Boris Ostrovsky Cc: =?iso-8859-1?Q?J=FCrgen_Gro=DF?= , Alexander Potapenko , Stefano Stabellini , xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] x86/xen: Distribute switch variables for initialization Message-ID: <202002201505.C3863B2D0@keescook> References: <20200220062318.69299-1-keescook@chromium.org> <16a166da-c6e7-aa36-53a0-1b56197c8fc0@suse.com> <8a7f5bd7-2bb6-d187-cc6e-87ff01c440ce@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <8a7f5bd7-2bb6-d187-cc6e-87ff01c440ce@oracle.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 20, 2020 at 11:33:41AM -0500, Boris Ostrovsky wrote: > > > On 2/20/20 1:37 AM, Jürgen Groß wrote: > > On 20.02.20 07:23, Kees Cook wrote: > >> Variables declared in a switch statement before any case statements > >> cannot be automatically initialized with compiler instrumentation (as > >> they are not part of any execution flow). With GCC's proposed automatic > >> stack variable initialization feature, this triggers a warning (and they > >> don't get initialized). Clang's automatic stack variable initialization > >> (via CONFIG_INIT_STACK_ALL=y) doesn't throw a warning, but it also > >> doesn't initialize such variables[1]. Note that these warnings (or > >> silent > >> skipping) happen before the dead-store elimination optimization phase, > >> so even when the automatic initializations are later elided in favor of > >> direct initializations, the warnings remain. > >> > >> To avoid these problems, move such variables into the "case" where > >> they're used or lift them up into the main function body. > >> > >> arch/x86/xen/enlighten_pv.c: In function ‘xen_write_msr_safe’: > >> arch/x86/xen/enlighten_pv.c:904:12: warning: statement will never be > >> executed [-Wswitch-unreachable] > >>    904 |   unsigned which; > >>        |            ^~~~~ > >> > >> [1] https://bugs.llvm.org/show_bug.cgi?id=44916 > >> > >> Signed-off-by: Kees Cook > > > > Reviewed-by: Juergen Gross > > > > Applied to for-linus-5.6. > > (I replaced 'unsigned' with 'unsigned int' to quiet down checkpatch ) Oh, good call. Sorry I missed that! Thanks! -- Kees Cook