Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp43192rwb; Mon, 26 Sep 2022 14:27:32 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7aKnxaiWgox45n9mqZR49uQbAoZ0ekYIIQdwF80DXmTE37cisnUgyDf49jcJHl1LGl1NKQ X-Received: by 2002:a05:6402:90e:b0:443:ec4b:2b03 with SMTP id g14-20020a056402090e00b00443ec4b2b03mr24198040edz.71.1664227652200; Mon, 26 Sep 2022 14:27:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664227652; cv=none; d=google.com; s=arc-20160816; b=eMbqoY2ldu+Pr7pEDta46WZX+wp+cvOXm6YQ4NLL+xN2mi8+PBYlIOpmPUpOnxQ+OO lW6sDS23qmawacSPjJ47cijLUt70weVPPxpiZsm1Cp4n3cdw0zJDaFufsTrtc2DGXT5l zMmzolHYXd5+fobLFNutDgzmXyG1KNShaBmEF1SpUqqpIMes1pwwjSwr48UT++yXshkn wsquLdlNVDUtcYbf5rmDEQZC/HJLlCjd8U3mb129j4e5IBn4pGajEHY0Sbp5gSKX925i JwRsiws5zgK45drM7EtODoIYIXHGY+jHOJOX6ceaQD7oufgkU4mVMrY+bWSV6mvubG/c HzJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=VUYHQIv2vL8pY0r5skq1FuqyyfYP1QoMOYkxGZwbp6o=; b=AHTeZuRf57xVAE7zqF7YH0jylKpbRtup6VxFBTOU/Swhd3GMSs06EcxXIskzhqcn// fC7ZkCmlYt7l6tRBM6CGqRf6sjrL3wkZ0dYaJSFTlgBoTA1LyNHc+3cP275fnNh9cvT2 u2wVSWuLwVkcfPKP9yG50NYynQXFh3uVpy508P9nzT998CtfIBkw1tlg+jnc01X4W24t wUMe1/ckujEqv0wfCmJEzZu3wUbGhuOtFzNZvLqhCxfmm6ya7yeKOztI6AesYbql2Neu 1ZuO+W2BAWPY5BTZ2K7mIOLEgFauSgEBrRvjbYWtRlt6VDw9vWPeSRJ1tXD4b0YSEsb0 Aeig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=TxQD2fJT; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id he35-20020a1709073da300b0076fd1d815bcsi1182046ejc.748.2022.09.26.14.27.05; Mon, 26 Sep 2022 14:27:32 -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=@chromium.org header.s=google header.b=TxQD2fJT; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231350AbiIZVH0 (ORCPT + 99 others); Mon, 26 Sep 2022 17:07:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231316AbiIZVHT (ORCPT ); Mon, 26 Sep 2022 17:07:19 -0400 Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A60C8A1D57 for ; Mon, 26 Sep 2022 14:07:16 -0700 (PDT) Received: by mail-pg1-x52c.google.com with SMTP id 129so6225102pgc.5 for ; Mon, 26 Sep 2022 14:07:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date; bh=VUYHQIv2vL8pY0r5skq1FuqyyfYP1QoMOYkxGZwbp6o=; b=TxQD2fJTodac/gzds749N6eKDMqdv7Q8g+tPhsOiW/sX3qUzP3f31tYswj1cNjhZ+P GZ26rUT4PfJw2GQKkiXkOXyDG3qoXJdjcDtY3ngV/e6Eip/wNz2SxOqyLUFoEqou289d 65H2ej14mtX4cRsJfIOnYU6qdCyop+wYz0PRE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date; bh=VUYHQIv2vL8pY0r5skq1FuqyyfYP1QoMOYkxGZwbp6o=; b=0lbe0EyjY4/bYP82pWV+Igw2FXxlx63RoupKrJXiUJKafTOIn8t7Z6X7RXKOopY9cK yXKweO1DA7ljhrbzXywOlKOZMj/3JGqaioUoby9Rs5tC+qOa0s5bMS6Qm4EZrqb91zyf +WH1jAlRdHQHUA+xcgQ1nHtYuV08rxOgOsZfSBshnU0OCfertSQmkMVU7FvO4ppMnAIF knWwP/XPDhxrFsYWFqwwlSJGPZvtMxFl8izxVIbSHilulNbWNwwraT9SSVEQIOOW71ym 8F/ADx/nkl3P9OJGta0LjqDEPc2HbLTEfKTqFS/5mv8CpEXEb55yNN1MbDQ1Wdcm7ANq cllg== X-Gm-Message-State: ACrzQf0zgJ9hCjLrEJQc3kOVanMD5Csdce8LdCLgpDzxeIEEE+eckqgf mcbMsWMj5x4ZEIKAWTul5CrQsY2yIzbUWw== X-Received: by 2002:a63:441b:0:b0:439:103b:25a4 with SMTP id r27-20020a63441b000000b00439103b25a4mr21064706pga.487.1664226436243; Mon, 26 Sep 2022 14:07:16 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id h6-20020aa79f46000000b00540ffb28da0sm13290247pfr.91.2022.09.26.14.07.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 14:07:15 -0700 (PDT) Date: Mon, 26 Sep 2022 14:07:14 -0700 From: Kees Cook To: Nick Desaulniers 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 Subject: Re: [PATCH v2] overflow: Introduce overflows_type() and castable_to_type() Message-ID: <202209261405.619441AC2F@keescook> References: <20220926191109.1803094-1-keescook@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 On Mon, Sep 26, 2022 at 01:17:18PM -0700, Nick Desaulniers wrote: > + 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? Hm, I'm not sure how those are supposed to be used. Those defines don't seem to be used externally? > 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. Yeah, I was surprised when I had to wrap it in #ifdef given "clang" is part of the string. > > > +#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)? I'd rather it stay explicit -- otherwise we start to wander into "oops, we got lucky" territory for what should be a really distinct test case. -- Kees Cook