perf: Break deadlock involving exec_update_mutex
authorpeterz@infradead.org <peterz@infradead.org>
Fri, 28 Aug 2020 12:37:20 +0000 (14:37 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 9 Jan 2021 12:46:24 +0000 (13:46 +0100)
commit2cded5a3cc38545472a717b16402cbde1c1712b5
tree0b8418e411dbefaac2a499a18900cb79d194e33a
parent36cf9ae54b0ead0daab7701a994de3dcd9ef605d
perf: Break deadlock involving exec_update_mutex

[ Upstream commit 78af4dc949daaa37b3fcd5f348f373085b4e858f ]

Syzbot reported a lock inversion involving perf. The sore point being
perf holding exec_update_mutex() for a very long time, specifically
across a whole bunch of filesystem ops in pmu::event_init() (uprobes)
and anon_inode_getfile().

This then inverts against procfs code trying to take
exec_update_mutex.

Move the permission checks later, such that we need to hold the mutex
over less code.

Reported-by: syzbot+db9cdf3dd1f64252c6ef@syzkaller.appspotmail.com
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/events/core.c