]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commit
mm: always expand the stack with the mmap write lock held
authorLinus Torvalds <torvalds@linux-foundation.org>
Wed, 5 Jul 2023 12:34:24 +0000 (09:34 -0300)
committerLuke Nowakowski-Krijger <luke.nowakowskikrijger@canonical.com>
Thu, 6 Jul 2023 20:20:10 +0000 (13:20 -0700)
commitdcaa9dbc2bdc497c75fdf17a87591eee68af25a9
treec6d2ed1a3777048dae129f16fd55a4d33d8b0c88
parentae5159e39f1187cbccb0340ccd41574e661bcb1a
mm: always expand the stack with the mmap write lock held

This finishes the job of always holding the mmap write lock when
extending the user stack vma, and removes the 'write_locked' argument
from the vm helper functions again.

For some cases, we just avoid expanding the stack at all: drivers and
page pinning really shouldn't be extending any stacks.  Let's see if any
strange users really wanted that.

It's worth noting that architectures that weren't converted to the new
lock_mm_and_find_vma() helper function are left using the legacy
"expand_stack()" function, but it has been changed to drop the mmap_lock
and take it for writing while expanding the vma.  This makes it fairly
straightforward to convert the remaining architectures.

As a result of dropping and re-taking the lock, the calling conventions
for this function have also changed, since the old vma may no longer be
valid.  So it will now return the new vma if successful, and NULL - and
the lock dropped - if the area could not be extended.

Tested-by: Vegard Nossum <vegard.nossum@oracle.com>
Tested-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de> # ia64
Tested-by: Frank Scheiner <frank.scheiner@web.de> # ia64
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
(cherry picked from commit 8d7071af890768438c14db6172cc8f9f4d04e184)
CVE-2023-3269
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
Acked-by: Cengiz Can <cengiz.can@canonical.com>
Acked-by: Tim Gardner <tim.gardner@canonical.com>
Signed-off-by: Luke Nowakowski-Krijger <luke.nowakowskikrijger@canonical.com>
17 files changed:
arch/ia64/mm/fault.c
arch/m68k/mm/fault.c
arch/microblaze/mm/fault.c
arch/openrisc/mm/fault.c
arch/parisc/mm/fault.c
arch/s390/mm/fault.c
arch/sparc/mm/fault_64.c
arch/um/kernel/trap.c
drivers/iommu/amd/iommu_v2.c
drivers/iommu/iommu-sva.c
fs/binfmt_elf.c
fs/exec.c
include/linux/mm.h
mm/gup.c
mm/memory.c
mm/mmap.c
mm/nommu.c