Ethical Hacking Learn to find vulnerabilities before the bad guys do! Gain real world hands on hacking experience in our state of the art hacking lab. Course designed and taught by expert instructors with years of penetration testing experience. 12 student maximum in every class. Certification attempt included in every package. | Computer Forensics Training at InfoSec Institute Gain the in-demand skills of a certified computer examiner, learn to recover trace data left behind by fraud, theft, and cybercrime perpetrators. Discover the source of computer crime and abuse at your organization so that it never happens again. All of our class sizes are guaranteed to be 12 students or less to facilitate one-on-one interaction with one of our expert instructors. |

| Subject: | [Full-Disclosure] Re: Linux Kernel sctp_setsockopt() Integer Overflow |
|---|---|
| Date: | Fri, 28 May 2004 12:25:28 -0600 |
Bringing up an old topic (discussed 15-May), because it seems noone replied to my post, which contains er.. wrong claims.
Shaun Colley wrote:
--- 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?
I was wrong reading the above code, simple as that. Sure, kmalloc(0) will NOT return NULL as I claimed.
if (size > csizep->cs_size)
continue;
Here, when size == 0 (and csizep->cs_size is always > 0),
the condition is always false, so the next instruction
will be executed, which is: return __kmem_cache_alloc(flags & GFP_DMA ?
csizep->cs_dmacachep : csizep->cs_cachep, flags);which will allocate either 32 or 64 bytes of memory (depending on the arch) and return it to the caller.
So there IS a bug, exactly as described in the original advisory.
I wonder why noone replied... ;)
/mjt
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | [Full-Disclosure] Re: Linux Kernel sctp_setsockopt() Integer Overflow, Michael Tokarev |
|---|---|
| Next by Date: | Re: [Full-Disclosure] Breaking Laws Cisco's stolen code, madsaxon |
| Previous by Thread: | [Full-Disclosure] Re: Linux Kernel sctp_setsockopt() Integer Overflow, Michael Tokarev |
| Next by Thread: | [Full-Disclosure] [ GLSA 200405-03 ] ClamAV VirusEvent parameter vulnerability, Thierry Carrez |
| Indexes: | [Date] [Thread] [Top] [All Lists] |