Received: by 10.213.65.68 with SMTP id h4csp343241imn; Fri, 30 Mar 2018 22:38:57 -0700 (PDT) X-Google-Smtp-Source: AIpwx49MPGCZMg6brKFjcyzUj0hcdBpSJaZOHKO03fuU6TQCDGnwcB9Xlkn4u9Kf+j8FIf9RgPDl X-Received: by 10.98.31.86 with SMTP id f83mr1334201pff.196.1522474737373; Fri, 30 Mar 2018 22:38:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522474737; cv=none; d=google.com; s=arc-20160816; b=GCm4TM3jPmVs9tEgB41b+pHsA35jIy1LfOnG/i9Rig7g8qJ5ovM3Y8bYaDpeVpUoWI Bw2r55y75v7QylPGf5srT26EPggUHVPF2x3Ulb0pQF5m5/GL7rgjgQSESHJwdyb1Na/7 KvS0opjFNQo94iwVURqdwcJ6B5DhHc7fvasJDUy+stPzZN4JgWL+7pIQ1ewQ0jVeHDYN taGHbrBG1YS/jDyLPXzmYQQcQxeFdQFyUoboXbKdx0UHELHgS44mptJolhgnoqIZGcW0 PJ7ehQ7hCd83V70z/O7dBpwAEGp/5m/KFhdpQdWzRhsTxAvyoY/BGrqaWVpcBrGVyXn1 Zklw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=U4/9pGwXtG2foD/Qo+64uCaGI6AQqk/rAxgSrJ+dfEE=; b=AqmrTYF9hnlxRH491PVgSAP4y+dqVFWXdm/PAA7CRTvLgxZlk1nVufbJmjXf9WADOY 6yH3vSdzRA77AAJIsZCFi+nTySULifTLkgrAAJm0rklQEqWAXrKjCbyyYa9Fh3gAoTuf cbCYueQsuTI1QwkFkuLjKSdcIaraQQKOF9UVqjX+HnZdV59VOpoXaqFw3QCpzGgjEkKL 0MXuM4DBKmB9Epf6tK5p2+/s+/KABbWZkCwCw/7Y2GnFfuhxzsCZebRPDK2ytlzoGWSX kDhD/Xkxv+NABPatDB/EptsLjLMOsuxLo+t9xP47QgNl7PVeROz5xWOetQpe4H4Vbp72 YkGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=fUQQBzNq; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i63si6634842pge.289.2018.03.30.22.38.07; Fri, 30 Mar 2018 22:38:57 -0700 (PDT) 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=fail header.i=@gmail.com header.s=20161025 header.b=fUQQBzNq; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751376AbeCaFek (ORCPT + 99 others); Sat, 31 Mar 2018 01:34:40 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:41675 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750776AbeCaFei (ORCPT ); Sat, 31 Mar 2018 01:34:38 -0400 Received: by mail-wr0-f193.google.com with SMTP id f14so9362524wre.8 for ; Fri, 30 Mar 2018 22:34:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=U4/9pGwXtG2foD/Qo+64uCaGI6AQqk/rAxgSrJ+dfEE=; b=fUQQBzNq9yRH+hkBFhw++wR+eSOfMGHXolKj7OEhJ3GQQPxEk8o/EMVHksSHIuko39 moniODM81GMY7NbrHugZuNpGoSRdJBiq9TSAIeFeKmgzTrVRMsUlse5TVuaWfH+8O7Mo I9/xN7m4fbxGRahXccixoxgVUYniGW4+XQtbbesPjTMCMovGzGQP+09jJGpd8Mp+QuFU YcafZP0vG+VtwXlekBbw2W0f1LX7Az/dzBSij0Q0j9ozhRCu5kAInDSEzTchKk34qRjg YmKjqetA3Ec/lKR5GqjFb6a0WVNSp5kV5zvcXdTbNivKUkra8o1H4sayl0aHZDbeG0JM 78eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=U4/9pGwXtG2foD/Qo+64uCaGI6AQqk/rAxgSrJ+dfEE=; b=A/pxhEjyJ6KrZGCFexJxzOTXAuv3JAvFc0LE9ncDa+wcDIDpuroKMQNKkI2u86xckj rqLxYo42/CIzHePbZHn72nJKY1l7DNJPG/NYfuoJuT6KmcGM5TEt7pHp+V5DFAHJR6bq fehZz+Uy9hAD0ldWRcwL/ws/GXC8RsEqy6NeGXWp5saPchnqFM65eDCOn+608ICTcAMR MEnUZ8QHZ6FevfjllzwqgMxgtgDEM/BZv0kxvGUs68t8gx0DxbwNsi7R0fM3j7s5RXj1 O2AUWf8jMzz6mPJc1T7oclPt876jjZMFENJcIrHU+43CsINL9DsmT9FUznZpy6LtZg7+ PlMQ== X-Gm-Message-State: AElRT7E1V5/qddhUftaTvKNw46aZgYGIhCz7kzmIw2j23etj8i8pgDpK D5R2H2aMlby80WHKQHuq0x4= X-Received: by 10.223.176.171 with SMTP id i40mr967184wra.246.1522474477377; Fri, 30 Mar 2018 22:34:37 -0700 (PDT) Received: from gmail.com (2E8B0CD5.catv.pool.telekom.hu. [46.139.12.213]) by smtp.gmail.com with ESMTPSA id p15sm7929219wmd.7.2018.03.30.22.34.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 30 Mar 2018 22:34:36 -0700 (PDT) Date: Sat, 31 Mar 2018 07:34:34 +0200 From: Ingo Molnar To: Kees Cook Cc: Andrew Morton , Linus Torvalds , Martin Uecker , Josh Poimboeuf , Rasmus Villemoes , Randy Dunlap , Miguel Ojeda , David Laight , Ian Abbott , LKML , Kernel Hardening Subject: Re: [PATCH v6] kernel.h: Retain constant expression output for max()/min() Message-ID: <20180331053434.akno723avvcri654@gmail.com> References: <20180326221554.GA45166@beast> <20180327054748.jx6mzywguuqfkqpv@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Kees Cook wrote: > On Mon, Mar 26, 2018 at 10:47 PM, Ingo Molnar wrote: > > > > * Kees Cook wrote: > > > >> In the effort to remove all VLAs from the kernel[1], it is desirable to > >> build with -Wvla. However, this warning is overly pessimistic, in that > >> it is only happy with stack array sizes that are declared as constant > >> expressions, and not constant values. One case of this is the evaluation > >> of the max() macro which, due to its construction, ends up converting > >> constant expression arguments into a constant value result. > >> > >> All attempts to rewrite this macro with __builtin_constant_p() failed with > >> older compilers (e.g. gcc 4.4)[2]. However, Martin Uecker constructed[3] a > >> mind-shattering solution that works everywhere. Cthulhu fhtagn! > >> > >> This patch updates the min()/max() macros to evaluate to a constant > >> expression when called on constant expression arguments. This removes > >> several false-positive stack VLA warnings from an x86 allmodconfig > >> build when -Wvla is added: > > > > Cool! > > > > Acked-by: Ingo Molnar > > > > How many warnings are left in an allmodconfig build? > > For -Wvla? Out of the original 112 files with VLAs, 42 haven't had a > patch applied yet. Doing a linux-next allmodconfig build with the > max() patch and my latest ecc patch, we've gone from 316 warning > instances to 205. More than half of those are in > include/crypto/skcipher.h and include/crypto/hash.h. Great - once the number of warnings is zero, is the plan to enable the warning unconditionally? Thanks, Ingo