Received: by 10.213.65.68 with SMTP id h4csp1099728imn; Sun, 18 Mar 2018 14:43:51 -0700 (PDT) X-Google-Smtp-Source: AG47ELvJPZCL5wZtv7lvWlS1Me75gqt94JlFtcgB/QW5Jw5bxfI3SFrx/V6JJO2H0/xhwgOjW29K X-Received: by 10.98.61.80 with SMTP id k77mr1823667pfa.2.1521409431380; Sun, 18 Mar 2018 14:43:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521409431; cv=none; d=google.com; s=arc-20160816; b=LD64C8UcAZ5l12OFAauoXIYOgoG29DT67/UExx8xQ3l9MiI/NUg+Cw1dEOe5qORfdm RKHSUX7NfOIJsPvZK1oPJnwxRYOAMMROhS16eCySuadking9G81EaIpgtJXQctVulEPE jGUymQu59a82ETUbkBpeA5qgPevQUNv0GQf6kz1yM0Ozyd6zYFAVRNcPzQCE+SexqQlc qojIsVCzP5ogLgkfjiejl9Q16XeZZ+Z1RYlbHDKNuUXdZk3e7oHTKAwGwvJ67npYIZnI yUpfRCvt0XIi3OLwg0n2dH6Z4LiRpobdSDSI9hci/VFPEU6axX2UZI2JWmc3dH2i2s0u vtVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature:dkim-signature :arc-authentication-results; bh=wNizOT6HONS2DW5gzlP0xlyT2p8aQEuxrrEymSWTJRY=; b=SBpEuYsQCuDkV3AwjRBiM1psgJcThyMQ2rzBrxFgCgoZT1IcPO2m2J9vr7zK0dwVQl uT+cKajyL679oxwsuzq+P91yPZOLwigg4SzD9+qF4PxGc4twQhT8WZ18j7xrvWK9uFnl n7nM3OE3Bm24uu8wKQxUl0Sg8tchVdcwf1XqRxHf0AAtlhrafxW8RZE2rVdaV31JupdH q52yspbHlo2nhLbGovCucqMDjLap+T0rqEedND5OTEvHBf0RUQ2Ir1Gy3LG74pFSIFY7 himIiTXA/gXBhwzCpkNv1oingTxVH4kFShGlWwr3lzQrr+JDRmjPZddC0vR0x1FvKdLS EcBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=fvEMTa5T; dkim=fail header.i=@linux-foundation.org header.s=google header.b=WfwBeNAk; 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 h8si9210918pfi.117.2018.03.18.14.43.33; Sun, 18 Mar 2018 14:43:51 -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=fvEMTa5T; dkim=fail header.i=@linux-foundation.org header.s=google header.b=WfwBeNAk; 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 S1754733AbeCRVd3 (ORCPT + 99 others); Sun, 18 Mar 2018 17:33:29 -0400 Received: from mail-io0-f194.google.com ([209.85.223.194]:37291 "EHLO mail-io0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754541AbeCRVdZ (ORCPT ); Sun, 18 Mar 2018 17:33:25 -0400 Received: by mail-io0-f194.google.com with SMTP id y128so1020288iod.4; Sun, 18 Mar 2018 14:33:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=wNizOT6HONS2DW5gzlP0xlyT2p8aQEuxrrEymSWTJRY=; b=fvEMTa5TFrSre6YuEXvs+3ujFvLjlCfqGKBl4jsz/LHNmR+kcutDK6Z65jq0NgcTqg zMMz2dIXxWMgqY1ZbeC5ZWv5Ea9aWdcj0AQ4/5GDumYOj7Tl8aeNc/WI8WuEkFsyXoKH sxwGzdxzCiIdbzPBgFjhKe2zbDupCuYV8R6Xlo4EdpnnW9EZCKn1bd+E4m2F+Q6fICsK ZzfyPi3hkoTRGg2PIn7CIUjWXMYGC7WvaIJ2DMkCQJn/0A7G6nG0ZxeZ2maOA0btSrGu gIJpHmpHKw0hDkxISUOTgrqN0bxQFjQdIfUywMYULzjkndhimhPiiZvu/9b2fsU8kkUQ 6NYg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=wNizOT6HONS2DW5gzlP0xlyT2p8aQEuxrrEymSWTJRY=; b=WfwBeNAk1joxPKF8wuxBzisYxp2CvnvRcexthO9ZHfv5ooJdzQDjcQNag+TxvksbwF 0xs6jAC3AqIdhs9sPIGquWvTt0341wRcxQ2c+k9G1WTnI5PU7YNI0A9FjZv6lN7LUtOl 1rpWzQ0ZsbgabtD/NVdXrjCrjA6z0ibIGNT4A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=wNizOT6HONS2DW5gzlP0xlyT2p8aQEuxrrEymSWTJRY=; b=hIgATU0Ind8gTOfFf0YbYCqT2L1D8WYAdLVU4e54ojyjKTpR65+Kpq1M2cmiB/aXEi rfnF5wQfzmCL2QwFQcKn+FkRQuABu4bh9n4bil3PpYfU0q6xYqv8d1asEuO8Hy9oyQiy eckSNql79HbHDr566dQYSelYQkX+7ZtCJJ9rhnqLrwH+PbpiUs4cCqWXd6jGQdk0qVX9 SKkdNgX+H8co90mJ04VBbbvCJPJaH0dsRIZwEmFg1HweyLwbUI2M8On1671qvyc6ePJT 1o7t8PzQbbTiU091m+zljkPkHyWgWTKmn3lZ7zXQPfzeEgyDpGiP3zOPoVrJ4mUKTU3a BgiQ== X-Gm-Message-State: AElRT7G3xwOlgoZ5MzT7MTkrGi6v8XbPbNYnYZ2zgP5esR162FdO90W5 cGmO+aLTxMObnc1Sy2H1d1peD0yMeKe/8NlWAd8= X-Received: by 10.107.12.201 with SMTP id 70mr9696853iom.48.1521408804250; Sun, 18 Mar 2018 14:33:24 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.95.15 with HTTP; Sun, 18 Mar 2018 14:33:23 -0700 (PDT) In-Reply-To: <42b4342b-aefc-a16a-0d43-9f9c0d63ba7a@rasmusvillemoes.dk> References: <1521174359-46392-1-git-send-email-keescook@chromium.org> <20180316175502.GE30522@ZenIV.linux.org.uk> <42b4342b-aefc-a16a-0d43-9f9c0d63ba7a@rasmusvillemoes.dk> From: Linus Torvalds Date: Sun, 18 Mar 2018 14:33:23 -0700 X-Google-Sender-Auth: Mccg8ClxyZvlW7FTSlowcGl4-1Q Message-ID: Subject: Re: [PATCH v5 0/2] Remove false-positive VLAs when using max() To: Rasmus Villemoes Cc: Kees Cook , Al Viro , Florian Weimer , Andrew Morton , Josh Poimboeuf , Randy Dunlap , Miguel Ojeda , Ingo Molnar , David Laight , Ian Abbott , linux-input , linux-btrfs , Network Development , Linux Kernel Mailing List , Kernel Hardening Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Mar 18, 2018 at 2:13 PM, Rasmus Villemoes wrote: > On 2018-03-17 19:52, Linus Torvalds wrote: >> >> Ok, so it really looks like that same "__builtin_constant_p() doesn't >> return a constant". >> >> Which is really odd, but there you have it. > > Not really. We do rely on builtin_constant_p not being folded too > quickly to a 0/1 answer, so that gcc still generates good code even if > the argument is only known to be constant at a late(r) optimization > stage (through inlining and all). Hmm. That makes sense. It just doesn't work for our case when we really want to choose the expression based on side effects or not. > So unlike types_compatible_p, which > can obviously be answered early during parsing, builtin_constant_p is > most of the time a yes/no/maybe/it's complicated thing. The silly thing is, the thing we *really* want to know _is_ actually easily accessible during the early parsing, exactly like __builtin_compatible_p(): it's not really that we care about the expressions being constant, as much as the "can this have side effects" question. We only really use __builtin_constant_p() as a (bad) approximation of that in this case, since it's the best we can do. So the real use would be to say "can we use the simple direct macro that just happens to also fold into a nice integer constant expression" for __builtin_choose_expr(). I tried to find something like that, but it really doesn't exist, even though I would actually have expected it to be a somewhat common concern for macro writers: write a macro that works in any arbitrary environment. I guess array sizes are really the only true limiting environment (static initializers is another one). How annoying. Odd that newer gcc's seem to do so much better (ie gcc-5 seems to be fine). So _something_ must have changed. Linus