lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMuHMdVx0wpKhHKn0NppJRbMA2FwjKntPFX1zaJzKhQANeY6oQ@mail.gmail.com>
Date: Wed, 4 Dec 2024 14:15:07 +0100
From: Geert Uytterhoeven <geert@...ux-m68k.org>
To: Arnd Bergmann <arnd@...nel.org>
Cc: Linus Torvalds <torvalds@...uxfoundation.org>, David Laight <David.Laight@...lab.com>, 
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>, Jens Axboe <axboe@...nel.dk>, 
	Matthew Wilcox <willy@...radead.org>, Christoph Hellwig <hch@...radead.org>, 
	Andrew Morton <akpm@...ux-foundation.org>, 
	Andy Shevchenko <andriy.shevchenko@...ux.intel.com>, 
	Dan Carpenter <dan.carpenter@...aro.org>, "Jason A . Donenfeld" <Jason@...c4.com>, 
	"pedro.falcato@...il.com" <pedro.falcato@...il.com>, Mateusz Guzik <mjguzik@...il.com>, 
	"linux-mm@...ck.org" <linux-mm@...ck.org>, Lorenzo Stoakes <lorenzo.stoakes@...cle.com>, 
	Biju Das <biju.das.jz@...renesas.com>
Subject: Re: [PATCH v2 1/8] minmax: Put all the clamp() definitions together

Hi Arnd et al,

People started seeing this in today's linux-next...

On Tue, Jul 30, 2024 at 4:15 PM Arnd Bergmann <arnd@...nel.org> wrote:
> On Tue, Jul 30, 2024, at 12:10, Arnd Bergmann wrote:
> > On Tue, Jul 30, 2024, at 05:59, Linus Torvalds wrote:
> >> On Mon, 29 Jul 2024 at 16:21, Linus Torvalds <torvalds@...uxfoundation.org> wrote:
> >
> > I'm giving this a spin on the randconfig test setup now to see
> > if there are some other cases like the bcachefs one. So far I've
> > seen one failure, but I can't make sense of it yet:
> >
> > drivers/gpu/drm/i915/display/intel_backlight.c: In function 'scale':
> > include/linux/compiler_types.h:510:45: error: call to
> > '__compiletime_assert_905' declared with attribute error: clamp() low
> > limit source_min greater than high limit source_max
> > include/linux/minmax.h:107:9: note: in expansion of macro
> > 'BUILD_BUG_ON_MSG'
> >   107 |         BUILD_BUG_ON_MSG(statically_true(ulo > uhi),
> >                 \
> > drivers/gpu/drm/i915/display/intel_backlight.c:47:22: note: in
> > expansion of macro 'clamp'
> >    47 |         source_val = clamp(source_val, source_min, source_max);
> >
> > See https://pastebin.com/raw/yLJ5ZqVw for the x86-64 .config
> > that triggered this.
>
> The above seems to happen only with gcc-13 and gcc-14, but not gcc-12
> and earlier, and it's the only one I've seen with a bit of randconfig
> testing on that version.
>
> There is another one that I see with gcc-8 randconfigs (arm64):
>
> net/netfilter/ipvs/ip_vs_conn.c: In function 'ip_vs_conn_init':
> include/linux/compiler_types.h:510:38: error: call to '__compiletime_assert_1040' declared with attribute error: clamp() low limit min greater than high limit max_avail
>   510 |  _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
>       |                                      ^
> include/linux/minmax.h:182:28: note: in expansion of macro '__careful_clamp'
>   182 | #define clamp(val, lo, hi) __careful_clamp(val, lo, hi)
>       |                            ^~~~~~~~~~~~~~~
> net/netfilter/ipvs/ip_vs_conn.c:1498:8: note: in expansion of macro 'clamp'
>  1498 |  max = clamp(max, min, max_avail);
>
> I can reproduce this one with gcc-8/9/10, but not gcc-11
> or higher.
>
> This may be another case of __builtin_constant_p() being
> slightly unreliable when a local variable is constant-folded
> based on a condition, or with partial inlining.

Or perhaps the argument order is wrong, and it should be

    max = clamp(max_avail, min, max);

instead?

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@...ux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ