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

Valdis.Kletnieks
2004-06-09T20:40:33Z

[-- Attachment #1: Type: text/plain, Size: 923 bytes --]

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 #2: Type: application/pgp-signature, Size: 226 bytes --]