Messages in this thread | | | Subject | Re: [PATCH] ALSA: Remove subsystem-specific malloc (1/8) | From | Valdis.Kletnieks@vt ... | Date | Wed, 09 Jun 2004 16:40:22 -0400 |
| |
On Wed, 09 Jun 2004 22:21:26 +0200, Arjan van de Ven said:
> > + */ > > +void *kcalloc(size_t n, size_t size, int flags) > > +{ > > + void *ret = kmalloc(n * size, flags); > > how about making sure n*size doesn't overflow an int in this function? > We had a few security holes due to that happening a while ago; might as > well prevent it from happening entirely
Do we want 'int', or is some other value (size_t? u32?) a better bet? (I see on some of the 64-bit boxes a compat_size_t for 32-bits as well, which hints at the problems here....
I'm worried that 'int' will Do The Wrong Thing when it runs into stuff like this from asm-i386/types.h:
/* DMA addresses come in generic and 64-bit flavours. */
#ifdef CONFIG_HIGHMEM64G typedef u64 dma_addr_t; #else typedef u32 dma_addr_t; #endif typedef u64 dma64_addr_t;
Are there any platforms where 'int' and 'max reasonable kmalloc size' have the same number of bits? [unhandled content-type:application/pgp-signature] | |