From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from benson.default.arb33.uk0.bigv.io ([46.43.0.16]:42259 "EHLO benson.default.arb33.uk0.bigv.io" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750883AbeCHWRn (ORCPT ); Thu, 8 Mar 2018 17:17:43 -0500 Message-ID: <1520546351.23648.32.camel@hellion.org.uk> Subject: Re: [PATCH] kernel.h: Skip single-eval logic on literals in min()/max() From: Ian Campbell To: Kees Cook , Andrew Morton Cc: Josh Poimboeuf , Rasmus Villemoes , "Gustavo A. R. Silva" , "Tobin C. Harding" , rostedt@goodmis.org, corbet@lwn.net, Chris Mason , Josef Bacik , David Sterba , "David S. Miller" , Alexey Kuznetsov , Hideaki YOSHIFUJI , Ingo Molnar , Peter Zijlstra , Thomas Gleixner , Masahiro Yamada , Borislav Petkov , Randy Dunlap , Ian Abbott , Sergey Senozhatsky , Petr Mladek , Andy Shevchenko , Pantelis Antoniou , linux-btrfs@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com Date: Thu, 08 Mar 2018 21:59:11 +0000 In-Reply-To: <20180308214045.GA6787@beast> References: <20180308214045.GA6787@beast> Content-Type: text/plain; charset="ISO-8859-1" Mime-Version: 1.0 Sender: linux-btrfs-owner@vger.kernel.org List-ID: On Thu, 2018-03-08 at 13:40 -0800, Kees Cook wrote: > > +#define __min(t1, t2, x, y) \ > + __builtin_choose_expr(__builtin_constant_p(x) && \ > + __builtin_constant_p(y) && \ > + __builtin_types_compatible_p(t1, t2), \ > + (t1)(x) < (t2)(y) ? (t1)(x) : (t2)(y), \ > + __single_eval_min(t1, t2, \ > + __UNIQUE_ID(max1_), \ > + __UNIQUE_ID(max2_), \ min1_ etc? Ian.