Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp509517rwb; Tue, 27 Sep 2022 00:05:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7soQRzP9ZGbJ8du7LAIBAG8yi5rgMQim84gLj83CTWGkjzeSn48o9N5BZrWY0wzA3Zljp3 X-Received: by 2002:a63:585c:0:b0:439:61d5:17fc with SMTP id i28-20020a63585c000000b0043961d517fcmr22921914pgm.364.1664262322637; Tue, 27 Sep 2022 00:05:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664262322; cv=none; d=google.com; s=arc-20160816; b=vdtlD7MLolWDYj0QE88UIgaz9O7rxGWMSjJkCQlMgB02540labPcjBg+xnJKX7L3r/ P6WaWsSO21FAMpR7WLX1/xaZfGSteD/v9kBvphra3cUqi/gVIpdc2Qu9pos7/GU9ECIW 7NCQtO+fq9Ws0MhI4JQ/7+0wCdh2w79vbApYM5w9TPk7MwPAzRz3aH5psaWu3ypZGGuD RFUkgjUyVSIRHpWUD8bUYAGnL1tcSCxoSxTAZ0AgJCzqlCp5TlHfblyByPVCMgW1ozUd sCsrqcn1ncHSxxaBlFT1ZZFyYR1ocTtI+5uw40bHZ2Y91WksABZEq0Ifsoahc2mTOuZx YjgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:date:references:in-reply-to :message-id:mime-version:user-agent:feedback-id:dkim-signature; bh=TzO+ODVQbZM3RLr25LPxtnSO8wG2IKyol1fYyPxsSTw=; b=CEe0ceX/xAIwKmVBw/BdCWcOndXc/Ja1IvD4QRiSrxY0B61ZmJQI5OfXqiTInACHY2 S018sjQgakMeguvTLIByQe83PYTdURUUYq0IjI7IkvBheEe1aDxNU2JC0nssVzUJ1S0m 7rVSguOWbmWW8q5yK9Kroe0UPCy6zR8UawnU4h/7LxVYMY16iR0R4Ll0cuCUKsEqpXSr QN4DKXkxG5IZywn+Ibl+MnN/rpgG315/CYUcHyXAVQgx5TPkuxFaP/5e6pUt/cwXDnCi nM73qofY53zFJpWtDua2S8uJ+tWdSPmveZ8+w3McQFMbrOG4SbByXrPMIoOc79vJr2xx 6S9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lI+CwghM; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k8-20020a170902c40800b0017555e9de54si1087306plk.427.2022.09.27.00.05.11; Tue, 27 Sep 2022 00:05:22 -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=@kernel.org header.s=k20201202 header.b=lI+CwghM; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229969AbiI0GqO (ORCPT + 99 others); Tue, 27 Sep 2022 02:46:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229608AbiI0GqK (ORCPT ); Tue, 27 Sep 2022 02:46:10 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB4FF9F757 for ; Mon, 26 Sep 2022 23:46:08 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 4A00EB819D2 for ; Tue, 27 Sep 2022 06:46:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 829A8C433D7; Tue, 27 Sep 2022 06:46:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1664261165; bh=eEUvxBZsi9LqCvOrkkoLXt0oGQK0hSltb52/gNuFgZc=; h=In-Reply-To:References:Date:From:To:Cc:Subject:From; b=lI+CwghMpzN++0ZUnThnzTvbWp/kmLG3EKJnSz2lqlMmF5N41snJ24ZJd3KOO8Q2i kC19a2HtXl3Wc5T8/FA0EOecRsTNEDRiaTBYueezXngaNLK5kDQ62TH1j7TdWKPDO9 Aw4bbd4E+bJFtmVrZ7fPjI15Vp81XO9/TdKClb0hufGU1cYEv5UEMky8iZ7pPPsHfQ ctKj+NxHpm3kJ1poWIkH6Tx7AK7lh88jJI9pFj7WdvSDCjJni/L4riZ3wYQvUQ68V7 6Mxf/Z2icQjUnSVyTKl1UpbKOVNmmWGf/3OKKqs12b/ckuROsEKmMbMS6AbM/I3OLV rhFVDPKWrSe+g== Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailauth.nyi.internal (Postfix) with ESMTP id 5057227C0054; Tue, 27 Sep 2022 02:46:04 -0400 (EDT) Received: from imap51 ([10.202.2.101]) by compute3.internal (MEProxy); Tue, 27 Sep 2022 02:46:04 -0400 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeegfedgudduhecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfgjfhffhffvvefutgesthdtredtreertdenucfhrhhomhepfdet rhhnugcuuegvrhhgmhgrnhhnfdcuoegrrhhnugeskhgvrhhnvghlrdhorhhgqeenucggtf frrghtthgvrhhnpeelvefgudeiheefledttedthfffgfekudegkeelffdtiedvgfevieet teekheffveenucffohhmrghinhepkhgvrhhnvghlrdhorhhgnecuvehluhhsthgvrhfuih iivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghrnhguodhmvghsmhhtphgruhht hhhpvghrshhonhgrlhhithihqdduvdekhedujedtvdegqddvkeejtddtvdeigedqrghrnh gupeepkhgvrhhnvghlrdhorhhgsegrrhhnuggsrdguvg X-ME-Proxy: Feedback-ID: i36794607:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 81704B60089; Tue, 27 Sep 2022 02:46:03 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.7.0-alpha0-968-g04df58079d-fm-20220921.001-g04df5807 Mime-Version: 1.0 Message-Id: <854247e0-6276-4f3b-b4e9-b408e151a6b3@www.fastmail.com> In-Reply-To: <202209261405.619441AC2F@keescook> References: <20220926191109.1803094-1-keescook@chromium.org> <202209261405.619441AC2F@keescook> Date: Tue, 27 Sep 2022 08:45:43 +0200 From: "Arnd Bergmann" To: "Kees Cook" , "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 Subject: Re: [PATCH v2] overflow: Introduce overflows_type() and castable_to_type() Content-Type: text/plain X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 On Mon, Sep 26, 2022, at 11:07 PM, Kees Cook wrote: > 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? We use them in a couple of places. When I originally introduced them, the idea was to add more infrastructure around these to replace the various -Wno-... flags in local makefiles with more targetted annotations, and then have a way to control the warning levels (W=1 W=2 E=1 etc) per directory and per file, but I never completed the work to add the interesting bits. >> 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. The idea of __auto_type is to avoid the more deeply nested macros. If the preprocessed file turns into an absolute mess, adding a temporary variable may help. Not sure if that applies here. Arnd