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: <20200619095105.GA222848@elver.google.com>
Date:   Fri, 19 Jun 2020 11:51:05 +0200
From:   Marco Elver <elver@...gle.com>
To:     Luc Van Oostenryck <luc.vanoostenryck@...il.com>
Cc:     Linus Torvalds <torvalds@...ux-foundation.org>,
        linux-kernel@...r.kernel.org, Borislav Petkov <bp@...e.de>,
        Will Deacon <will@...nel.org>
Subject: Re: [PATCH] sparse: use the _Generic() version of
 __unqual_scalar_typeof()

On Fri, Jun 19, 2020 at 12:26AM +0200, Luc Van Oostenryck wrote:
> If the file is being checked with sparse, use the version of
> __unqual_scalar_typeof() using _Generic(), leaving the unoptimized
> version only for the oldest versions of GCC.
> 
> This reverts commit
>   b398ace5d2ea ("compiler_types.h: Use unoptimized __unqual_scalar_typeof for sparse")
> 
> Note: a recent version of sparse will be needed (minimum v0.6.2-rc2
>        or later than 2020-05-28).
> 
> Cc: Marco Elver <elver@...gle.com>
> Cc: Borislav Petkov <bp@...e.de>
> Cc: Will Deacon <will@...nel.org>
> Link: https://marc.info/?l=linux-sparse&m=159233481816454
> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@...il.com>

Definitely support this change, so in principle:

	Acked-by: Marco Elver <elver@...gle.com>

But, I think sparse still isn't entirely happy with all legal uses of
_Generic. Running latest sparse on:

	void test_Generic_conversion(void)
	{
	#define TEST_WITH_QUALIFIER(type, selection_type)			\
		do {								\
			type var = 0;						\
			_Generic(var, selection_type: (void (*)(type))0)(var);	\
		} while (0)
		/* Expect no errors. */
		TEST_WITH_QUALIFIER(const int, int);
		TEST_WITH_QUALIFIER(volatile int, int);
		TEST_WITH_QUALIFIER(_Atomic int, int);
		TEST_WITH_QUALIFIER(register int, int);
	}

results in

	generic-test.c:9:9: error: no generic selection for 'int const var'
	generic-test.c:10:9: error: no generic selection for 'int volatile var'
	generic-test.c:11:9: error: no generic selection for 'int [atomic] var'

Whereas GCC or Clang accept this as expected. I can't find the
standardese right now, but in [1] we have:

	"[...] The conversion is performed in type domain only: it
	discards the top-level cvr-qualifiers and atomicity and applies
	array-to-pointer/function-to-pointer transformations to the type
	of the controlling expression [...]"

[1] https://en.cppreference.com/w/c/language/generic

Thanks,
-- Marco

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ