Re: [PATCH] ALSA: Remove subsystem-specific malloc (1/8)

From: Valdis . Kletnieks
Date: Wed Jun 09 2004 - 15:41:53 EST


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?

Attachment: pgp00000.pgp
Description: PGP signature