Skip to content

Commit eee9c70

Browse files
committed
gup: avoid stack expansion warning for known-good case
In commit a425ac5 ("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>
1 parent 1b72240 commit eee9c70

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

mm/memory.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5694,6 +5694,10 @@ int __access_remote_vm(struct mm_struct *mm, unsigned long addr, void *buf,
56945694
if (mmap_read_lock_killable(mm))
56955695
return 0;
56965696

5697+
/* Avoid triggering the temporary warning in __get_user_pages */
5698+
if (!vma_lookup(mm, addr) && !expand_stack(mm, addr))
5699+
return 0;
5700+
56975701
/* ignore errors, just check how much was successfully transferred */
56985702
while (len) {
56995703
int bytes, offset;

0 commit comments

Comments
 (0)