Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp701697imu; Wed, 23 Jan 2019 04:15:25 -0800 (PST) X-Google-Smtp-Source: ALg8bN7H4toVRHzBXKLYcodKI/3B5asGEuEsTpov2m5eipN/wQibbpFJ8LBT0ClBvLHbxJrMaPD+ X-Received: by 2002:a65:434d:: with SMTP id k13mr1765752pgq.269.1548245725613; Wed, 23 Jan 2019 04:15:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548245725; cv=none; d=google.com; s=arc-20160816; b=QWBYCm8/o2t0g1O0Skp/gHDoToK/QNB/iCSbhvALgbUm9Iys4dLvkvNnAH5pU/pb9X vkSDicFQ4hihH0yASL1Ag30ppiOPULsk41pPJyT3Ialgri8Ps40KBVgaqEAnrWG4zmdA QbHdhzozXWOL77CMFE69aLIliieXwQeq03IPP2EkcOOOHxumkwtYWQR+eONnS+hU8H09 nkYWQF+rekprpHtkmvYfqhEv045loUFOWglqy+r+KXlt9cdVS72Ugapan6my5AUTW5z/ a4m71KYPIGaxaGONVZNLGQWXmLXOPYi8rWOyvoNVqpkUYcUyRI+WdJqeDP2WDoTebX0B l8Qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=7CuKdBNpc7lIzSxWikvoBf9wcEakd+B812ZHSpJjJVY=; b=N4sy7wafrMp3Fr0F7a9sUY/jniL+tKvbTuY3TFwJvYWDllBZ6MwBTyUd8gvOks7nwO h00gY3E1/p/OoQlPKScXk0Wy7oaTtvgqZFebH4Nw1smzxYQ6yJxo6Ok6z2Hhd6wax17C Vckcuc+Ve/gVcHvuCpEKw12cS4CU2aMXmmSoJ4MGxhQ4kauW2EzXOUJ1bcv/91ASlBrm /jp8BY1otRQLbPxQ3MVK1U7yQzPuSDpBXZtMLjKNS3TRZROpKJLCVU5VqOg7zp6cfbek Z0sswe8LqdVKmPnsqUyUZpOq2ySqLYK7aDt48rCiVPOk86Dh+K4feXVQztDgO82Mmo5l S/kQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=H+m7GGMj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u21si20145313pgm.21.2019.01.23.04.15.10; Wed, 23 Jan 2019 04:15:25 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=H+m7GGMj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727467AbfAWMMj (ORCPT + 99 others); Wed, 23 Jan 2019 07:12:39 -0500 Received: from mail-io1-f68.google.com ([209.85.166.68]:40035 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726228AbfAWMMj (ORCPT ); Wed, 23 Jan 2019 07:12:39 -0500 Received: by mail-io1-f68.google.com with SMTP id k2so1473630iog.7 for ; Wed, 23 Jan 2019 04:12:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=7CuKdBNpc7lIzSxWikvoBf9wcEakd+B812ZHSpJjJVY=; b=H+m7GGMjF6744xT1D2UwyNiY/KMpTtbRw5bi2y+pCDduRAgSAvhW2ZIPfnH2kOOExh 3Su0JFmxMJMowRT9N2wYUjrjYvuBsgKmxpYbizh11PtffeWo9FwZbrdMYunm9gcvYSN7 D7CAGGUmeHybx5kZaQ1Zx2WU51V6DvtSTJ2bc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=7CuKdBNpc7lIzSxWikvoBf9wcEakd+B812ZHSpJjJVY=; b=qQ653MXo/8qnxL+VvFSfWAGJTQjs0vWDAVfdsx1LBdYB/HhGJosUMplhwoSS7YbQDv L3amboo1SPD0lHmqDn6EOegdm/f1uwOKeaEIHjDkMc7qRcRAScFLHj3I/Bjs9kFfThvT rHBLhsIGVQ57fbTAWguPqXjeTHZA++eRGrLx3scUV3XxbEl7enlRP5Ck1ewGh1wsnxEh V3Xd77weAseaVbWT4++S6Aw5FrRKxXObKwyr/nwPKWJoKUi7UlXsbLm7o+Nj9BsP5Krd 5CF/6apXDgJgeuFUiTBpProipKIUBlqfSSpo44p8ROknZBiicuJvmTg3aXOHT529Uajv 8Y+g== X-Gm-Message-State: AHQUAuYV9idQpCRoX/u5Kv/+JLN/N825jWV7iTm8YFFl+6tVg0ZZjMGE nz0s+fZMroO6F4plPuqiXjZOAVez+V6eqghZCBPBHg== X-Received: by 2002:a5d:8410:: with SMTP id i16mr1019729ion.173.1548245557818; Wed, 23 Jan 2019 04:12:37 -0800 (PST) MIME-Version: 1.0 References: <20190123110349.35882-1-keescook@chromium.org> <20190123110349.35882-2-keescook@chromium.org> <20190123115829.GA31385@kroah.com> In-Reply-To: From: Ard Biesheuvel Date: Wed, 23 Jan 2019 13:12:26 +0100 Message-ID: Subject: Re: [PATCH 1/3] treewide: Lift switch variables out of switches To: Jann Horn Cc: Greg KH , Kees Cook , kernel list , Laura Abbott , Alexander Popov , xen-devel , dri-devel , intel-gfx@lists.freedesktop.org, intel-wired-lan@lists.osuosl.org, Network Development , linux-usb , linux-fsdevel@vger.kernel.org, Linux-MM , dev@openvswitch.org, Linux Kbuild mailing list , linux-security-module , Kernel Hardening Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 23 Jan 2019 at 13:09, Jann Horn wrote: > > On Wed, Jan 23, 2019 at 1:04 PM Greg KH wrot= e: > > On Wed, Jan 23, 2019 at 03:03:47AM -0800, Kees Cook wrote: > > > Variables declared in a switch statement before any case statements > > > cannot be initialized, so move all instances out of the switches. > > > After this, future always-initialized stack variables will work > > > and not throw warnings like this: > > > > > > fs/fcntl.c: In function =E2=80=98send_sigio_to_task=E2=80=99: > > > fs/fcntl.c:738:13: warning: statement will never be executed [-Wswitc= h-unreachable] > > > siginfo_t si; > > > ^~ > > > > That's a pain, so this means we can't have any new variables in { } > > scope except for at the top of a function? > > AFAICS this only applies to switch statements (because they jump to a > case and don't execute stuff at the start of the block), not blocks > after if/while/... . > I guess that means it may apply to other cases where you do a 'goto' into the middle of a for() loop, for instance (at the first iteration), which is also a valid pattern. Is there any way to tag these assignments so the diagnostic disregards them= ?