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=-7.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 E6F91C3F2D7 for ; Tue, 3 Mar 2020 15:55:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BE57920863 for ; Tue, 3 Mar 2020 15:55:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583250925; bh=UGdXaHoMkI2mtHF9nsoYia1Fwcd76iZNyx5ZnrXedcs=; h=Subject:From:To:Cc:Date:In-Reply-To:References:List-ID:From; b=OAvw055ls0v8gJVHUh0yiR9zj5Kaa4HBxm4SYDBU5KuKd9+TcSOMn1piFfj/1jcFO fmxKgsJlDHWfCUIf0dBUH39rao2oJ9cuCMAtevLWeClVOToSrXdJ85NYnnaKUoYu9Q xB2xvBmBEgKoDSF4xTDXtKOztpm7Ifxr+b+C6xBE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729969AbgCCPzY (ORCPT ); Tue, 3 Mar 2020 10:55:24 -0500 Received: from mail.kernel.org ([198.145.29.99]:33712 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729577AbgCCPzY (ORCPT ); Tue, 3 Mar 2020 10:55:24 -0500 Received: from tleilax.poochiereds.net (68-20-15-154.lightspeed.rlghnc.sbcglobal.net [68.20.15.154]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5559120866; Tue, 3 Mar 2020 15:55:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583250924; bh=UGdXaHoMkI2mtHF9nsoYia1Fwcd76iZNyx5ZnrXedcs=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=YRoJVFSMzPTj9B2dJX4KD2NQin2bjap4pJVp8rJ8uAh6LBsdaBe/1PynQjLhWWiLh obdqnCWGgryQKoLQlxaXFBROkTja7CF4CCKuZnIDQV5b+Nn+i/HrhjdiIakEeZ/SWJ 8TIuiuYMzO4bbn6F4huLsKk+4MC3QFyfkslK4ztU= Message-ID: Subject: Re: [PATCH] fcntl: Distribute switch variables for initialization From: Jeff Layton To: Kees Cook , "J. Bruce Fields" , Jens Axboe , Al Viro Cc: Alexander Potapenko , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Date: Tue, 03 Mar 2020 10:55:22 -0500 In-Reply-To: <202003022040.40A32072@keescook> References: <20200220062243.68809-1-keescook@chromium.org> <202003022040.40A32072@keescook> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.34.4 (3.34.4-1.fc31) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2020-03-02 at 20:41 -0800, Kees Cook wrote: > On Wed, Feb 19, 2020 at 10:22:43PM -0800, 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. > > > > fs/fcntl.c: In function ‘send_sigio_to_task’: > > fs/fcntl.c:738:20: warning: statement will never be executed [-Wswitch-unreachable] > > 738 | kernel_siginfo_t si; > > | ^~ > > > > [1] https://bugs.llvm.org/show_bug.cgi?id=44916 > > > > Signed-off-by: Kees Cook > > Ping. Can someone pick this up, please? > > Thanks! > > -Kees > > > --- > > fs/fcntl.c | 6 ++++-- > > 1 file changed, 4 insertions(+), 2 deletions(-) > > > > diff --git a/fs/fcntl.c b/fs/fcntl.c > > index 9bc167562ee8..2e4c0fa2074b 100644 > > --- a/fs/fcntl.c > > +++ b/fs/fcntl.c > > @@ -735,8 +735,9 @@ static void send_sigio_to_task(struct task_struct *p, > > return; > > > > switch (signum) { > > - kernel_siginfo_t si; > > - default: > > + default: { > > + kernel_siginfo_t si; > > + > > /* Queue a rt signal with the appropriate fd as its > > value. We use SI_SIGIO as the source, not > > SI_KERNEL, since kernel signals always get > > @@ -769,6 +770,7 @@ static void send_sigio_to_task(struct task_struct *p, > > si.si_fd = fd; > > if (!do_send_sig_info(signum, &si, p, type)) > > break; > > + } > > /* fall-through - fall back on the old plain SIGIO signal */ > > case 0: > > do_send_sig_info(SIGIO, SEND_SIG_PRIV, p, type); > > Sure, looks straightforward enough. I'll pick it up for v5.7. Thanks, -- Jeff Layton