Commit fba46a5
maple_tree: fix MA_STATE_PREALLOC flag in mas_preallocate()
Temporarily clear the preallocation flag when explicitly requesting
allocations. Pre-existing allocations are already counted against the
request through mas_node_count_gfp(), but the allocations will not happen
if the MA_STATE_PREALLOC flag is set. This flag is meant to avoid
re-allocating in bulk allocation mode, and to detect issues with
preallocation calculations.
The MA_STATE_PREALLOC flag should also always be set on zero allocations
so that detection of underflow allocations will print a WARN_ON() during
consumption.
User visible effect of this flaw is a WARN_ON() followed by a null pointer
dereference when subsequent requests for larger number of nodes is
ignored, such as the vma merge retry in mmap_region() caused by drivers
altering the vma flags (which happens in v6.6, at least)
Link: https://lkml.kernel.org/r/[email protected]
Fixes: 54a611b ("Maple Tree: add new data structure")
Signed-off-by: Liam R. Howlett <[email protected]>
Reported-by: Zhaoyang Huang <[email protected]>
Reported-by: Hailong Liu <[email protected]>
Link: https://lore.kernel.org/all/[email protected]/
Link: https://lore.kernel.org/all/[email protected]/
Link: https://lore.kernel.org/all/[email protected]/
Cc: Lorenzo Stoakes <[email protected]>
Cc: Suren Baghdasaryan <[email protected]>
Cc: Hailong Liu <[email protected]>
Cc: [email protected] <[email protected]>
Cc: Steve Kang <[email protected]>
Cc: Matthew Wilcox <[email protected]>
Cc: Sidhartha Kumar <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>1 parent 40ffd28 commit fba46a5
1 file changed
+3
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5527 | 5527 | | |
5528 | 5528 | | |
5529 | 5529 | | |
5530 | | - | |
| 5530 | + | |
5531 | 5531 | | |
| 5532 | + | |
5532 | 5533 | | |
5533 | 5534 | | |
5534 | 5535 | | |
| |||
5538 | 5539 | | |
5539 | 5540 | | |
5540 | 5541 | | |
| 5542 | + | |
5541 | 5543 | | |
5542 | 5544 | | |
5543 | 5545 | | |
| |||
0 commit comments