LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [syzbot] general protection fault in try_grab_compound_head
@ 2021-07-03 15:41 syzbot
  2021-07-03 20:24 ` syzbot
  0 siblings, 1 reply; 5+ messages in thread
From: syzbot @ 2021-07-03 15:41 UTC (permalink / raw)
  To: akpm, linux-kernel, linux-mm, syzkaller-bugs

Hello,

syzbot found the following issue on:

HEAD commit:    3dbdb38e Merge branch 'for-5.14' of git://git.kernel.org/p..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=16758ac4300000
kernel config:  https://syzkaller.appspot.com/x/.config?x=a1fcf15a09815757
dashboard link: https://syzkaller.appspot.com/bug?extid=a3fcd59df1b372066f5a
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=11a856c4300000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=1582c9d8300000

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

general protection fault, probably for non-canonical address 0xdffffc0000000000: 0000 [#1] PREEMPT SMP KASAN
KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007]
CPU: 0 PID: 8484 Comm: syz-executor116 Tainted: G        W         5.13.0-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
RIP: 0010:page_zonenum include/linux/mm.h:1121 [inline]
RIP: 0010:is_zone_movable_page include/linux/mm.h:1140 [inline]
RIP: 0010:is_pinnable_page include/linux/mm.h:1556 [inline]
RIP: 0010:try_grab_compound_head mm/gup.c:126 [inline]
RIP: 0010:try_grab_compound_head+0x686/0x8f0 mm/gup.c:113
Code: e9 16 fe ff ff e8 0a fe cc ff 0f 0b 45 31 e4 e9 07 fe ff ff e8 fb fd cc ff 48 89 da 48 b8 00 00 00 00 00 fc ff df 48 c1 ea 03 <80> 3c 02 00 0f 85 44 02 00 00 48 8b 2b bf 03 00 00 00 49 bc 00 00
RSP: 0018:ffffc900017df7e8 EFLAGS: 00010246
RAX: dffffc0000000000 RBX: 0000000000000000 RCX: 0000000000000000
RDX: 0000000000000000 RSI: ffffffff81a88c35 RDI: 0000000000000003
RBP: 0000000000010000 R08: 0000000000000000 R09: 0000000000000003
R10: ffffffff81a8862b R11: 000000000000003f R12: 0000000000040000
R13: ffff88803ac03ff8 R14: 0000000000000000 R15: dffffc0000000000
FS:  00000000005a5300(0000) GS:ffff8880b9c00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000020000084 CR3: 0000000021f85000 CR4: 00000000001506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 follow_hugetlb_page+0x7bf/0x12c0 mm/hugetlb.c:5248
 __get_user_pages+0x5d8/0x1490 mm/gup.c:1137
 __get_user_pages_locked mm/gup.c:1352 [inline]
 __gup_longterm_locked+0x216/0xfa0 mm/gup.c:1745
 pin_user_pages+0x84/0xc0 mm/gup.c:2900
 io_sqe_buffer_register+0x24e/0x1350 fs/io_uring.c:8381
 io_sqe_buffers_register+0x29c/0x620 fs/io_uring.c:8508
 __io_uring_register fs/io_uring.c:10129 [inline]
 __do_sys_io_uring_register+0x1049/0x2880 fs/io_uring.c:10254
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x43ef49
Code: 28 c3 e8 2a 14 00 00 66 2e 0f 1f 84 00 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 c0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffea3542188 EFLAGS: 00000246 ORIG_RAX: 00000000000001ab
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 000000000043ef49
RDX: 00000000200001c0 RSI: 0000000000000000 RDI: 0000000000000003
RBP: 0000000000402f30 R08: 0000000010000000 R09: 0000000000000000
R10: 0000000000000001 R11: 0000000000000246 R12: 0000000000402fc0
R13: 0000000000000000 R14: 00000000004ac018 R15: 0000000000400488
Modules linked in:
---[ end trace e3fc885187db8a03 ]---
RIP: 0010:page_zonenum include/linux/mm.h:1121 [inline]
RIP: 0010:is_zone_movable_page include/linux/mm.h:1140 [inline]
RIP: 0010:is_pinnable_page include/linux/mm.h:1556 [inline]
RIP: 0010:try_grab_compound_head mm/gup.c:126 [inline]
RIP: 0010:try_grab_compound_head+0x686/0x8f0 mm/gup.c:113
Code: e9 16 fe ff ff e8 0a fe cc ff 0f 0b 45 31 e4 e9 07 fe ff ff e8 fb fd cc ff 48 89 da 48 b8 00 00 00 00 00 fc ff df 48 c1 ea 03 <80> 3c 02 00 0f 85 44 02 00 00 48 8b 2b bf 03 00 00 00 49 bc 00 00
RSP: 0018:ffffc900017df7e8 EFLAGS: 00010246
RAX: dffffc0000000000 RBX: 0000000000000000 RCX: 0000000000000000
RDX: 0000000000000000 RSI: ffffffff81a88c35 RDI: 0000000000000003
RBP: 0000000000010000 R08: 0000000000000000 R09: 0000000000000003
R10: ffffffff81a8862b R11: 000000000000003f R12: 0000000000040000
R13: ffff88803ac03ff8 R14: 0000000000000000 R15: dffffc0000000000
FS:  00000000005a5300(0000) GS:ffff8880b9c00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000020000084 CR3: 0000000021f85000 CR4: 00000000001506f0
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.
syzbot can test patches for this issue, for details see:
https://goo.gl/tpsmEJ#testing-patches

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [syzbot] general protection fault in try_grab_compound_head
  2021-07-03 15:41 [syzbot] general protection fault in try_grab_compound_head syzbot
@ 2021-07-03 20:24 ` syzbot
  2021-07-08 13:03   ` Thomas Gleixner
  0 siblings, 1 reply; 5+ messages in thread
From: syzbot @ 2021-07-03 20:24 UTC (permalink / raw)
  To: akpm, bp, hpa, jmattson, joro, kvm, linux-kernel, linux-mm,
	mark.rutland, masahiroy, mingo, pbonzini, peterz,
	rafael.j.wysocki, rostedt, seanjc, sedat.dilek, syzkaller-bugs,
	tglx, vitor, vkuznets, wanpengli, will, x86

syzbot has bisected this issue to:

commit 997acaf6b4b59c6a9c259740312a69ea549cc684
Author: Mark Rutland <mark.rutland@arm.com>
Date:   Mon Jan 11 15:37:07 2021 +0000

    lockdep: report broken irq restoration

bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=16fbcec4300000
start commit:   3dbdb38e Merge branch 'for-5.14' of git://git.kernel.org/p..
git tree:       upstream
final oops:     https://syzkaller.appspot.com/x/report.txt?x=15fbcec4300000
console output: https://syzkaller.appspot.com/x/log.txt?x=11fbcec4300000
kernel config:  https://syzkaller.appspot.com/x/.config?x=a1fcf15a09815757
dashboard link: https://syzkaller.appspot.com/bug?extid=a3fcd59df1b372066f5a
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=11a856c4300000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=1582c9d8300000

Reported-by: syzbot+a3fcd59df1b372066f5a@syzkaller.appspotmail.com
Fixes: 997acaf6b4b5 ("lockdep: report broken irq restoration")

For information about bisection process see: https://goo.gl/tpsmEJ#bisection

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [syzbot] general protection fault in try_grab_compound_head
  2021-07-03 20:24 ` syzbot
@ 2021-07-08 13:03   ` Thomas Gleixner
  2021-07-12 21:29     ` Sean Christopherson
  0 siblings, 1 reply; 5+ messages in thread
From: Thomas Gleixner @ 2021-07-08 13:03 UTC (permalink / raw)
  To: syzbot, akpm, bp, hpa, jmattson, joro, kvm, linux-kernel,
	linux-mm, mark.rutland, masahiroy, mingo, pbonzini, peterz,
	rafael.j.wysocki, rostedt, seanjc, sedat.dilek, syzkaller-bugs,
	vitor, vkuznets, wanpengli, will, x86

On Sat, Jul 03 2021 at 13:24, syzbot wrote:
> syzbot has bisected this issue to:
>
> commit 997acaf6b4b59c6a9c259740312a69ea549cc684
> Author: Mark Rutland <mark.rutland@arm.com>
> Date:   Mon Jan 11 15:37:07 2021 +0000
>
>     lockdep: report broken irq restoration

That's the commit which makes the underlying problem visible:

       raw_local_irq_restore() called with IRQs enabled

and is triggered by this call chain:

 kvm_wait arch/x86/kernel/kvm.c:860 [inline]
 kvm_wait+0xc3/0xe0 arch/x86/kernel/kvm.c:837
 pv_wait arch/x86/include/asm/paravirt.h:564 [inline]
 pv_wait_head_or_lock kernel/locking/qspinlock_paravirt.h:470 [inline]
 __pv_queued_spin_lock_slowpath+0x8b8/0xb40 kernel/locking/qspinlock.c:508
 pv_queued_spin_lock_slowpath arch/x86/include/asm/paravirt.h:554 [inline]
 queued_spin_lock_slowpath arch/x86/include/asm/qspinlock.h:51 [inline]
 queued_spin_lock include/asm-generic/qspinlock.h:85 [inline]
 do_raw_spin_lock+0x200/0x2b0 kernel/locking/spinlock_debug.c:113
 spin_lock include/linux/spinlock.h:354 [inline]
 alloc_huge_page+0x2b0/0xda0 mm/hugetlb.c:2318
 hugetlb_no_page mm/hugetlb.c:4323 [inline]
 hugetlb_fault+0xc35/0x1cd0 mm/hugetlb.c:4523
 follow_hugetlb_page+0x317/0xda0 mm/hugetlb.c:4836
 __get_user_pages+0x3fa/0xe30 mm/gup.c:1041
 __get_user_pages_locked mm/gup.c:1256 [inline]
 __gup_longterm_locked+0x15f/0xc80 mm/gup.c:1667
 io_sqe_buffer_register fs/io_uring.c:8462 [inline]
 __io_uring_register fs/io_uring.c:9901 [inline]
 __do_sys_io_uring_register+0xeb1/0x3350 fs/io_uring.c:10000
 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

Thanks,

        tglx

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [syzbot] general protection fault in try_grab_compound_head
  2021-07-08 13:03   ` Thomas Gleixner
@ 2021-07-12 21:29     ` Sean Christopherson
  2021-07-13  1:08       ` Joao Martins
  0 siblings, 1 reply; 5+ messages in thread
From: Sean Christopherson @ 2021-07-12 21:29 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: syzbot, akpm, bp, hpa, jmattson, joro, kvm, linux-kernel,
	linux-mm, mark.rutland, masahiroy, mingo, pbonzini, peterz,
	rafael.j.wysocki, rostedt, sedat.dilek, syzkaller-bugs, vitor,
	vkuznets, wanpengli, will, x86

On Thu, Jul 08, 2021, Thomas Gleixner wrote:
> On Sat, Jul 03 2021 at 13:24, syzbot wrote:
> > syzbot has bisected this issue to:
> >
> > commit 997acaf6b4b59c6a9c259740312a69ea549cc684
> > Author: Mark Rutland <mark.rutland@arm.com>
> > Date:   Mon Jan 11 15:37:07 2021 +0000
> >
> >     lockdep: report broken irq restoration
> 
> That's the commit which makes the underlying problem visible:
> 
>        raw_local_irq_restore() called with IRQs enabled
> 
> and is triggered by this call chain:
> 
>  kvm_wait arch/x86/kernel/kvm.c:860 [inline]
>  kvm_wait+0xc3/0xe0 arch/x86/kernel/kvm.c:837

And the bug in kvm_wait() was fixed by commit f4e61f0c9add ("x86/kvm: Fix broken
irq restoration in kvm_wait").  The bisection is bad, syzbot happened into the
kvm_wait() WARN and got distracted.  The original #GP looks stable, if someone
from mm land has bandwidth.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [syzbot] general protection fault in try_grab_compound_head
  2021-07-12 21:29     ` Sean Christopherson
@ 2021-07-13  1:08       ` Joao Martins
  0 siblings, 0 replies; 5+ messages in thread
From: Joao Martins @ 2021-07-13  1:08 UTC (permalink / raw)
  To: Sean Christopherson, Mike Kravetz
  Cc: syzbot, akpm, bp, hpa, jmattson, joro, kvm, linux-kernel,
	linux-mm, mark.rutland, masahiroy, mingo, pbonzini, peterz,
	rafael.j.wysocki, rostedt, sedat.dilek, syzkaller-bugs, vitor,
	vkuznets, wanpengli, will, x86, Thomas Gleixner

On 7/12/21 10:29 PM, Sean Christopherson wrote:
> On Thu, Jul 08, 2021, Thomas Gleixner wrote:
>> On Sat, Jul 03 2021 at 13:24, syzbot wrote:
>>> syzbot has bisected this issue to:
>>>
>>> commit 997acaf6b4b59c6a9c259740312a69ea549cc684
>>> Author: Mark Rutland <mark.rutland@arm.com>
>>> Date:   Mon Jan 11 15:37:07 2021 +0000
>>>
>>>     lockdep: report broken irq restoration
>>
>> That's the commit which makes the underlying problem visible:
>>
>>        raw_local_irq_restore() called with IRQs enabled
>>
>> and is triggered by this call chain:
>>
>>  kvm_wait arch/x86/kernel/kvm.c:860 [inline]
>>  kvm_wait+0xc3/0xe0 arch/x86/kernel/kvm.c:837
> 
> And the bug in kvm_wait() was fixed by commit f4e61f0c9add ("x86/kvm: Fix broken
> irq restoration in kvm_wait").  The bisection is bad, syzbot happened into the
> kvm_wait() WARN and got distracted.  The original #GP looks stable, if someone
> from mm land has bandwidth.
> 

I've bisected this to (my) recent commit 82e5d378b0e47 ("mm/hugetlb: refactor subpage
recording").

I have this fix below and should formally submit tomorrow after more testing.
My apologies for the trouble.

	Joao

------>8------

Subject: mm/hugetlb: fix refs calculation from unaligned @vaddr

commit 82e5d378b0e47 ("mm/hugetlb: refactor subpage recording")
refactored the count of subpages but missed an edge case when @vaddr is
less than a PAGE_SIZE close to vma->vm_end. It would errousnly set @refs
to 0 and record_subpages_vmas() wouldn't set the pages array element to
its value, consequently causing the reported #GP by syzbot.

Fix it by aligning down @vaddr in @refs calculation.

Reported-by: syzbot+a3fcd59df1b372066f5a@syzkaller.appspotmail.com
Fixes: 82e5d378b0e47 ("mm/hugetlb: refactor subpage recording")
Signed-off-by: Joao Martins <joao.m.martins@oracle.com>

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index a86a58ef132d..cbc448c1a3c8 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -4949,8 +4949,9 @@ long follow_hugetlb_page(struct mm_struct *mm, struct vm_area_struct
*vma,
                        continue;
                }

-               refs = min3(pages_per_huge_page(h) - pfn_offset,
-                           (vma->vm_end - vaddr) >> PAGE_SHIFT, remainder);
+               /* [vaddr .. vm_end] may not be aligned to PAGE_SIZE */
+               refs = min3(pages_per_huge_page(h) - pfn_offset, remainder,
+                   (vma->vm_end - ALIGN_DOWN(vaddr, PAGE_SIZE)) >> PAGE_SHIFT);

                if (pages || vmas)
                        record_subpages_vmas(mem_map_offset(page, pfn_offset),

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-07-13  1:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-03 15:41 [syzbot] general protection fault in try_grab_compound_head syzbot
2021-07-03 20:24 ` syzbot
2021-07-08 13:03   ` Thomas Gleixner
2021-07-12 21:29     ` Sean Christopherson
2021-07-13  1:08       ` Joao Martins

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).