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]
Date:	Tue, 12 May 2009 22:31:42 -0400
From:	Jeff Garzik <jeff@...zik.org>
To:	Rusty Russell <rusty@...tcorp.com.au>
CC:	Al Viro <viro@...iv.linux.org.uk>, Ingo Molnar <mingo@...e.hu>,
	Peter Zijlstra <a.p.zijlstra@...llo.nl>,
	Mike Travis <travis@....com>,
	LKML <linux-kernel@...r.kernel.org>,
	Andrew Morton <akpm@...ux-foundation.org>, roland@...hat.com
Subject: Re: [RFC PATCH 2/2] kernel/sched.c: VLA in middle of struct

Rusty Russell wrote:
> sched: avoid flexible array member inside struct (gcc extension)
> 
> struct sched_group and struct sched_domain end in 'unsigned long
> cpumask[]' which Jeff Garzik notes is not legal to place inside
> another struct.  It upsets sparse and clang (LLVM's C front end).
> 
> Al Viro pointed out that a union is the Right Way to do this.
> 
> Signed-off-by: Rusty Russell <rusty@...tcorp.com.au>
> Reported-by: Jeff Garzik <jeff@...zik.org>
> Cc: Al Viro <viro@...iv.linux.org.uk>
> ---
>  kernel/sched.c |   32 +++++++++++++++++---------------
>  1 file changed, 17 insertions(+), 15 deletions(-)
> 
> diff --git a/kernel/sched.c b/kernel/sched.c
> --- a/kernel/sched.c
> +++ b/kernel/sched.c
> @@ -7756,22 +7756,24 @@ int sched_smt_power_savings = 0, sched_m
>   * FIXME: use cpumask_var_t or dynamic percpu alloc to avoid wasting space
>   * for nr_cpu_ids < CONFIG_NR_CPUS.
>   */
> -struct static_sched_group {
> +union static_sched_group {
>  	struct sched_group sg;
> -	DECLARE_BITMAP(cpus, CONFIG_NR_CPUS);
> -};
> -
> -struct static_sched_domain {
> +	char _sg_and_cpus[sizeof(struct sched_group) +
> +			  BITS_TO_LONGS(CONFIG_NR_CPUS) * sizeof(long)];
> +};
> +
> +union static_sched_domain {
>  	struct sched_domain sd;
> -	DECLARE_BITMAP(span, CONFIG_NR_CPUS);
> +	char _sd_and_cpus[sizeof(struct sched_domain) +
> +			  BITS_TO_LONGS(CONFIG_NR_CPUS) * sizeof(long)];
>  };

Looks good to me...  thanks!

	Jeff



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ