[syzbot] [mm?] WARNING in try_grab_page

12 views
Skip to first unread message

syzbot

unread,
Jul 3, 2023, 12:34:57ā€ÆPM7/3/23
to ak...@linux-foundation.org, linux-...@vger.kernel.org, linu...@kvack.org, syzkall...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 3a8a670eeeaa Merge tag 'net-next-6.5' of git://git.kernel...
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=12c1d408a80000
kernel config: https://syzkaller.appspot.com/x/.config?x=ce7f4ca96cdf82c7
dashboard link: https://syzkaller.appspot.com/bug?extid=9b82859567f2e50c123e
compiler: aarch64-linux-gnu-gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
userspace arch: arm64

Unfortunately, I don't have any reproducer for this issue yet.

Downloadable assets:
disk image (non-bootable): https://storage.googleapis.com/syzbot-assets/384ffdcca292/non_bootable_disk-3a8a670e.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/a940531a9b86/vmlinux-3a8a670e.xz
kernel image: https://storage.googleapis.com/syzbot-assets/4f3cbae5be61/Image-3a8a670e.gz.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+9b8285...@syzkaller.appspotmail.com

------------[ cut here ]------------
WARNING: CPU: 1 PID: 20384 at mm/gup.c:229 __lse_atomic_add arch/arm64/include/asm/atomic_lse.h:27 [inline]
WARNING: CPU: 1 PID: 20384 at mm/gup.c:229 arch_atomic_add arch/arm64/include/asm/atomic.h:28 [inline]
WARNING: CPU: 1 PID: 20384 at mm/gup.c:229 raw_atomic_add include/linux/atomic/atomic-arch-fallback.h:537 [inline]
WARNING: CPU: 1 PID: 20384 at mm/gup.c:229 atomic_add include/linux/atomic/atomic-instrumented.h:105 [inline]
WARNING: CPU: 1 PID: 20384 at mm/gup.c:229 try_grab_page+0x108/0x160 mm/gup.c:252
Modules linked in:
CPU: 1 PID: 20384 Comm: syz-executor.1 Not tainted 6.4.0-syzkaller-04247-g3a8a670eeeaa #0
Hardware name: linux,dummy-virt (DT)
pstate: a0400009 (NzCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
pc : try_grab_page+0x108/0x160 mm/gup.c:229
lr : follow_page_pte+0x174/0x3e4 mm/gup.c:651
sp : ffff800089bbb5e0
x29: ffff800089bbb5e0 x28: 0000000000200000 x27: ffff000004d23800
x26: 0120000042835fc3 x25: 0000000000000000 x24: 0000000000080000
x23: ffff800089bbb738 x22: fffffc00000a0d40 x21: ffff00001e541008
x20: fcff00001e5a7b40 x19: 0000000000290000 x18: 0000000000000000
x17: 0000000000000000 x16: ffff800081ccc7c0 x15: 0000ffff8b6e9fff
x14: 0000000000000000 x13: 1edfe00003cc9f01 x12: ffff800089bbb628
x11: f6ff00001e64f800 x10: f6ff00001e64f80c x9 : f6ff00001e64f808
x8 : 0000000020001000 x7 : 0000000020000000 x6 : 0000000000000000
x5 : 0000000000042835 x4 : 0000000020001000 x3 : fffffc00000a0d40
x2 : fffffc00000a0d40 x1 : 0000000000290000 x0 : 00000000fffffff3
Call trace:
__lse_atomic_add arch/arm64/include/asm/atomic_lse.h:27 [inline]
arch_atomic_add arch/arm64/include/asm/atomic.h:28 [inline]
raw_atomic_add include/linux/atomic/atomic-arch-fallback.h:537 [inline]
atomic_add include/linux/atomic/atomic-instrumented.h:105 [inline]
try_grab_page+0x108/0x160 mm/gup.c:252
follow_pmd_mask mm/gup.c:734 [inline]
follow_pud_mask mm/gup.c:765 [inline]
follow_p4d_mask mm/gup.c:782 [inline]
follow_page_mask+0x12c/0x2e4 mm/gup.c:839
__get_user_pages+0x174/0x30c mm/gup.c:1217
__get_user_pages_locked mm/gup.c:1448 [inline]
__gup_longterm_locked+0x94/0x8f4 mm/gup.c:2142
internal_get_user_pages_fast+0x970/0xb60 mm/gup.c:3140
pin_user_pages_fast+0x4c/0x60 mm/gup.c:3246
iov_iter_extract_user_pages lib/iov_iter.c:1768 [inline]
iov_iter_extract_pages+0xc8/0x54c lib/iov_iter.c:1831
extract_user_to_sg lib/scatterlist.c:1123 [inline]
extract_iter_to_sg lib/scatterlist.c:1349 [inline]
extract_iter_to_sg+0x26c/0x6fc lib/scatterlist.c:1339
hash_sendmsg+0xc0/0x43c crypto/algif_hash.c:117
sock_sendmsg_nosec net/socket.c:725 [inline]
sock_sendmsg+0x54/0x60 net/socket.c:748
____sys_sendmsg+0x270/0x2ac net/socket.c:2494
___sys_sendmsg+0x80/0xdc net/socket.c:2548
__sys_sendmsg+0x68/0xc4 net/socket.c:2577
__do_sys_sendmsg net/socket.c:2586 [inline]
__se_sys_sendmsg net/socket.c:2584 [inline]
__arm64_sys_sendmsg+0x24/0x30 net/socket.c:2584
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x48/0x114 arch/arm64/kernel/syscall.c:52
el0_svc_common.constprop.0+0x44/0xe4 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x38/0xa4 arch/arm64/kernel/syscall.c:191
el0_svc+0x2c/0xb0 arch/arm64/kernel/entry-common.c:647
el0t_64_sync_handler+0xc0/0xc4 arch/arm64/kernel/entry-common.c:665
el0t_64_sync+0x19c/0x1a0 arch/arm64/kernel/entry.S:591
---[ end trace 0000000000000000 ]---


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzk...@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

If the bug is already fixed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want to change bug's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the bug is a duplicate of another bug, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup

Sven Schnelle

unread,
Jul 25, 2023, 4:41:42ā€ÆAM7/25/23
to syzbot, ak...@linux-foundation.org, linux-...@vger.kernel.org, linu...@kvack.org, syzkall...@googlegroups.com, Herbert Xu, David S. Miller, David Howells, linux-...@vger.kernel.org
syzbot <syzbot+9b8285...@syzkaller.appspotmail.com> writes:

> [..]
> ------------[ cut here ]------------
> WARNING: CPU: 1 PID: 20384 at mm/gup.c:229 __lse_atomic_add arch/arm64/include/asm/atomic_lse.h:27 [inline]
> WARNING: CPU: 1 PID: 20384 at mm/gup.c:229 arch_atomic_add arch/arm64/include/asm/atomic.h:28 [inline]
> WARNING: CPU: 1 PID: 20384 at mm/gup.c:229 raw_atomic_add include/linux/atomic/atomic-arch-fallback.h:537 [inline]
> WARNING: CPU: 1 PID: 20384 at mm/gup.c:229 atomic_add include/linux/atomic/atomic-instrumented.h:105 [inline]
> WARNING: CPU: 1 PID: 20384 at mm/gup.c:229 try_grab_page+0x108/0x160 mm/gup.c:252
> Modules linked in:
> CPU: 1 PID: 20384 Comm: syz-executor.1 Not tainted 6.4.0-syzkaller-04247-g3a8a670eeeaa #0
> Hardware name: linux,dummy-virt (DT)
> pstate: a0400009 (NzCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
> pc : try_grab_page+0x108/0x160 mm/gup.c:229
> lr : follow_page_pte+0x174/0x3e4 mm/gup.c:651
> [..]
I looked into this issue. What syzkaller is doing is opening an AF_ALG
socket, and sending a large message which will eventually end in -EFAULT.
Looking at the code in crypto/algif_hash.c i see that hash_sendmsg is
calling extract_iter_to_sg() -> extract_user_to_sg(). In the -EFAULT
case, this function is calling put_page(), which looks like a leftover
from the old pinning interface. I think this should be a
unpin_user_page() call now.

However, hash_sendmsg() also unpins via af_alg_free_sg() in the error
path. From an API perspective, i would prefer if extract_user_to_sg()
does the unpinning on error. Any thoughts?

David Howells

unread,
Jul 25, 2023, 5:28:41ā€ÆAM7/25/23
to Sven Schnelle, dhow...@redhat.com, syzbot, ak...@linux-foundation.org, linux-...@vger.kernel.org, linu...@kvack.org, syzkall...@googlegroups.com, Herbert Xu, David S. Miller, linux-...@vger.kernel.org
Sven Schnelle <sv...@linux.ibm.com> wrote:

>
> I looked into this issue. What syzkaller is doing is opening an AF_ALG
> socket, and sending a large message which will eventually end in -EFAULT.
> Looking at the code in crypto/algif_hash.c i see that hash_sendmsg is
> calling extract_iter_to_sg() -> extract_user_to_sg(). In the -EFAULT
> case, this function is calling put_page(), which looks like a leftover
> from the old pinning interface. I think this should be a
> unpin_user_page() call now.
>
> However, hash_sendmsg() also unpins via af_alg_free_sg() in the error
> path. From an API perspective, i would prefer if extract_user_to_sg()
> does the unpinning on error. Any thoughts?

Good catch, thanks. I'll whip up a patch or two for it.

David

David Howells

unread,
Jul 26, 2023, 4:25:31ā€ÆAM7/26/23
to Sven Schnelle, dhow...@redhat.com, syzbot, ak...@linux-foundation.org, linux-...@vger.kernel.org, linu...@kvack.org, syzkall...@googlegroups.com, Herbert Xu, David S. Miller, linux-...@vger.kernel.org
Sven Schnelle <sv...@linux.ibm.com> wrote:

> However, hash_sendmsg() also unpins via af_alg_free_sg() in the error
> path. From an API perspective, i would prefer if extract_user_to_sg()
> does the unpinning on error. Any thoughts?

In the event of an error, extract_user_to_sg() unpins only the pages it added
to the scatterlist; it doesn't unpin any pages that were already there and
doesn't free the scatterlist; it also decrements sgtable->nents so that the
caller doesn't see the pages it attempted to add, so calling af_alg_free_sg()
shouldn't hurt.

Note that the error path also frees the result, so we do need to do at least
part of it.

David

David Howells

unread,
Jul 26, 2023, 4:31:36ā€ÆAM7/26/23
to syzbot, dhow...@redhat.com, Sven Schnelle, ak...@linux-foundation.org, linux-...@vger.kernel.org, linu...@kvack.org, syzkall...@googlegroups.com, Herbert Xu, David S. Miller, linux-...@vger.kernel.org
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master

lib/scatterlist: Fix error handling in extract_iter_to_sg()

Fix the error handling in extract_iter_to_sg(). Pages need to be unpinned,
not put, and only if they actually got pinned (which is the case in
extract_user_to_sg()).

The bug may result in a warning like the following:

WARNING: CPU: 1 PID: 20384 at mm/gup.c:229 __lse_atomic_add arch/arm64/include/asm/atomic_lse.h:27 [inline]
WARNING: CPU: 1 PID: 20384 at mm/gup.c:229 arch_atomic_add arch/arm64/include/asm/atomic.h:28 [inline]
WARNING: CPU: 1 PID: 20384 at mm/gup.c:229 raw_atomic_add include/linux/atomic/atomic-arch-fallback.h:537 [inline]
WARNING: CPU: 1 PID: 20384 at mm/gup.c:229 atomic_add include/linux/atomic/atomic-instrumented.h:105 [inline]
WARNING: CPU: 1 PID: 20384 at mm/gup.c:229 try_grab_page+0x108/0x160 mm/gup.c:252
...
pc : try_grab_page+0x108/0x160 mm/gup.c:229
lr : follow_page_pte+0x174/0x3e4 mm/gup.c:651
...
Fixes: 018584697533 ("netfs: Add a function to extract an iterator into a scatterlist")
Reported-by: syzbot+9b8285...@syzkaller.appspotmail.com
Link: https://lore.kernel.org/linux-mm/00000000000027...@google.com/
Signed-off-by: David Howells <dhow...@redhat.com>
cc: Sven Schnelle <sv...@linux.ibm.com>
cc: ak...@linux-foundation.org
cc: Herbert Xu <her...@gondor.apana.org.au>
cc: "David S. Miller" <da...@davemloft.net>
cc: Jeff Layton <jla...@kernel.org>
cc: Steve French <sfr...@samba.org>
cc: Shyam Prasad N <nspman...@gmail.com>
cc: Rohith Surabattula <rohith...@gmail.com>
cc: Jens Axboe <ax...@kernel.dk>
cc: Herbert Xu <her...@gondor.apana.org.au>
cc: "David S. Miller" <da...@davemloft.net>
cc: Eric Dumazet <edum...@google.com>
cc: Jakub Kicinski <ku...@kernel.org>
cc: Paolo Abeni <pab...@redhat.com>
cc: Matthew Wilcox <wi...@infradead.org>
cc: linu...@kvack.org
cc: linux-...@vger.kernel.org
cc: linux-...@redhat.com
cc: linux...@vger.kernel.org
cc: linux-...@vger.kernel.org
cc: net...@vger.kernel.org
---
lib/scatterlist.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/scatterlist.c b/lib/scatterlist.c
index e86231a44c3d..c65566b4dc66 100644
--- a/lib/scatterlist.c
+++ b/lib/scatterlist.c
@@ -1148,7 +1148,7 @@ static ssize_t extract_user_to_sg(struct iov_iter *iter,

failed:
while (sgtable->nents > sgtable->orig_nents)
- put_page(sg_page(&sgtable->sgl[--sgtable->nents]));
+ unpin_user_page(sg_page(&sgtable->sgl[--sgtable->nents]));
return res;
}

syzbot

unread,
Jul 26, 2023, 4:31:39ā€ÆAM7/26/23
to dhow...@redhat.com, ak...@linux-foundation.org, da...@davemloft.net, dhow...@redhat.com, her...@gondor.apana.org.au, linux-...@vger.kernel.org, linux-...@vger.kernel.org, linu...@kvack.org, sv...@linux.ibm.com, syzkall...@googlegroups.com
This crash does not have a reproducer. I cannot test it.

syzbot

unread,
Sep 5, 2023, 1:36:05ā€ÆPM9/5/23
to ak...@linux-foundation.org, ax...@kernel.dk, da...@davemloft.net, da...@redhat.com, dhow...@redhat.com, edum...@google.com, gre...@linuxfoundation.org, her...@gondor.apana.org.au, jla...@kernel.org, ku...@kernel.org, linux-...@vger.kernel.org, linux-...@vger.kernel.org, linu...@kvack.org, nspman...@gmail.com, pab...@redhat.com, pat...@lists.linux.dev, rohith...@gmail.com, sas...@kernel.org, sta...@vger.kernel.org, stfr...@microsoft.com, sv...@linux.ibm.com, syzkall...@googlegroups.com, wi...@infradead.org
syzbot has found a reproducer for the following issue on:

HEAD commit: 3f86ed6ec0b3 Merge tag 'arc-6.6-rc1' of git://git.kernel.o..
git tree: upstream
console+strace: https://syzkaller.appspot.com/x/log.txt?x=139ce690680000
kernel config: https://syzkaller.appspot.com/x/.config?x=ff0db7a15ba54ead
dashboard link: https://syzkaller.appspot.com/bug?extid=9b82859567f2e50c123e
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=10b0c620680000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=152da4e7a80000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/6f4f710c5033/disk-3f86ed6e.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/555548fedbdc/vmlinux-3f86ed6e.xz
kernel image: https://storage.googleapis.com/syzbot-assets/c06d7c39bbc0/bzImage-3f86ed6e.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/120cc7b707b8/mount_0.gz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+9b8285...@syzkaller.appspotmail.com

XFS (loop0): Quotacheck needed: Please wait.
XFS (loop0): Quotacheck: Done.
------------[ cut here ]------------
WARNING: CPU: 1 PID: 5030 at mm/gup.c:229 try_grab_page+0x287/0x460
Modules linked in:
CPU: 1 PID: 5030 Comm: syz-executor118 Not tainted 6.5.0-syzkaller-11704-g3f86ed6ec0b3 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/26/2023
RIP: 0010:try_grab_page+0x287/0x460 mm/gup.c:229
Code: 01 49 8d 7e 60 be 04 00 00 00 e8 54 41 18 00 f0 41 83 46 60 01 42 80 3c 2b 00 0f 85 6a ff ff ff e9 6d ff ff ff e8 b9 55 be ff <0f> 0b bb f4 ff ff ff eb b6 e8 ab 55 be ff 49 ff ce e9 ca fd ff ff
RSP: 0018:ffffc90003a6ee88 EFLAGS: 00010293
RAX: ffffffff81cf4377 RBX: 0000000000000000 RCX: ffff888025da0000
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000001
RBP: 000000000000000e R08: ffffffff81cf418c R09: 1ffffd400039097e
R10: dffffc0000000000 R11: fffff9400039097f R12: ffffea0001c84bf4
R13: dffffc0000000000 R14: ffffea0001c84bc0 R15: ffffea0001c84bc0
FS: 0000555555acb380(0000) GS:ffff8880b9900000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000020008000 CR3: 00000000736e9000 CR4: 00000000003506e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
<TASK>
follow_page_pte+0x560/0x18f0 mm/gup.c:651
follow_pud_mask mm/gup.c:765 [inline]
follow_p4d_mask mm/gup.c:782 [inline]
follow_page_mask+0x7dc/0xe20 mm/gup.c:832
__get_user_pages+0x643/0x15e0 mm/gup.c:1237
__get_user_pages_locked mm/gup.c:1504 [inline]
get_dump_page+0x146/0x2b0 mm/gup.c:2018
dump_user_range+0x126/0x910 fs/coredump.c:913
elf_core_dump+0x3b75/0x4490 fs/binfmt_elf.c:2142
do_coredump+0x1b73/0x2ab0 fs/coredump.c:764
get_signal+0x145e/0x1840 kernel/signal.c:2878
arch_do_signal_or_restart+0x96/0x860 arch/x86/kernel/signal.c:309
exit_to_user_mode_loop+0x6a/0x100 kernel/entry/common.c:168
exit_to_user_mode_prepare+0xb1/0x140 kernel/entry/common.c:204
__syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline]
syscall_exit_to_user_mode+0x64/0x280 kernel/entry/common.c:296
do_syscall_64+0x4d/0xc0 arch/x86/entry/common.c:86
entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7fb68edcf0f9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 21 18 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffc8b18d558 EFLAGS: 00000246 ORIG_RAX: 000000000000004d
RAX: ffffffffffffffe5 RBX: 0000000000000003 RCX: 00007fb68edcf0f9
RDX: 0000000000000000 RSI: 0000000100000001 RDI: 0000000000000006
RBP: 0000000000000000 R08: 0000000000000000 R09: 0000555500000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00000000000f4240
R13: 00007ffc8b18d7c8 R14: 0000000000000001 R15: 00007ffc8b18d590
</TASK>


---
If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.
Reply all
Reply to author
Forward
0 new messages