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: <871w163fuw.fsf@saeurebad.de>
Date:	Sun, 03 Aug 2008 06:03:03 +0200
From:	Johannes Weiner <hannes@...urebad.de>
To:	Yinghai Lu <yhlu.kernel@...il.com>
Cc:	Ingo Molnar <mingo@...e.hu>, Thomas Gleixner <tglx@...utronix.de>,
	"H. Peter Anvin" <hpa@...or.com>,
	"Eric W. Biederman" <ebiederm@...ssion.com>,
	Dhaval Giani <dhaval@...ux.vnet.ibm.com>,
	Mike Travis <travis@....com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH 03/25] add dyn_array support

Hi,

Yinghai Lu <yhlu.kernel@...il.com> writes:

> could have crazy big arrays and allocate them in bootmem at init stage.
> also also to allocate array according to size we need to use to avoid wasting
> memory
> use CONFIG_HAVE_DYN_ARRAY to enable it or not
>
> usage:
>
> |static struct irq_desc irq_desc_init __initdata = {
> |       .status = IRQ_DISABLED,
> |       .chip = &no_irq_chip,
> |       .handle_irq = handle_bad_irq,
> |       .depth = 1,
> |       .lock = __SPIN_LOCK_UNLOCKED(irq_desc->lock),
> |#ifdef CONFIG_SMP
> |       .affinity = CPU_MASK_ALL
> |#endif
> |};
> |
> |static void __init init_work(void *data)
> |{
> |       struct dyn_array *da = data;
> |       struct  irq_desc *desc;
> |       int i;
> |
> |       desc = *da->name;

Where *da->name might be NULL...

> |
> |       for (i = 0; i < *da->nr; i++)
> |               memcpy(&desc[i], &irq_desc_init, sizeof(struct irq_desc));

... boom.

> +void pre_alloc_dyn_array(void)
> +{
> +#ifdef CONFIG_HAVE_DYN_ARRAY
> +	unsigned long size, phys = 0;
> +	struct dyn_array **daa;
> +
> +	for (daa = __dyn_array_start ; daa < __dyn_array_end; daa++) {
> +		struct dyn_array *da = *daa;
> +
> +		size = da->size * (*da->nr);
> +		print_fn_descriptor_symbol("dyna_array %s ", da->name);
> +		printk(KERN_CONT "size:%#lx nr:%d align:%#lx",
> +			da->size, *da->nr, da->align);
> +		*da->name = __alloc_bootmem_nopanic(size, da->align, phys);

So, why is this _nopanic()?

> +		phys = virt_to_phys(*da->name);
> +		printk(KERN_CONT " ==> [%#lx - %#lx]\n", phys, phys + size);
> +
> +		if (da->init_work)
> +			da->init_work(da);
> +	}
> +#endif

	Hannes
--
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