Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp41681rwb; Mon, 26 Sep 2022 14:26:06 -0700 (PDT) X-Google-Smtp-Source: AMsMyM41jDO4T9XbbCXgn5UJfi85C62OdLYPJDUewDQDnHvKad1r/PfnEC94et0Fyj7oA9OMqCEP X-Received: by 2002:a17:907:2723:b0:77c:8beb:643b with SMTP id d3-20020a170907272300b0077c8beb643bmr20366266ejl.86.1664227565977; Mon, 26 Sep 2022 14:26:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664227565; cv=none; d=google.com; s=arc-20160816; b=ftgWP6xueqmLq4FpCvGnyLropxbEIx1XRm386eOkmmQFqJhDByTkGlT3t+q0d7bkbx NOahEWu0bnaJ9KmRXrDO9Xtagy9t5gVXB5/DiIXy9pRN7W1dKH9ukN74OBkCbeEQgoPX uphFRxbaJXZS0RgVAidICxw/YzR0bRkrMpF/x+9A/XHO8sFPewWIgzu7YDU55b1rlrby BWLv1zQ/lrXejetnBAO2NojaPVNEaEWMSWwTgPTLCEzSyY53gHdsQGRUJ96TlKwKXyXx Z+bEIMfkS1ouIo04Mn4gWj73TJp7q6GDpT847s1Peh/uNsuuaIOpD13AU/wNeNC/P3mK TaHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=LBF//pAX5WHcz7xdaQr4Nf4d4GrRr37crvjLDzbblIk=; b=M3AuMxoRNuzM/EPOxoZS5T5x+HXc+6LMM2UG7sTxCGy/hc7L0DRH52gYlJHVsl3xN6 zwvD6whXQqSrONVm4+y0osPeOc65Bp1HlIzef1dZI+9LdC3BzVcjvI1EbLq917y0rQ7s TNJTI0ECWM0ajTWSc3s3nfkvInfy5hMZ0zYVeMounHXebp25peIbiSD5C9/BmUeDR+Ch RMQdTttgahnpUzTBBEO2KC1AxniuMjGhD/49ILyxhaWSK0v16sjUI5GoZOmi0F7vZUay dB5F+uubZ1NVLTmCIN+HnCc9hL59znIzHp/QJBcY5v12XTIe1eHuiXDOOUF3SYClxV9A 03DA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Bji77umc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ho34-20020a1709070ea200b007417c184ea5si1082215ejc.628.2022.09.26.14.25.40; Mon, 26 Sep 2022 14:26:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Bji77umc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S230389AbiIZURf (ORCPT + 99 others); Mon, 26 Sep 2022 16:17:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230320AbiIZURc (ORCPT ); Mon, 26 Sep 2022 16:17:32 -0400 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC337A3453 for ; Mon, 26 Sep 2022 13:17:30 -0700 (PDT) Received: by mail-pf1-x435.google.com with SMTP id a80so7797803pfa.4 for ; Mon, 26 Sep 2022 13:17:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=LBF//pAX5WHcz7xdaQr4Nf4d4GrRr37crvjLDzbblIk=; b=Bji77umcsdJeihjx85Wx1yJAb732Oz1ZA1q21x7/tJcnTUW/8fZte+SBOWKRr2y2X4 t7UYhPhE3DC/SUmvxlRXNayEpDUn6fkDZy7UDvvNDbtu4owhre655mCikZL0f8jsHtqv cGn9ctLsI5otDOKjNY0EQMprAXB1loNeikeBDNXuhf21Gc6YNSGymHqhwg97uF5tGFMe IZ94nsGJZnj+0Ru0uhnDDrRz3FETUQWktqxCIkpnHZcyY5l8qG/NsoDS/+XHrgbZsJr4 SbniuV3EE/E7bFBu3CiLO4p6FpJn/FlCsxGzzDKgRIkz5AdRBT3N+leywHBff6krEQW8 RNBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=LBF//pAX5WHcz7xdaQr4Nf4d4GrRr37crvjLDzbblIk=; b=Gsbm+KL464+dyyv8V1n7Rw1DBtEKYjpnDLaXK+OzfXDRkovZTZtX+iXupjsIde2pnL MtsIr6yxzV3nBdf09Mo3oW+ARZOEC3PNqa2kMdJSfUVhmgDViFznHfF1kLDHA6SAHq8D A/k+2/TxdHKIbWs8zRaFuY1szf2g91iuoB0jnqpB1GBCFNxxvMVyI4CCbVgSKaGmPe6l H8TQAljEn37rsIMp08GE90ClMqseJXvD0CUack2beYd7BTGcy+lxvUYgjPfs4LZIN17Q JteG6LtIDeo0lVDyMMslqHUnCZAjczSViZQ/kEB7ZmkuZqOvgElRiCO03gBequt53UBg lVkA== X-Gm-Message-State: ACrzQf2EhPJSWX4VhvLmfnA+i8Fcz7uFULzfVYsT8rBcU/DSI8N7BWVG uLJNC/FR0nKus1GB+3dXbFkfTl+yPjsF+GlDqxLtww== X-Received: by 2002:a63:2cd2:0:b0:41c:5901:67d8 with SMTP id s201-20020a632cd2000000b0041c590167d8mr21300624pgs.365.1664223450163; Mon, 26 Sep 2022 13:17:30 -0700 (PDT) MIME-Version: 1.0 References: <20220926191109.1803094-1-keescook@chromium.org> In-Reply-To: <20220926191109.1803094-1-keescook@chromium.org> From: Nick Desaulniers Date: Mon, 26 Sep 2022 13:17:18 -0700 Message-ID: Subject: Re: [PATCH v2] overflow: Introduce overflows_type() and castable_to_type() To: Kees Cook Cc: Gwan-gyeong Mun , Luc Van Oostenryck , Nathan Chancellor , Tom Rix , Daniel Latypov , Vitor Massaru Iha , "Gustavo A. R. Silva" , linux-hardening@vger.kernel.org, llvm@lists.linux.dev, Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Daniel Vetter , linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-sparse@vger.kernel.org, Arnd Bergmann Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org + Arnd On Mon, Sep 26, 2022 at 12:11 PM Kees Cook wrote: > --- > v2: > - fix comment typo > - wrap clang pragma to avoid GCC warnings > - style nit cleanups > - rename __castable_to_type() to castable_to_type() > - remove prior overflows_type() definition > v1: https://lore.kernel.org/lkml/20220926003743.409911-1-keescook@chromium.org > diff --git a/lib/overflow_kunit.c b/lib/overflow_kunit.c > index f385ca652b74..fffc3f86181d 100644 > --- a/lib/overflow_kunit.c > +++ b/lib/overflow_kunit.c > @@ -16,6 +16,11 @@ > #include > #include > > +/* We're expecting to do a lot of "always true" or "always false" tests. */ > +#ifdef CONFIG_CC_IS_CLANG > +#pragma clang diagnostic ignored "-Wtautological-constant-out-of-range-compare" > +#endif Any chance we can reuse parts of __diag_ignore or __diag_clang from include/linux/compiler_types.h or include/linux/compiler-clang.h respectively? Those are needed for pragmas within preprocessor macros, which we don't have here, but I suspect they may be more concise to use here. > +#define TEST_SAME_TYPE(t1, t2, same) do { \ > + typeof(t1) __t1h = type_max(t1); \ > + typeof(t1) __t1l = type_min(t1); \ > + typeof(t2) __t2h = type_max(t2); \ > + typeof(t2) __t2l = type_min(t2); \ Can we use __auto_type here rather than typeof(macro expansion)? -- Thanks, ~Nick Desaulniers