BugTraq
Linux Kernel sctp_setsockopt() Integer Overflow May 11 2004 06:58PM
Shaun Colley (shaunige yahoo co uk) (2 replies)
Re: Linux Kernel sctp_setsockopt() Integer Overflow May 15 2004 06:24PM
Michael Tokarev (mjt tls msk ru) (1 replies)
Shaun Colley wrote:
[]
> Below is the vulnerable call:
>
> ---
> if (NULL == (tmp = kmalloc(optlen + 1, GFP_KERNEL))) {
> retval = -ENOMEM;
> goto out_unlock;
> }
> ---
>
> Because kmalloc() takes the 'count' variable as an
> unsigned number, negative numbers are interpreted as
> large unsigned numbers. However, if -1 is passed as
> 'optlen' (represented as 0xffffffff (hex) in unsigned
> variables, which is the largest value an unsigned
....
[]
> And thus, due to the integer overflow, 0 is passed to
> kmalloc(), causing too little memory to be allocated
> to hold 'optval'.

But kmalloc(0) will return NULL, and the whole setsockopt
will finish with errno set to ENOMEM.

From 2.4 mm/slab.c:

void * kmalloc (size_t size, int flags)
{
cache_sizes_t *csizep = cache_sizes;

for (; csizep->cs_size; csizep++) {
if (size > csizep->cs_size)
continue;
return __kmem_cache_alloc(flags & GFP_DMA ?
csizep->cs_dmacachep : csizep->cs_cachep, flags);
}
return NULL;
}

So, where's the bug?

/mjt

[ reply ]
Re: Linux Kernel sctp_setsockopt() Integer Overflow May 27 2004 07:47PM
Michael Tokarev (mjt tls msk ru) (1 replies)
Re: Linux Kernel sctp_setsockopt() Integer Overflow May 29 2004 03:13AM
Jirka Kosina (jikos jikos cz) (1 replies)
Re: Linux Kernel sctp_setsockopt() Integer Overflow May 31 2004 05:35PM
Shaun Colley (shaunige yahoo co uk)
Re: [Full-Disclosure] Linux Kernel sctp_setsockopt() Integer Overflow May 11 2004 10:05PM
Tom Rini (trini kernel crashing org)


 

Privacy Statement
Copyright 2010, SecurityFocus