Commit 9ce6739
mm/slub: only zero requested size of buffer for kzalloc when debug enabled
kzalloc/kmalloc will round up the request size to a fixed size
(mostly power of 2), so the allocated memory could be more than
requested. Currently kzalloc family APIs will zero all the
allocated memory.
To detect out-of-bound usage of the extra allocated memory, only
zero the requested part, so that redzone sanity check could be
added to the extra space later.
For kzalloc users who will call ksize() later and utilize this
extra space, please be aware that the space is not zeroed any
more when debug is enabled. (Thanks to Kees Cook's effort to
sanitize all ksize() user cases [1], this won't be a big issue).
[1]. https://lore.kernel.org/all/[email protected]/#r
Signed-off-by: Feng Tang <[email protected]>
Acked-by: Hyeonggon Yoo <[email protected]>
Reviewed-by: Andrey Konovalov <[email protected]>
Signed-off-by: Vlastimil Babka <[email protected]>1 parent c18c20f commit 9ce6739
3 files changed
+27
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3254 | 3254 | | |
3255 | 3255 | | |
3256 | 3256 | | |
3257 | | - | |
| 3257 | + | |
| 3258 | + | |
3258 | 3259 | | |
3259 | 3260 | | |
3260 | 3261 | | |
| |||
3507 | 3508 | | |
3508 | 3509 | | |
3509 | 3510 | | |
3510 | | - | |
| 3511 | + | |
3511 | 3512 | | |
3512 | 3513 | | |
3513 | 3514 | | |
3514 | 3515 | | |
3515 | 3516 | | |
3516 | | - | |
| 3517 | + | |
3517 | 3518 | | |
3518 | 3519 | | |
3519 | 3520 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
720 | 720 | | |
721 | 721 | | |
722 | 722 | | |
723 | | - | |
| 723 | + | |
| 724 | + | |
724 | 725 | | |
| 726 | + | |
725 | 727 | | |
726 | 728 | | |
727 | 729 | | |
728 | 730 | | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
729 | 743 | | |
730 | 744 | | |
731 | 745 | | |
| |||
736 | 750 | | |
737 | 751 | | |
738 | 752 | | |
739 | | - | |
| 753 | + | |
740 | 754 | | |
741 | 755 | | |
742 | 756 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3395 | 3395 | | |
3396 | 3396 | | |
3397 | 3397 | | |
3398 | | - | |
| 3398 | + | |
| 3399 | + | |
| 3400 | + | |
| 3401 | + | |
| 3402 | + | |
3399 | 3403 | | |
3400 | 3404 | | |
3401 | 3405 | | |
| |||
3852 | 3856 | | |
3853 | 3857 | | |
3854 | 3858 | | |
3855 | | - | |
| 3859 | + | |
3856 | 3860 | | |
3857 | 3861 | | |
3858 | 3862 | | |
3859 | | - | |
| 3863 | + | |
3860 | 3864 | | |
3861 | 3865 | | |
3862 | 3866 | | |
| |||
0 commit comments