[syzbot] [fs?] [mm?] WARNING in page_copy_sane

6 views
Skip to first unread message

syzbot

unread,
Sep 18, 2023, 12:41:09 AM9/18/23
to ak...@linux-foundation.org, linux-...@vger.kernel.org, linux-...@vger.kernel.org, linu...@kvack.org, ll...@lists.linux.dev, mike.k...@oracle.com, muchu...@linux.dev, nat...@kernel.org, ndesau...@google.com, sidhart...@oracle.com, syzkall...@googlegroups.com, tr...@redhat.com, wi...@infradead.org
Hello,

syzbot found the following issue on:

HEAD commit: 98897dc735cf Add linux-next specific files for 20230914
git tree: linux-next
console+strace: https://syzkaller.appspot.com/x/log.txt?x=1548728c680000
kernel config: https://syzkaller.appspot.com/x/.config?x=1502c503717ada5c
dashboard link: https://syzkaller.appspot.com/bug?extid=c225dea486da4d5592bd
compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=171fffd8680000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=17bbbf1c680000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/00e4c0af5a8a/disk-98897dc7.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/7b54a00eee56/vmlinux-98897dc7.xz
kernel image: https://storage.googleapis.com/syzbot-assets/100094353b8e/bzImage-98897dc7.xz

The issue was bisected to:

commit 591a2520fbfd6565d9a5c732afa53f62228798e6
Author: Sidhartha Kumar <sidhart...@oracle.com>
Date: Mon Sep 11 21:53:19 2023 +0000

mm/filemap: remove hugetlb special casing in filemap.c

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=15e15464680000
final oops: https://syzkaller.appspot.com/x/report.txt?x=17e15464680000
console output: https://syzkaller.appspot.com/x/log.txt?x=13e15464680000

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+c225de...@syzkaller.appspotmail.com
Fixes: 591a2520fbfd ("mm/filemap: remove hugetlb special casing in filemap.c")

------------[ cut here ]------------
WARNING: CPU: 1 PID: 5040 at lib/iov_iter.c:463 page_copy_sane+0xc2/0x2c0 lib/iov_iter.c:463
Modules linked in:
CPU: 1 PID: 5040 Comm: syz-executor204 Not tainted 6.6.0-rc1-next-20230914-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/04/2023
RIP: 0010:page_copy_sane+0xc2/0x2c0 lib/iov_iter.c:463
Code: e8 73 db 63 fd 66 90 e8 6c db 63 fd e8 67 db 63 fd 4c 89 ee 48 89 ef e8 6c d6 63 fd 49 39 ed 0f 83 eb 00 00 00 e8 4e db 63 fd <0f> 0b 31 db e8 45 db 63 fd 89 d8 5b 5d 41 5c 41 5d 41 5e 41 5f c3
RSP: 0018:ffffc90003eefa58 EFLAGS: 00010293
RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
RDX: ffff88807a01d940 RSI: ffffffff84241482 RDI: 0000000000000006
RBP: 0000000000200000 R08: 0000000000000006 R09: 0000000000201000
R10: 0000000000200000 R11: 0000000000000000 R12: 0000000000000009
R13: 0000000000201000 R14: 0000000000000001 R15: ffffea0001fe0000
FS: 0000555556937380(0000) GS:ffff8880b9900000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00000000200001c0 CR3: 000000002911d000 CR4: 00000000003506e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
<TASK>
copy_page_to_iter+0x35/0x180 lib/iov_iter.c:472
hugetlbfs_read_iter+0x3d7/0xa60 fs/hugetlbfs/inode.c:385
call_read_iter include/linux/fs.h:1980 [inline]
do_iter_readv_writev+0x2f2/0x3c0 fs/read_write.c:733
do_iter_read+0x315/0x870 fs/read_write.c:795
vfs_readv+0x12d/0x1a0 fs/read_write.c:915
do_preadv fs/read_write.c:1007 [inline]
__do_sys_preadv fs/read_write.c:1057 [inline]
__se_sys_preadv fs/read_write.c:1052 [inline]
__x64_sys_preadv+0x228/0x300 fs/read_write.c:1052
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7f85cc7932e9
Code: 48 83 c4 28 c3 e8 37 17 00 00 0f 1f 80 00 00 00 00 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:00007ffda50bbbd8 EFLAGS: 00000246 ORIG_RAX: 0000000000000127
RAX: ffffffffffffffda RBX: 00007ffda50bbdb8 RCX: 00007f85cc7932e9
RDX: 0000000000000002 RSI: 0000000020000180 RDI: 0000000000000003
RBP: 00007f85cc806610 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000001
R13: 00007ffda50bbda8 R14: 0000000000000001 R15: 0000000000000001
</TASK>


---
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.
For information about bisection process see: https://goo.gl/tpsmEJ#bisection

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

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.

If you want to overwrite 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

syzbot

unread,
Sep 18, 2023, 12:44:14 PM9/18/23
to sidhart...@oracle.com, sidhart...@oracle.com, syzkall...@googlegroups.com
> #syz test

Your commands are accepted, but please keep syzkall...@googlegroups.com mailing list in CC next time. It serves as a history of what happened with each bug report. Thank you.

>
>
> diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
> index 14d3d28e41b0..5e09d4c86260 100644
> --- a/fs/hugetlbfs/inode.c
> +++ b/fs/hugetlbfs/inode.c
> @@ -334,6 +334,7 @@ static ssize_t hugetlbfs_read_iter(struct kiocb
> *iocb, struct iov_iter *to)
> ssize_t retval = 0;
>
> while (iov_iter_count(to)) {
> + struct folio *folio;
> struct page *page;
> size_t nr, copied, want;
>
> @@ -353,17 +354,17 @@ static ssize_t hugetlbfs_read_iter(struct kiocb
> *iocb, struct iov_iter *to)
> nr = nr - offset;
>
> /* Find the page */
> - page = find_lock_page(mapping, index);
> - if (unlikely(page == NULL)) {
> + folio = filemap_lock_hugetlb_folio(h, mapping, index);
> + if (unlikely(folio == NULL)) {
> /*
> * We have a HOLE, zero out the user-buffer for the
> * length of the hole or request.
> */
> copied = iov_iter_zero(nr, to);
> } else {
> - unlock_page(page);
> + folio_unlock(folio);
>
> - if (!PageHWPoison(page))
> + if (!folio_test_has_hwpoisoned(folio))
> want = nr;
> else {
> /*
> @@ -371,9 +372,9 @@ static ssize_t hugetlbfs_read_iter(struct kiocb
> *iocb, struct iov_iter *to)
> * touching the 1st raw HWPOISON
> subpage after
> * offset.
> */
> - want = adjust_range_hwpoison(page,
> offset, nr);
> + want =
> adjust_range_hwpoison(&folio->page, offset, nr);
> if (want == 0) {
> - put_page(page);
> + folio_put(folio);
> retval = -EIO;
> break;
> }
> @@ -382,8 +383,8 @@ static ssize_t hugetlbfs_read_iter(struct kiocb
> *iocb, struct iov_iter *to)
> /*
> * We have the page, copy it to user space buffer.
> */
> - copied = copy_page_to_iter(page, offset, want, to);
> - put_page(page);
> + copied = copy_page_to_iter(&folio->page, offset,
> want, to);
> + folio_put(folio);
> }
> offset += copied;
> retval += copied;

syzbot

unread,
Sep 18, 2023, 12:46:42 PM9/18/23
to sidhart...@oracle.com, syzkall...@googlegroups.com
Hello,

syzbot tried to test the proposed patch but the build/boot failed:

failed to apply patch:
checking file fs/hugetlbfs/inode.c
patch: **** unexpected end of file in patch



Tested on:

commit: 7fc7222d Add linux-next specific files for 20230918
git tree: linux-next
patch: https://syzkaller.appspot.com/x/patch.diff?x=1300fe54680000

syzbot

unread,
Sep 18, 2023, 2:03:37 PM9/18/23
to sidhart...@oracle.com, syzkall...@googlegroups.com

syzbot

unread,
Sep 18, 2023, 2:03:37 PM9/18/23
to sidhart...@oracle.com, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-and-tested-by: syzbot+c225de...@syzkaller.appspotmail.com

Tested on:

commit: 7fc7222d Add linux-next specific files for 20230918
git tree: linux-next
console output: https://syzkaller.appspot.com/x/log.txt?x=1323f58c680000
kernel config: https://syzkaller.appspot.com/x/.config?x=79253779bcbe3130
dashboard link: https://syzkaller.appspot.com/bug?extid=c225dea486da4d5592bd
compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=121bcef8680000

Note: testing is done by a robot and is best-effort only.

Matthew Wilcox

unread,
Sep 18, 2023, 2:18:50 PM9/18/23
to Sidhartha Kumar, syzbot, ak...@linux-foundation.org, linux-...@vger.kernel.org, linux-...@vger.kernel.org, linu...@kvack.org, ll...@lists.linux.dev, mike.k...@oracle.com, muchu...@linux.dev, nat...@kernel.org, ndesau...@google.com, syzkall...@googlegroups.com, tr...@redhat.com
On Mon, Sep 18, 2023 at 01:10:21PM -0500, Sidhartha Kumar wrote:
> @@ -382,8 +382,8 @@ static ssize_t hugetlbfs_read_iter(struct kiocb *iocb, struct iov_iter *to)
> /*
> * We have the page, copy it to user space buffer.
> */
> - copied = copy_page_to_iter(page, offset, want, to);
> - put_page(page);
> + copied = copy_page_to_iter(&folio->page, offset, want, to);

copy_folio_to_iter() please. Yes, I know it's just a wrapper today.

> + folio_put(folio);
> }
> offset += copied;
> retval += copied;
> --
> 2.41.0
>

syzbot

unread,
Sep 18, 2023, 2:36:28 PM9/18/23
to ak...@linux-foundation.org, linux-...@vger.kernel.org, linux-...@vger.kernel.org, linu...@kvack.org, ll...@lists.linux.dev, mike.k...@oracle.com, muchu...@linux.dev, nat...@kernel.org, ndesau...@google.com, sidhart...@oracle.com, syzkall...@googlegroups.com, tr...@redhat.com, wi...@infradead.org
Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-and-tested-by: syzbot+c225de...@syzkaller.appspotmail.com

Tested on:

commit: 7fc7222d Add linux-next specific files for 20230918
git tree: linux-next
console output: https://syzkaller.appspot.com/x/log.txt?x=17fddb62680000
kernel config: https://syzkaller.appspot.com/x/.config?x=79253779bcbe3130
dashboard link: https://syzkaller.appspot.com/bug?extid=c225dea486da4d5592bd
compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=137cae54680000

Sidhartha Kumar

unread,
Sep 19, 2023, 5:43:38 AM9/19/23
to syzbot, syzkall...@googlegroups.com
On 9/17/23 11:41 PM, syzbot wrote:
#syz test
v7-0001-mm-hugetlb-fix-warning-in-page_copy_sane.patch

Sidhartha Kumar

unread,
Sep 19, 2023, 5:44:20 AM9/19/23
to syzbot, ak...@linux-foundation.org, linux-...@vger.kernel.org, linux-...@vger.kernel.org, linu...@kvack.org, ll...@lists.linux.dev, mike.k...@oracle.com, muchu...@linux.dev, nat...@kernel.org, ndesau...@google.com, syzkall...@googlegroups.com, tr...@redhat.com, wi...@infradead.org
On 9/17/23 11:41 PM, syzbot wrote:
#syz test
0001-mm-hugetlb-fix-warning-in-page_copy_sane.patch

Sidhartha Kumar

unread,
Sep 19, 2023, 5:44:20 AM9/19/23
to syzbot, syzkall...@googlegroups.com
#syz test

From ce2fbe18194b31a2ddafb2bb761dec910fa36c18 Mon Sep 17 00:00:00 2001
From: Sidhartha Kumar <sidhart...@oracle.com>
Date: Mon, 18 Sep 2023 11:40:07 -0500
Subject: [PATCH v7] mm/hugetlb: fix warning in page_copy_sane

Signed-off-by: Sidhartha Kumar <sidhart...@oracle.com>
---
fs/hugetlbfs/inode.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 14d3d28e41b0..5e09d4c86260 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -334,6 +334,7 @@ static ssize_t hugetlbfs_read_iter(struct kiocb
*iocb, struct iov_iter *to)
ssize_t retval = 0;

while (iov_iter_count(to)) {
+ struct folio *folio;
struct page *page;
size_t nr, copied, want;

@@ -353,17 +354,17 @@ static ssize_t hugetlbfs_read_iter(struct kiocb
*iocb, struct iov_iter *to)
nr = nr - offset;

/* Find the page */
- page = find_lock_page(mapping, index);
- if (unlikely(page == NULL)) {
+ folio = filemap_lock_hugetlb_folio(h, mapping, index);
+ if (unlikely(folio == NULL)) {
/*
* We have a HOLE, zero out the user-buffer for the
* length of the hole or request.
*/
copied = iov_iter_zero(nr, to);
} else {
- unlock_page(page);
+ folio_unlock(folio);

- if (!PageHWPoison(page))
+ if (!folio_test_has_hwpoisoned(folio))
want = nr;
else {
/*
@@ -371,9 +372,9 @@ static ssize_t hugetlbfs_read_iter(struct kiocb
*iocb, struct iov_iter *to)
* touching the 1st raw HWPOISON subpage after
* offset.
*/
- want = adjust_range_hwpoison(page, offset, nr);
+ want = adjust_range_hwpoison(&folio->page, offset, nr);
if (want == 0) {
- put_page(page);
+ folio_put(folio);
retval = -EIO;
break;
}
@@ -382,8 +383,8 @@ static ssize_t hugetlbfs_read_iter(struct kiocb
*iocb, struct iov_iter *to)
/*
* We have the page, copy it to user space buffer.
*/
- copied = copy_page_to_iter(page, offset, want, to);
- put_page(page);
+ copied = copy_page_to_iter(&folio->page, offset, want, to);

Aleksandr Nogikh

unread,
Sep 19, 2023, 6:39:18 AM9/19/23
to syzbot, sidhart...@oracle.com, syzkall...@googlegroups.com
syzbot expects no empty lines inside the git patch, please take a look
at the part it managed to parse (available via the link above).

Ivan Orlov

unread,
Sep 20, 2023, 10:52:25 AM9/20/23
to syzkall...@googlegroups.com, syzbot+c225de...@syzkaller.appspotmail.com

syzbot

unread,
Sep 20, 2023, 11:14:30 AM9/20/23
to ivan.or...@gmail.com, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-and-tested-by: syzbot+c225de...@syzkaller.appspotmail.com

Tested on:

commit: 2cf0f715 Merge tag 'nfs-for-6.6-2' of git://git.linux-..
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
console output: https://syzkaller.appspot.com/x/log.txt?x=1647bf54680000
kernel config: https://syzkaller.appspot.com/x/.config?x=d594086f139d167
dashboard link: https://syzkaller.appspot.com/bug?extid=c225dea486da4d5592bd
compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40

Note: no patches were applied.
Reply all
Reply to author
Forward
0 new messages