lkml.org 
[lkml]   [2023]   [Nov]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [syzbot] [kernel?] inconsistent lock state in ptrace_attach
On Fri, Nov 17, 2023 at 10:38:30AM +0100, Oleg Nesterov wrote:
> On 11/17, Peter Zijlstra wrote:
> >
> > On Fri, Nov 17, 2023 at 12:49:04AM -0800, syzbot wrote:
> > > syzbot has bisected this issue to:
> > >
> > > commit 2d25a889601d2fbc87ec79b30ea315820f874b78
> > > Author: Peter Zijlstra <peterz@infradead.org>
> > > Date: Sun Sep 17 11:24:21 2023 +0000
> > >
> > > ptrace: Convert ptrace_attach() to use lock guards
> > >
> > > bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=132b7d84e80000
> > > start commit: f31817cbcf48 Add linux-next specific files for 20231116
> > > git tree: linux-next
> > > final oops: https://syzkaller.appspot.com/x/report.txt?x=10ab7d84e80000
> > > console output: https://syzkaller.appspot.com/x/log.txt?x=172b7d84e80000
> > > kernel config: https://syzkaller.appspot.com/x/.config?x=f59345f1d0a928c
> > > dashboard link: https://syzkaller.appspot.com/bug?extid=cbb25bb9b4d29a773985
> > > syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1014d797680000
> > > C reproducer: https://syzkaller.appspot.com/x/repro.c?x=11b1ec67680000
> > >
> > > Reported-by: syzbot+cbb25bb9b4d29a773985@syzkaller.appspotmail.com
> > > Fixes: 2d25a889601d ("ptrace: Convert ptrace_attach() to use lock guards")
> >
> > Hurmph, let me pull that patch from tip and go have a look. Thanks!
>
> I guess
>
> scoped_guard (write_lock, &tasklist_lock)
>
> is not right... this needs write_lock_irq().
>
> I didn't notice this when I reviewed this patch.

Yep, that seems to be the case.

I keep forgetting how to tell the syscall robot to test the below delta,
but I'll push the ammended commit to my staging tree and we'll see what
happens.

---
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -461,7 +461,7 @@ static int ptrace_attach(struct task_str
return retval;
}

- scoped_guard (write_lock, &tasklist_lock) {
+ scoped_guard (write_lock_irq, &tasklist_lock) {
if (unlikely(task->exit_state))
return -EPERM;
if (task->ptrace)
\
 
 \ /
  Last update: 2023-11-20 14:02    [W:0.048 / U:0.572 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site