aboutsummaryrefslogtreecommitdiffstats
path: root/mm/memory.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2023-06-29 12:36:47 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2023-06-29 12:36:47 -0700
commiteee9c708cc89b4600c6e6cdda5bc2b8b4dad96cb (patch)
treee6477cf99485c81a457f66b89ae2f49f6343e7d0 /mm/memory.c
parent1b722407a13b7f8658d2e26917791f32805980a2 (diff)
downloadlinux-eee9c708cc89b4600c6e6cdda5bc2b8b4dad96cb.tar.gz
gup: avoid stack expansion warning for known-good case
In commit a425ac5365f6 ("gup: add warning if some caller would seem to want stack expansion") I added a temporary warning to catch any strange GUP users that would be impacted by the fact that GUP no longer extends the stack. But it turns out that the warning is most easily triggered through __access_remote_vm(), that already knows to expand the stack - it just does it *after* calling GUP. So the warning is easy to trigger by just running gdb (or similar) and accessing things remotely under the stack. This just adds a temporary extra "expand stack early" to avoid the warning for the already converted case - not because the warning is bad, but because getting the warning for this known good case would then hide any subsequent warnings for any actually interesting cases. Let's try to remember to revert this change when we remove the warnings. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/memory.c')
-rw-r--r--mm/memory.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/mm/memory.c b/mm/memory.c
index d8a9a770b1f164..0ae59470302111 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -5694,6 +5694,10 @@ int __access_remote_vm(struct mm_struct *mm, unsigned long addr, void *buf,
if (mmap_read_lock_killable(mm))
return 0;
+ /* Avoid triggering the temporary warning in __get_user_pages */
+ if (!vma_lookup(mm, addr) && !expand_stack(mm, addr))
+ return 0;
+
/* ignore errors, just check how much was successfully transferred */
while (len) {
int bytes, offset;