linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Suraj Sonawane <surajsonawane0215@gmail.com>
To: syzbot <syzbot+9f9a7f73fb079b2387a6@syzkaller.appspotmail.com>
Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
	 linux-mm@kvack.org, syzkaller-bugs@googlegroups.com
Subject: Re: [syzbot] [mm?] kernel BUG in const_folio_flags (2)
Date: Mon, 25 Nov 2024 13:23:28 +0530	[thread overview]
Message-ID: <CAHiZj8h7VTOdp3CnbocTn2c4QnVDQi+YeRUDACvoKgBDYi-4eg@mail.gmail.com> (raw)
In-Reply-To: <674184c9.050a0220.1cc393.0001.GAE@google.com>


[-- Attachment #1.1: Type: text/plain, Size: 7380 bytes --]

#syz test

On Sat, Nov 23, 2024 at 1:01 PM syzbot <
syzbot+9f9a7f73fb079b2387a6@syzkaller.appspotmail.com> wrote:

> Hello,
>
> syzbot found the following issue on:
>
> HEAD commit:    9fb2cfa4635a Merge tag 'pull-ufs' of git://git.kernel.org/
> ..
> git tree:       upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=10042930580000
> kernel config:  https://syzkaller.appspot.com/x/.config?x=c4515f1b6a4e50b7
> dashboard link:
> https://syzkaller.appspot.com/bug?extid=9f9a7f73fb079b2387a6
> 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=105ff2e8580000
>
> Downloadable assets:
> disk image:
> https://storage.googleapis.com/syzbot-assets/7c0c61a15f60/disk-9fb2cfa4.raw.xz
> vmlinux:
> https://storage.googleapis.com/syzbot-assets/3363d84eeb74/vmlinux-9fb2cfa4.xz
> kernel image:
> https://storage.googleapis.com/syzbot-assets/2b1a270af550/bzImage-9fb2cfa4.xz
>
> IMPORTANT: if you fix the issue, please add the following tag to the
> commit:
> Reported-by: syzbot+9f9a7f73fb079b2387a6@syzkaller.appspotmail.com
>
>  madvise_pageout_page_range mm/madvise.c:609 [inline]
>  madvise_pageout+0x326/0x820 mm/madvise.c:636
>  madvise_vma_behavior+0x58c/0x19e0 mm/madvise.c:1045
>  madvise_walk_vmas+0x1cf/0x2c0 mm/madvise.c:1274
>  do_madvise+0x29d/0x700 mm/madvise.c:1461
>  __do_sys_madvise mm/madvise.c:1477 [inline]
>  __se_sys_madvise mm/madvise.c:1475 [inline]
>  __x64_sys_madvise+0xa9/0x110 mm/madvise.c:1475
>  do_syscall_x64 arch/x86/entry/common.c:52 [inline]
>  do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83
> ------------[ cut here ]------------
> kernel BUG at include/linux/page-flags.h:309!
> Oops: invalid opcode: 0000 [#1] PREEMPT SMP KASAN PTI
> CPU: 0 UID: 0 PID: 7269 Comm: syz.1.183 Not tainted
> 6.12.0-syzkaller-00233-g9fb2cfa4635a #0
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
> Google 10/30/2024
> RIP: 0010:const_folio_flags.constprop.0+0x12e/0x150
> include/linux/page-flags.h:309
> Code: 86 cb ff e8 f4 86 cb ff 48 8d 45 ff 48 39 c3 0f 84 38 ff ff ff e8 e2
> 86 cb ff 48 c7 c6 00 19 58 8b 48 89 df e8 e3 4b 11 00 90 <0f> 0b e8 6b 0d
> 2d 00 e9 f1 fe ff ff e8 61 0d 2d 00 eb a3 48 89 df
> RSP: 0018:ffffc9000c55ee30 EFLAGS: 00010293
> RAX: 0000000000000000 RBX: ffffea0000496f80 RCX: ffffc9000c55ecd8
> RDX: ffff88805f401e00 RSI: ffffffff81c1362d RDI: ffff88805f402244
> RBP: 0000000000000001 R08: 0000000000000000 R09: fffffbfff203a591
> R10: ffffffff901d2c8f R11: 0000000000000001 R12: 00000000000014df
> R13: 0000000000000000 R14: dffffc0000000000 R15: 1ffff920018abdf4
> FS:  00007f08b31bc6c0(0000) GS:ffff8880b8600000(0000)
> knlGS:0000000000000000
> CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> CR2: 000000c0025ff000 CR3: 00000000341ce000 CR4: 00000000003526f0
> DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
> DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
> Call Trace:
>  <TASK>
>  folio_test_locked include/linux/page-flags.h:509 [inline]
>  next_uptodate_folio+0xac/0x4b0 mm/filemap.c:3505
>  filemap_map_pages+0x1c6/0x16a0 mm/filemap.c:3647
>  do_fault_around mm/memory.c:5255 [inline]
>  do_read_fault mm/memory.c:5288 [inline]
>  do_fault mm/memory.c:5431 [inline]
>  do_pte_missing+0xdae/0x3e70 mm/memory.c:3965
>  handle_pte_fault mm/memory.c:5766 [inline]
>  __handle_mm_fault+0x100a/0x2a10 mm/memory.c:5909
>  handle_mm_fault+0x3fa/0xaa0 mm/memory.c:6077
>  faultin_page mm/gup.c:1187 [inline]
>  __get_user_pages+0x8d9/0x3b50 mm/gup.c:1485
>  __get_user_pages_locked mm/gup.c:1751 [inline]
>  get_dump_page+0xfb/0x220 mm/gup.c:2269
>  dump_user_range+0x135/0x8c0 fs/coredump.c:943
>  elf_core_dump+0x2766/0x3840 fs/binfmt_elf.c:2121
>  do_coredump+0x2c42/0x4160 fs/coredump.c:758
>  get_signal+0x237c/0x26d0 kernel/signal.c:2903
>  arch_do_signal_or_restart+0x90/0x7e0 arch/x86/kernel/signal.c:337
>  exit_to_user_mode_loop kernel/entry/common.c:111 [inline]
>  exit_to_user_mode_prepare include/linux/entry-common.h:328 [inline]
>  irqentry_exit_to_user_mode+0x13f/0x280 kernel/entry/common.c:231
>  asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:623
> RIP: 0033:0x1000
> Code: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <00> 00 00 00 00
> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> RSP: 002b:000000000000010c EFLAGS: 00010246
> RAX: 0000000000000000 RBX: 00007f08b41363b8 RCX: 00007f08b3f7e759
> RDX: ffffffffff600000 RSI: 0000000000000104 RDI: 8000000000000000
> RBP: 00007f08b3ff175e R08: 0000000100000000 R09: 0000000000000000
> R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
> R13: 0000000000000000 R14: 00007f08b41363b8 R15: 00007fff7656a008
>  </TASK>
> Modules linked in:
> ---[ end trace 0000000000000000 ]---
> RIP: 0010:const_folio_flags.constprop.0+0x12e/0x150
> include/linux/page-flags.h:309
> Code: 86 cb ff e8 f4 86 cb ff 48 8d 45 ff 48 39 c3 0f 84 38 ff ff ff e8 e2
> 86 cb ff 48 c7 c6 00 19 58 8b 48 89 df e8 e3 4b 11 00 90 <0f> 0b e8 6b 0d
> 2d 00 e9 f1 fe ff ff e8 61 0d 2d 00 eb a3 48 89 df
> RSP: 0018:ffffc9000c55ee30 EFLAGS: 00010293
> RAX: 0000000000000000 RBX: ffffea0000496f80 RCX: ffffc9000c55ecd8
> RDX: ffff88805f401e00 RSI: ffffffff81c1362d RDI: ffff88805f402244
> RBP: 0000000000000001 R08: 0000000000000000 R09: fffffbfff203a591
> R10: ffffffff901d2c8f R11: 0000000000000001 R12: 00000000000014df
> R13: 0000000000000000 R14: dffffc0000000000 R15: 1ffff920018abdf4
> FS:  00007f08b31bc6c0(0000) GS:ffff8880b8700000(0000)
> knlGS:0000000000000000
> CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> CR2: 00007fff76568ff8 CR3: 00000000341ce000 CR4: 00000000003526f0
> DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
> DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
>
>
> ---
> 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 syzkaller@googlegroups.com.
>
> syzbot will keep track of this issue. See:
> https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
>
> If the report is already addressed, 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 report's subsystems, reply with:
> #syz set subsystems: new-subsystem
> (See the list of subsystem names on the web dashboard)
>
> If the report is a duplicate of another one, reply with:
> #syz dup: exact-subject-of-another-report
>
> If you want to undo deduplication, reply with:
> #syz undup
>
> --
> You received this message because you are subscribed to the Google Groups
> "syzkaller-bugs" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to syzkaller-bugs+unsubscribe@googlegroups.com.
> To view this discussion visit
> https://groups.google.com/d/msgid/syzkaller-bugs/674184c9.050a0220.1cc393.0001.GAE%40google.com
> .
>

[-- Attachment #1.2: Type: text/html, Size: 9393 bytes --]

[-- Attachment #2: 0001-v2fix-kernel-BUG-in-const_folio_flags.patch --]
[-- Type: text/x-patch, Size: 1181 bytes --]

From 332c11344a3c5b064982d556dd40c7a17fdf44e9 Mon Sep 17 00:00:00 2001
From: Suraj Sonawane <surajsonawane0215@gmail.com>
Date: Mon, 25 Nov 2024 13:19:48 +0530
Subject: [PATCH] v2fix kernel BUG in const_folio_flags

syz test

Signed-off-by: Suraj Sonawane <surajsonawane0215@gmail.com>
---
 include/linux/page-flags.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index 2220bfec2..214ad9d6d 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -8,6 +8,7 @@
 
 #include <linux/types.h>
 #include <linux/bug.h>
+#include <linux/mm.h>
 #include <linux/mmdebug.h>
 #ifndef __GENERATING_BOUNDS_H
 #include <linux/mm_types.h>
@@ -306,6 +307,12 @@ static const unsigned long *const_folio_flags(const struct folio *folio,
 {
 	const struct page *page = &folio->page;
 
+	long nr_pages = folio_nr_pages(folio);
+
+	if (n >= nr_pages) {
+		pr_err("Invalid folio index: n=%u, folio_nr_pages=%u\n", n, folio_nr_pages(folio));
+		return -EINVAL;
+	}
+
 	VM_BUG_ON_PGFLAGS(PageTail(page), page);
 	VM_BUG_ON_PGFLAGS(n > 0 && !test_bit(PG_head, &page->flags), page);
 	return &page[n].flags;
-- 
2.34.1


  parent reply	other threads:[~2024-11-25  7:54 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-23  7:31 syzbot
2024-11-25  6:56 ` Suraj Sonawane
2024-11-25  6:58   ` syzbot
2024-11-25  7:16 ` Suraj Sonawane
2024-11-25  7:18   ` syzbot
2024-11-25  7:37 ` Suraj Sonawane
2024-11-25  7:39   ` syzbot
2024-11-25  7:53 ` Suraj Sonawane [this message]
2024-11-25  7:55   ` syzbot
2024-11-25  7:57 ` Suraj Sonawane
2024-11-25  7:59   ` syzbot
2024-11-25 13:12 ` Suraj Sonawane
2024-11-25 13:43   ` syzbot
2024-11-28 10:52 ` David Hildenbrand
2024-11-28 11:42   ` Hillf Danton
2024-11-28 12:02     ` David Hildenbrand
2024-11-28 12:23       ` David Hildenbrand
2024-11-28 13:03         ` Hillf Danton
2024-11-28 13:37           ` syzbot
2024-11-28 12:57 ` David Hildenbrand
2024-11-28 13:18   ` syzbot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAHiZj8h7VTOdp3CnbocTn2c4QnVDQi+YeRUDACvoKgBDYi-4eg@mail.gmail.com \
    --to=surajsonawane0215@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=syzbot+9f9a7f73fb079b2387a6@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox