mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
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>
This commit is contained in:
parent
f313c51d26
commit
8d7071af89
17 changed files with 169 additions and 116 deletions
|
@ -105,8 +105,9 @@ retry:
|
|||
if (address + 256 < rdusp())
|
||||
goto map_err;
|
||||
}
|
||||
if (expand_stack(vma, address))
|
||||
goto map_err;
|
||||
vma = expand_stack(mm, address);
|
||||
if (!vma)
|
||||
goto map_err_nosemaphore;
|
||||
|
||||
/*
|
||||
* Ok, we have a good vm_area for this memory access, so
|
||||
|
@ -196,10 +197,12 @@ bus_err:
|
|||
goto send_sig;
|
||||
|
||||
map_err:
|
||||
mmap_read_unlock(mm);
|
||||
map_err_nosemaphore:
|
||||
current->thread.signo = SIGSEGV;
|
||||
current->thread.code = SEGV_MAPERR;
|
||||
current->thread.faddr = address;
|
||||
goto send_sig;
|
||||
return send_fault_sig(regs);
|
||||
|
||||
acc_err:
|
||||
current->thread.signo = SIGSEGV;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue