Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

SLOB: fix bogus ksize calculation

SLOB's ksize calculation was braindamaged and generally harmlessly
underreported the allocation size. But for very small buffers, it could
in fact overreport them, leading code depending on krealloc to overrun
the allocation and trample other data.

Signed-off-by: Matt Mackall <mpm@selenic.com>
Tested-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Matt Mackall and committed by
Linus Torvalds
85ba94ba e09e6e2b

+1 -1
+1 -1
mm/slob.c
··· 515 515 516 516 sp = (struct slob_page *)virt_to_page(block); 517 517 if (slob_page(sp)) 518 - return ((slob_t *)block - 1)->units + SLOB_UNIT; 518 + return (((slob_t *)block - 1)->units - 1) * SLOB_UNIT; 519 519 else 520 520 return sp->page.private; 521 521 }