Commit a6687c8
slab: Mark large folios for debugging purposes
If a user calls p = kmalloc(1024); kfree(p); kfree(p); and 'p' was the
only object in the slab, we may free the slab after the first call to
kfree(). If we do, we clear PGTY_slab and the second call to kfree()
will call free_large_kmalloc(). That will leave a trace in the logs
("object pointer: 0x%p"), but otherwise proceed to free the memory,
which is likely to corrupt the page allocator's metadata.
Allocate a new page type for large kmalloc and mark the memory with it
while it's allocated. That lets us detect this double-free and return
without harming any data structures.
Reported-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Harry Yoo <harry.yoo@oracle.com>
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>1 parent 7e384db commit a6687c8
2 files changed
Lines changed: 17 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
925 | 925 | | |
926 | 926 | | |
927 | 927 | | |
928 | | - | |
929 | | - | |
930 | | - | |
931 | | - | |
932 | | - | |
933 | | - | |
934 | | - | |
935 | | - | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
936 | 937 | | |
937 | 938 | | |
938 | 939 | | |
| |||
1075 | 1076 | | |
1076 | 1077 | | |
1077 | 1078 | | |
| 1079 | + | |
1078 | 1080 | | |
1079 | 1081 | | |
1080 | 1082 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4255 | 4255 | | |
4256 | 4256 | | |
4257 | 4257 | | |
| 4258 | + | |
4258 | 4259 | | |
4259 | 4260 | | |
4260 | 4261 | | |
| |||
4730 | 4731 | | |
4731 | 4732 | | |
4732 | 4733 | | |
| 4734 | + | |
| 4735 | + | |
| 4736 | + | |
| 4737 | + | |
| 4738 | + | |
4733 | 4739 | | |
4734 | 4740 | | |
4735 | 4741 | | |
| |||
4739 | 4745 | | |
4740 | 4746 | | |
4741 | 4747 | | |
| 4748 | + | |
4742 | 4749 | | |
4743 | 4750 | | |
4744 | 4751 | | |
| |||
0 commit comments