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

Configure Feed

Select the types of activity you want to include in your feed.

SLOB: fix bogus ksize calculation fix

This fixes the previous fix, which was completely wrong on closer
inspection. This version has been manually tested with a user-space
test harness and generates sane values. A nearly identical patch has
been boot-tested.

The problem arose from changing how kmalloc/kfree handled alignment
padding without updating ksize to match. This brings it in sync.

Signed-off-by: Matt Mackall <mpm@selenic.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Matt Mackall and committed by
Linus Torvalds
70096a56 69849375

+5 -3
+5 -3
mm/slob.c
··· 514 514 return 0; 515 515 516 516 sp = (struct slob_page *)virt_to_page(block); 517 - if (slob_page(sp)) 518 - return (((slob_t *)block - 1)->units - 1) * SLOB_UNIT; 519 - else 517 + if (slob_page(sp)) { 518 + int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN); 519 + unsigned int *m = (unsigned int *)(block - align); 520 + return SLOB_UNITS(*m) * SLOB_UNIT; 521 + } else 520 522 return sp->page.private; 521 523 } 522 524