Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp698839imu; Wed, 23 Jan 2019 04:12:09 -0800 (PST) X-Google-Smtp-Source: ALg8bN76C0FdJ8pK0t5hSnOs44eaFpGxKWifa5oeVg1U39tF4guesn9dHqLkZJ5Kr1L+ifD6jRAF X-Received: by 2002:a62:d206:: with SMTP id c6mr1769652pfg.245.1548245529441; Wed, 23 Jan 2019 04:12:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548245529; cv=none; d=google.com; s=arc-20160816; b=1Dyx7SDQ+u4A2CU1bS1RNc1c1bd77CcSnh0rTaGoJvnp/M98yhKkOQXyYzx00zzb1b RnbKAYy4T8y1/Sw9ECBPswrPgbndB1CW12O2ElOaD089prEWqXaytkOuyQd4RIcBQdta mbgcpm8bHH7007giJuq5hHf8xrlJxUJ+pMfva2c1jBBVP7omUpkyDAxj4TtUhw6F05pG fpdxjYVHwWbsE0G4GJfkA74vxlDmUzU9EgVcyF4YYrrNa0M5sezBJKZLOKLWHp4l6pB8 3KSyr1NSVbgLrayEEXcpIPZ+KRDASMoQPQ4wBQbC/Fp3gGTcf6IBT1H8maQ6zbKzCN6f KGgg== 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=ozDKIbwcmYuyejXGARNO3jJ/EJ1dH91BZQgRlXa0NVc=; b=gWyT77w4FJ8/EtaHsdAMzDwVhidT4q1DlAw9OeYPsJFN8c/R6ZP6G7eASYafBhrcd6 y1/MH1151GoFdmSSXhily2smJ6QuZBmfG7FiDF7Tquhn2lhfz0etwqfkvif4F8lsiLzQ Jk3A21jzxHWTQws0knrr+Dt/zxhNZR2anO2lpthLPr0IUgKgK+iWPo1rHSCF8J9bBQMB MPIS52Zc8nqutbZ0xWLMXkFd5hbch/QfB/iBsxMtUFtYtGx7NX/5O0ET1KVYywkxpTov oU1lOsFxsWKOoOCrw5Vd9qLwc3JJobI4+y9gTt0OQkh4ECOJExQ1tgBiyWR+d3BtCi2+ as+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=TdmruNmZ; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c139si19127641pfb.281.2019.01.23.04.11.54; Wed, 23 Jan 2019 04:12:09 -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=@google.com header.s=20161025 header.b=TdmruNmZ; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727309AbfAWMJm (ORCPT + 99 others); Wed, 23 Jan 2019 07:09:42 -0500 Received: from mail-oi1-f196.google.com ([209.85.167.196]:45871 "EHLO mail-oi1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726207AbfAWMJk (ORCPT ); Wed, 23 Jan 2019 07:09:40 -0500 Received: by mail-oi1-f196.google.com with SMTP id y1so1551567oie.12 for ; Wed, 23 Jan 2019 04:09:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=ozDKIbwcmYuyejXGARNO3jJ/EJ1dH91BZQgRlXa0NVc=; b=TdmruNmZ40rRcOmr5c75vEIE9p7sNtcssBxrB6bd1v49wN7GdrM8dCdTjsFQkdwWpn swJtemBXQ8ZfNyCa1SflX10bZDRPmJb8tjwU7YUSHbALC+X1sn7gMgElfhG0yulEtun3 dI6EjQ0qoKfuvzWguCcBeFpT2cvANhqJOLW8brHwqybryRKfXMLt2jCo+c3z0h0u9cs+ DwJAHlcaYLhJSTROVF0VfKwLWBxSkwFrqjVe5od1op4Pncf0bV9yiTfuJ+VyvjAwTZBa D5nZZ6vI/i6CDyC16YUTSU53EeDC1Pc5YlFAA/BNIwJPdl/R6qmYspFi9kUVWRDYLnSU eOng== 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=ozDKIbwcmYuyejXGARNO3jJ/EJ1dH91BZQgRlXa0NVc=; b=qDaKncyQ1D41539GvJdLNHQ7kXxdDWYI7pSQE2V2CmywFLLMAZ1WJspbE3YoHi1fjS 1cYhoVuIvsKfKf8sO90B/AhZnN633LkkpIWYzNWTJiAAbUzVV1lr97T4SOwJhT2XtUKm LXV+JDBfld139ggUfECkAynpuYiH4hBv7VxVj0sM/SEETvz+wjA4ri8PNIFFvyT3/ENQ qI/pcjcLvBnR32xLoPhpPSUBX+DNIXO1ieknWXrUu5FONm/+ZahLtLwSPUlZll+UyDqb t04f/WYM8eJ2sbpgxhVleUacZn7DaIBzvFtiPo5ixLCnkIigpOJLMmpTiRcJe9fisf5H e44w== X-Gm-Message-State: AJcUukc6QtF4DxsENodH9aQ+nVM194smHRasjjA/QmoPTW0t9Dj3BqUm zqRIYbreyiDnJD+pJ/K5z+UAzzrZctRgBKdyGdLDX8MIuiSYoA== X-Received: by 2002:aca:c43:: with SMTP id i3mr1280767oiy.157.1548245379171; Wed, 23 Jan 2019 04:09:39 -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: <20190123115829.GA31385@kroah.com> From: Jann Horn Date: Wed, 23 Jan 2019 13:09:13 +0100 Message-ID: Subject: Re: [PATCH 1/3] treewide: Lift switch variables out of switches To: Greg KH Cc: Kees Cook , kernel list , Ard Biesheuvel , Laura Abbott , Alexander Popov , xen-devel , dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, intel-wired-lan@lists.osuosl.org, Network Development , linux-usb@vger.kernel.org, linux-fsdevel@vger.kernel.org, Linux-MM , dev@openvswitch.org, linux-kbuild@vger.kernel.org, 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, Jan 23, 2019 at 1:04 PM Greg KH wrote: > 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 [-Wswitch-= 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/... . > That's going to be a hard thing to keep from happening over time, as > this is valid C :(