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: <20260111182010.GH3634291@ZenIV>
Date: Sun, 11 Jan 2026 18:20:10 +0000
From: Al Viro <viro@...iv.linux.org.uk>
To: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Eric Dumazet <edumazet@...gle.com>, oe-kbuild-all@...ts.linux.dev,
	linux-kernel@...r.kernel.org, Jakub Kicinski <kuba@...nel.org>,
	Maciej Żenczykowski <maze@...gle.com>,
	Will Deacon <will@...nel.org>,
	"Paul E. McKenney" <paulmck@...nel.org>,
	Peter Zijlstra <peterz@...radead.org>
Subject: Re: include/net/sock.h:2100:16: sparse: sparse: cast to non-scalar

On Sat, Jan 10, 2026 at 10:35:48PM +0000, Al Viro wrote:

> Folks involved in putting that cast in arch/alpha/include/asm/rwonce.h Cc'd...

FWIW, there's a way to strip qualifiers from *any* non-array type.
Look:

void f(void)
{
	const int x;
	x = 1;		// an error
	typeof(((typeof(x)(*)(void))0)()) y;
	y = 2;		// perfectly fine
}

The way it works is that qualifiers are stripped from return type when
deriving a function type.  That was spelled out only in C17; 6.7.6.3[5]
| If, in the declaration "T D1", D1 has the form
| D ( parameter-type-list )
|  or
| D ( identifier-list[opt] )
| and the type specified for ident in the declaration "T D" is
| "derived-declarator-type-list T", then the type specified for ident
| is "derived-declarator-type-list function returning the unqualified version
| of T".
but that "unqualified version of..." matched the common practice in
earlier variants of standard; they stopped issuing TCs by that point
(~2014), but both clang and gcc behave that way with any variant of
standard.

IOW, this

#define unqual_non_array(T) __typeof__(((T(*)(void))0)())

would do the right thing without that _Generic cascade and it'll work
just fine for e.g. kuid_t.  Using it for an array would trigger an error,
array-returning functions being forbidden...

Guys, do you have any problems with replacing __unqual_scalar_typeof()
uses with that thing?

As in,#ifndef __smp_load_acquire
#define __smp_load_acquire(p)                                           \
({                                                                      \
        unqual_non_array(__typeof__(*p)) ___p1 = READ_ONCE(*p);         \
...

Objections?  IMO it's more palatable than current __unqual_scalar_typeof()...

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ