Skip to content

Commit

Permalink
s/epoll: robustify irq safety with lockdep_assert_irqs_enabled()
Browse files Browse the repository at this point in the history
Sprinkle lockdep_assert_irqs_enabled() checks in the functions that do not
save and restore interrupts when dealing with the ep->wq.lock.  These are
ep_scan_ready_list() and those called by epoll_ctl(): ep_insert, ep_modify
and ep_remove.

[[email protected]: remove too-obvious comments]
Link: http://lkml.kernel.org/r/20180721183127.3busfa335zlcjeox@linux-r8p5
Signed-off-by: Davidlohr Bueso <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Davidlohr Bueso authored and torvalds committed Aug 22, 2018
1 parent 304b18b commit 92e6417
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions fs/eventpoll.c
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,8 @@ static __poll_t ep_scan_ready_list(struct eventpoll *ep,
struct epitem *epi, *nepi;
LIST_HEAD(txlist);

lockdep_assert_irqs_enabled();

/*
* We need to lock this because we could be hit by
* eventpoll_release_file() and epoll_ctl().
Expand Down Expand Up @@ -764,6 +766,8 @@ static int ep_remove(struct eventpoll *ep, struct epitem *epi)
{
struct file *file = epi->ffd.file;

lockdep_assert_irqs_enabled();

/*
* Removes poll wait queue hooks.
*/
Expand Down Expand Up @@ -1412,6 +1416,8 @@ static int ep_insert(struct eventpoll *ep, const struct epoll_event *event,
struct epitem *epi;
struct ep_pqueue epq;

lockdep_assert_irqs_enabled();

user_watches = atomic_long_read(&ep->user->epoll_watches);
if (unlikely(user_watches >= max_user_watches))
return -ENOSPC;
Expand Down Expand Up @@ -1540,6 +1546,8 @@ static int ep_modify(struct eventpoll *ep, struct epitem *epi,
int pwake = 0;
poll_table pt;

lockdep_assert_irqs_enabled();

init_poll_funcptr(&pt, NULL);

/*
Expand Down

0 comments on commit 92e6417

Please sign in to comment.