All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Arnd Bergmann" <arnd@kernel.org>
To: "Kees Cook" <keescook@chromium.org>,
	"Nick Desaulniers" <ndesaulniers@google.com>
Cc: "Gwan-gyeong Mun" <gwan-gyeong.mun@intel.com>,
	"Luc Van Oostenryck" <luc.vanoostenryck@gmail.com>,
	"Nathan Chancellor" <nathan@kernel.org>,
	"Tom Rix" <trix@redhat.com>,
	"Daniel Latypov" <dlatypov@google.com>,
	"Vitor Massaru Iha" <vitor@massaru.org>,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>,
	linux-hardening@vger.kernel.org, llvm@lists.linux.dev,
	"Jani Nikula" <jani.nikula@linux.intel.com>,
	"Joonas Lahtinen" <joonas.lahtinen@linux.intel.com>,
	"Rodrigo Vivi" <rodrigo.vivi@intel.com>,
	"Tvrtko Ursulin" <tvrtko.ursulin@linux.intel.com>,
	"David Airlie" <airlied@linux.ie>,
	"Daniel Vetter" <daniel@ffwll.ch>,
	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()
Date: Tue, 27 Sep 2022 08:45:43 +0200	[thread overview]
Message-ID: <854247e0-6276-4f3b-b4e9-b408e151a6b3@www.fastmail.com> (raw)
In-Reply-To: <202209261405.619441AC2F@keescook>

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 <keescook@chromium.org> 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 <linux/types.h>
>> >  #include <linux/vmalloc.h>
>> >
>> > +/* 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

WARNING: multiple messages have this Message-ID (diff)
From: "Arnd Bergmann" <arnd@kernel.org>
To: "Kees Cook" <keescook@chromium.org>,
	"Nick Desaulniers" <ndesaulniers@google.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>,
	linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
	David Airlie <airlied@linux.ie>, Tom Rix <trix@redhat.com>,
	Daniel Latypov <dlatypov@google.com>,
	llvm@lists.linux.dev,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>,
	Gwan-gyeong Mun <gwan-gyeong.mun@intel.com>,
	Nathan Chancellor <nathan@kernel.org>,
	linux-sparse@vger.kernel.org, linux-hardening@vger.kernel.org,
	Rodrigo Vivi <rodrigo.vivi@intel.com>,
	intel-gfx@lists.freedesktop.org,
	Vitor Massaru Iha <vitor@massaru.org>,
	Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: Re: [PATCH v2] overflow: Introduce overflows_type() and castable_to_type()
Date: Tue, 27 Sep 2022 08:45:43 +0200	[thread overview]
Message-ID: <854247e0-6276-4f3b-b4e9-b408e151a6b3@www.fastmail.com> (raw)
In-Reply-To: <202209261405.619441AC2F@keescook>

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 <keescook@chromium.org> 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 <linux/types.h>
>> >  #include <linux/vmalloc.h>
>> >
>> > +/* 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

WARNING: multiple messages have this Message-ID (diff)
From: "Arnd Bergmann" <arnd@kernel.org>
To: "Kees Cook" <keescook@chromium.org>,
	"Nick Desaulniers" <ndesaulniers@google.com>
Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
	David Airlie <airlied@linux.ie>, Tom Rix <trix@redhat.com>,
	Daniel Latypov <dlatypov@google.com>,
	llvm@lists.linux.dev,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>,
	Nathan Chancellor <nathan@kernel.org>,
	linux-sparse@vger.kernel.org, linux-hardening@vger.kernel.org,
	Daniel Vetter <daniel@ffwll.ch>,
	Rodrigo Vivi <rodrigo.vivi@intel.com>,
	intel-gfx@lists.freedesktop.org,
	Vitor Massaru Iha <vitor@massaru.org>,
	Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: Re: [Intel-gfx] [PATCH v2] overflow: Introduce overflows_type() and castable_to_type()
Date: Tue, 27 Sep 2022 08:45:43 +0200	[thread overview]
Message-ID: <854247e0-6276-4f3b-b4e9-b408e151a6b3@www.fastmail.com> (raw)
In-Reply-To: <202209261405.619441AC2F@keescook>

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 <keescook@chromium.org> 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 <linux/types.h>
>> >  #include <linux/vmalloc.h>
>> >
>> > +/* 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

  reply	other threads:[~2022-09-27  6:46 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-26 19:11 [PATCH v2] overflow: Introduce overflows_type() and castable_to_type() Kees Cook
2022-09-26 19:11 ` [Intel-gfx] " Kees Cook
2022-09-26 19:11 ` Kees Cook
2022-09-26 20:17 ` Nick Desaulniers
2022-09-26 20:17   ` [Intel-gfx] " Nick Desaulniers
2022-09-26 20:17   ` Nick Desaulniers
2022-09-26 21:07   ` Kees Cook
2022-09-26 21:07     ` [Intel-gfx] " Kees Cook
2022-09-26 21:07     ` Kees Cook
2022-09-27  6:45     ` Arnd Bergmann [this message]
2022-09-27  6:45       ` [Intel-gfx] " Arnd Bergmann
2022-09-27  6:45       ` Arnd Bergmann
2022-09-27  0:27 ` [Intel-gfx] ✗ Fi.CI.BUILD: failure for " Patchwork
2022-09-27  8:29 ` [PATCH v2] " Gwan-gyeong Mun
2022-09-27  8:29   ` [Intel-gfx] " Gwan-gyeong Mun
2022-09-27  8:29   ` Gwan-gyeong Mun
2022-09-27 23:36 ` [Intel-gfx] " kernel test robot
2022-09-27 23:36   ` kernel test robot
2022-09-27 23:36   ` kernel test robot
2022-09-28  8:19 ` Gwan-gyeong Mun
2022-09-28  8:19   ` [Intel-gfx] " Gwan-gyeong Mun
2022-09-28  8:19   ` Gwan-gyeong Mun
2022-09-29  3:24 ` [Intel-gfx] " kernel test robot
2022-09-29  3:24   ` kernel test robot
2022-09-29  3:24   ` kernel test robot
2022-09-29  8:32 ` kernel test robot
2022-09-29  8:32   ` kernel test robot
2022-09-29  8:32   ` kernel test robot
2022-10-13  6:49 ` [PATCH v3] " Gwan-gyeong Mun
2022-10-13  6:49   ` Gwan-gyeong Mun
2022-10-13  6:49   ` [Intel-gfx] " Gwan-gyeong Mun
2022-10-13  8:12   ` Jani Nikula
2022-10-13  8:12     ` [Intel-gfx] " Jani Nikula
2022-10-13  8:12     ` Jani Nikula
2022-10-13  8:17 ` [Intel-gfx] ✗ Fi.CI.BUILD: failure for overflow: Introduce overflows_type() and castable_to_type() (rev2) Patchwork
2022-10-21  8:33 ` [PATCH v4] overflow: Introduce overflows_type() and castable_to_type() Gwan-gyeong Mun
2022-10-21  8:33   ` [Intel-gfx] " Gwan-gyeong Mun
2022-10-21  8:33   ` Gwan-gyeong Mun
2022-10-21 16:06   ` Nathan Chancellor
2022-10-21 16:06     ` [Intel-gfx] " Nathan Chancellor
2022-10-21 16:06     ` Nathan Chancellor
2022-10-21 12:29 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for overflow: Introduce overflows_type() and castable_to_type() (rev3) Patchwork
2022-10-21 12:29 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2022-10-21 12:48 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2022-10-21 19:46 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork
2022-10-24 20:11 ` [PATCH v5] overflow: Introduce overflows_type() and castable_to_type() Gwan-gyeong Mun
2022-10-24 20:11   ` Gwan-gyeong Mun
2022-10-24 20:11   ` [Intel-gfx] " Gwan-gyeong Mun
2022-10-29  5:55   ` Gwan-gyeong Mun
2022-10-29  5:55     ` [Intel-gfx] " Gwan-gyeong Mun
2022-10-29  5:55     ` Gwan-gyeong Mun
2022-10-29  7:32     ` Kees Cook
2022-10-29  7:32       ` [Intel-gfx] " Kees Cook
2022-10-29  7:32       ` Kees Cook
2022-10-29  8:01       ` Gwan-gyeong Mun
2022-10-29  8:01         ` [Intel-gfx] " Gwan-gyeong Mun
2022-10-29  8:01         ` Gwan-gyeong Mun
2022-11-01 23:06         ` Kees Cook
2022-11-01 23:06           ` [Intel-gfx] " Kees Cook
2022-11-02 11:27           ` Gwan-gyeong Mun
2022-11-02 11:27             ` [Intel-gfx] " Gwan-gyeong Mun
2022-11-02 11:27             ` Gwan-gyeong Mun
2022-11-02 11:52   ` Rasmus Villemoes
2022-11-02 11:52     ` [Intel-gfx] " Rasmus Villemoes
2022-11-02 11:52     ` Rasmus Villemoes
2022-11-02 19:33     ` Kees Cook
2022-11-02 19:33       ` [Intel-gfx] " Kees Cook
2022-11-02 19:33       ` Kees Cook
2022-10-25  0:31 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for overflow: Introduce overflows_type() and castable_to_type() (rev4) Patchwork
2022-10-25  0:31 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2022-10-25  0:53 ` [Intel-gfx] ✗ Fi.CI.BAT: failure " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=854247e0-6276-4f3b-b4e9-b408e151a6b3@www.fastmail.com \
    --to=arnd@kernel.org \
    --cc=airlied@linux.ie \
    --cc=daniel@ffwll.ch \
    --cc=dlatypov@google.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gustavoars@kernel.org \
    --cc=gwan-gyeong.mun@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jani.nikula@linux.intel.com \
    --cc=joonas.lahtinen@linux.intel.com \
    --cc=keescook@chromium.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sparse@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=luc.vanoostenryck@gmail.com \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=rodrigo.vivi@intel.com \
    --cc=trix@redhat.com \
    --cc=tvrtko.ursulin@linux.intel.com \
    --cc=vitor@massaru.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.