public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Hillf Danton <hdanton@sina.com>, Song Liu <songliubraving@fb.com>,
	Peter Zijlstra <peterz@infradead.org>
Cc: Namhyung Kim <namhyung@kernel.org>,
	syzbot <syzbot+b804f902bbb6bcf290cb@syzkaller.appspotmail.com>,
	Srikar Dronamraju <srikar@linux.vnet.ibm.com>,
	Greg KH <gregkh@linuxfoundation.org>,
	linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: perf_mmap_close() -> put_event() -> event.destroy() can deadlock
Date: Tue, 6 Apr 2021 19:23:23 +0200	[thread overview]
Message-ID: <20210406172322.GA13270@redhat.com> (raw)
In-Reply-To: <20210402074636.1270-1-hdanton@sina.com>

Song, Peter, please take a look.

On 04/02, Hillf Danton wrote:
>
> On Thu, 1 Apr 2021 12:53:26  Oleg Nesterov wrote:
> >
> >Hmm, please correct me, but I don't think so. I think mmap_lock -> dup_mmap_sem
> >is not possible.
> >
> Given perf_trace_destroy() in the report, it is a couple of steps in the
> subsequent call chain that it likely takes to reach uprobe_unregister().
>
> perf_trace_destroy()
>   perf_trace_event_unreg(p_event)
>     tp_event->class->reg(tp_event, TRACE_REG_PERF_UNREGISTER, NULL);
>       trace_uprobe_register()

Well, this is not possible, perf_trace_destroy() is only used by perf_tracepoint
pmu. But you are right anyway, event.destroy == perf_uprobe_destroy can lead to
uprobe_unregister(). Thanks.

-------------------------------------------------------------------------------

So. perf_mmap_close() does put_event(event) with mm->mmap_lock held. This can
deadlock if event->destroy == perf_uprobe_destroy: perf_trace_event_close/unreg
takes dup_mmap_sem.


perf_mmap_close() was added by 9bb5d40cd93c9 ("perf: Fix mmap() accounting hole")
and this commit doesn't look right anyway, I'll write another email. However, it
seems that this particular problem was added later by 33ea4b24277b0 ("perf/core:
Implement the 'perf_uprobe' PMU").

Oleg.


  parent reply	other threads:[~2021-04-06 17:23 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-26 10:29 [syzbot] possible deadlock in register_for_each_vma syzbot
     [not found] ` <20210327042150.7460-1-hdanton@sina.com>
2021-03-27 17:53   ` Oleg Nesterov
     [not found]   ` <20210328025217.7312-1-hdanton@sina.com>
2021-03-31 16:59     ` Oleg Nesterov
2021-03-31 20:18       ` Song Liu
     [not found]     ` <20210401092907.1098-1-hdanton@sina.com>
2021-04-01 10:53       ` Oleg Nesterov
     [not found]       ` <20210402074636.1270-1-hdanton@sina.com>
2021-04-06 17:23         ` Oleg Nesterov [this message]
2021-04-06 17:43           ` perf_buffer.event_list is not RCU-safe? Oleg Nesterov
2021-04-07  7:50             ` Peter Zijlstra
2021-04-07 12:30               ` Oleg Nesterov

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=20210406172322.GA13270@redhat.com \
    --to=oleg@redhat.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hdanton@sina.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=songliubraving@fb.com \
    --cc=srikar@linux.vnet.ibm.com \
    --cc=syzbot+b804f902bbb6bcf290cb@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