fix error handling in mmap_region() and refactor (hotfixes)
Status from this message: [merged mm-hotfixes-stable] mm-resolve-faulty-mmap_region-error-path-behaviour.patch removed from -mm tree
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v4 Latest5 patches 12 repliesApplied 5/5
- v3 posting 2/25 patches 6 repliesSuperseded
- v3 posting 1/25 patches 4 repliesSuperseded 3 of 5 applied
Earlier versions · 2
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v2 | 8 patches | 34 replies | Superseded | |
| v1 | 8 patches | 37 replies | Superseded |
Changes in v4 from the cover letter
* Reworked solution to use arch_calc_vm_flag_bits() as suggested by Catalin. This also ensures we do not break MTE in a KVM scenario.
Patches in v4 All 5 applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/5 | mm: avoid unsafe VMA hook invocation when error arises on mmap hookmm/ mm/ mm/ | +32 | 0 replies | Applied |
| 2/5 | mm: unconditionally close VMAs on errormm/ mm/ mm/ +2 more | +27 | 0 replies | Applied |
| 3/5 | mm: refactor map_deny_write_exec()include/ mm/ mm/ +1 more | +21 | 0 replies | Applied |
| 4/5 | mm: refactor arch_calc_vm_flag_bits() and arm64 MTE handlingarch/ arch/ include/ +3 more | +16 | 12 replies | Applied |
| 5/5 | mm: resolve faulty mmap_region() error path behaviourmm/ | +65 | 0 replies | Applied |
Reviews trailers per patch
All 5 patches have a Reviewed-by or Acked-by.
| Patch | Liam R. Howlett | Vlastimil Babka | Jann Horn | Mark Brown | Catalin Marinas |
|---|---|---|---|---|---|
| 1/5 | R-b | R-b | R-b | ||
| 2/5 | R-b | R-b | R-b | ||
| 3/5 | R-b | R-b | R-b | ||
| 4/5 | R-b | R-b | |||
| 5/5 | R-b | R-b | T-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 5 reviewers.
Cover letter [PATCH hotfix 6.12 v4 0/5] fix error handling in mmap_region() and refactor (hotfixes)
NOTE: This should be applied on mm-hotfixes-unstable in Andrew's mm tree as
it relies on other pending hotfixes.
The mmap_region() function is somewhat terrifying, with spaghetti-like control flow and numerous means by which issues can arise and incomplete state, memory leaks and other unpleasantness can occur.
A large amount of the complexity arises from trying to handle errors late in the process of mapping a VMA, which forms the basis of recently observed issues with resource leaks and observable inconsistent state.
This series goes to great lengths to simplify how mmap_region() works and to avoid unwinding errors late on in the process of setting up the VMA for the new mapping, and equally avoids such operations occurring while the VMA is in an inconsistent state.
The patches in this series comprise the minimal changes required to resolve existing issues in mmap_region() error handling, in order that they can be hotfixed and backported. There is additionally a follow up series which goes further, separated out from the v1 series and sent and updated separately.
v4:
* Reworked solution to use arch_calc_vm_flag_bits() as suggested by Catalin. This also ensures we do not break MTE in a KVM scenario.
v3:
* Added correct handling for arm64 MTE which was otherwise broken, as reported by Mark Brown.
https://lore.kernel.org/all/[email protected]/
v2:
* Marked first 4 patches as hotfixes, the rest as not.
* Improved comment in vma_close() as per Vlastimil.
* Updated hole byte count as per Jann.
* Updated comment in map_deny_write_exec() as per Jann.
* Dropped unnecessary vma_iter_free() as per Vlastimil, Liam.
* Corrected vms_abort_munmap_vmas() mistaken assumption about nr_pages as per Vlastimil.
* Changed order of initial checks in mmap_region() to avoid user-visible side effects as per Vlastimil, Liam.
* Corrected silly incorrect use of vma field.
* Various style corrects as per Liam.
* Fix horrid mistake with merge VMA, reworked the logic to avoid that nonsense altogether.
* Add fields to map state rather than using vmg fields to avoid confusion/risk of vmg state changing breaking things.
* Replaced last commit removing merge retry with one that retries the merge, only sanely.
https://lore.kernel.org/all/[email protected]/
v1:
https://lore.kernel.org/all/[email protected]/
Lorenzo Stoakes (5):
mm: avoid unsafe VMA hook invocation when error arises on mmap hook
mm: unconditionally close VMAs on error
mm: refactor map_deny_write_exec()
mm: refactor arch_calc_vm_flag_bits() and arm64 MTE handling
mm: resolve faulty mmap_region() error path behaviour
arch/arm64/include/asm/mman.h | 10 ++- arch/parisc/include/asm/mman.h | 5 +- include/linux/mman.h | 28 +++++-- mm/internal.h | 45 ++++++++++++ mm/mmap.c | 130 ++++++++++++++++++--------------- mm/mprotect.c | 2 +- mm/nommu.c | 9 +-- mm/shmem.c | 3 - mm/vma.c | 14 ++-- mm/vma.h | 6 +- 10 files changed, 159 insertions(+), 93 deletions(-)
--
2.47.0