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] [day] [month] [year] [list]
Date:   Thu, 5 Dec 2019 02:08:19 +0000
From:   Al Viro <viro@...iv.linux.org.uk>
To:     Luc Van Oostenryck <luc.vanoostenryck@...il.com>
Cc:     Steven Rostedt <rostedt@...dmis.org>,
        Ingo Molnar <mingo@...hat.com>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] fix cast of gfp_t to ulong in __def_gfpflag_names

On Wed, Dec 04, 2019 at 06:54:25PM +0100, Luc Van Oostenryck wrote:
> The macro '__def_gfpflag_names' is used to define arrays of
> struct trace_print_flags. This structure is defined as being
> a pair of 'unsigned long' - 'const char *'.
> 
> However, the macro __def_gfpflag_names is used to for GFP flags
> and thus take entries of type gfp_t (plus their name) which
> is a bitwise type, non-convertible to usual integers.
> These entries are casted to 'unsigned long' but this doesn't
> prevent Sparse to rughtfully complain:
> 	warning: cast from restricted gfp_t
> 
> The correct way to cast a bitwise type to a normal integer
> (which is OK here) is to use '__force'.
> 
> So, fix the cast by adding the '__force' required for such casts.

Ugh...
> -	{(unsigned long)GFP_TRANSHUGE,		"GFP_TRANSHUGE"},	\
<plenty of such>
> +	{(__force ulong)GFP_TRANSHUGE,		"GFP_TRANSHUGE"},	\

# operator is there for purpose; as in
#define FOO(name) {(__force unsigned long)name, #name}
with those becoming
#define __def_gfpflag_names \
	FOO(GFP_TRANSHUGE), \
	FOO(GFP_TRANSHUGE_LIGHT), \
etc.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ