* Re: [PATCH v4 02/16] freezer: add unsafe versions of freezable helpers for CIFS [not found] ` <CAMbhsRQ1i_dFctwjkqjg3=GJdEc8ReEDk=NnEFEXj8u3MaEqDA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> @ 2013-05-07 17:52 ` Colin Cross [not found] ` <1367949125-21809-1-git-send-email-ccross-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org> 0 siblings, 1 reply; 2+ messages in thread From: Colin Cross @ 2013-05-07 17:52 UTC (permalink / raw) To: linux-kernel-u79uwXL29TY76Z2rM5mHXA Cc: Pavel Machek, Rafael J. Wysocki, Peter Zijlstra, Ingo Molnar, Andrew Morton, Mandeep Singh Baines, Colin Cross, Oleg Nesterov, linux-nfs-u79uwXL29TY76Z2rM5mHXA, linux-pm-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA, Linus Torvalds, Tejun Heo, Steve French, Len Brown, linux-cifs-u79uwXL29TY76Z2rM5mHXA, samba-technical-w/Ol4Ecudpl8XjKLYN78aQ CIFS calls wait_event_freezekillable_unsafe with a VFS lock held, which is unsafe and will cause lockdep warnings when 6aa9707 "lockdep: check that no locks held at freeze time" is reapplied (it was reverted in dbf520a). CIFS shouldn't be doing this, but it has long-running syscalls that must hold a lock but also shouldn't block suspend. Until CIFS freeze handling is rewritten to use a signal to exit out of the critical section, add a new wait_event_freezekillable_unsafe helper that will not run the lockdep test when 6aa9707 is reapplied, and call it from CIFS. In practice the likley result of holding the lock while freezing is that a second task blocked on the lock will never freeze, aborting suspend, but it is possible to manufacture a case using the cgroup freezer, the lock, and the suspend freezer to create a deadlock. Silencing the lockdep warning here will allow problems to be found in other drivers that may have a more serious deadlock risk, and prevent new problems from being added. Acked-by: Pavel Machek <pavel-+ZI9xUNit7I@public.gmane.org> Signed-off-by: Colin Cross <ccross-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org> --- v4: Corrected to include CIFS wait_for_response hunk. The rest of this series is still at v3. fs/cifs/transport.c | 2 +- include/linux/freezer.h | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c index 1a52868..e7f22f8 100644 --- a/fs/cifs/transport.c +++ b/fs/cifs/transport.c @@ -452,7 +452,7 @@ wait_for_response(struct TCP_Server_Info *server, struct mid_q_entry *midQ) { int error; - error = wait_event_freezekillable(server->response_q, + error = wait_event_freezekillable_unsafe(server->response_q, midQ->mid_state != MID_REQUEST_SUBMITTED); if (error < 0) return -ERESTARTSYS; diff --git a/include/linux/freezer.h b/include/linux/freezer.h index 5b31e21c..d3c038e 100644 --- a/include/linux/freezer.h +++ b/include/linux/freezer.h @@ -212,6 +212,16 @@ static inline bool freezer_should_skip(struct task_struct *p) __retval; \ }) +/* DO NOT ADD ANY NEW CALLERS OF THIS FUNCTION */ +#define wait_event_freezekillable_unsafe(wq, condition) \ +({ \ + int __retval; \ + freezer_do_not_count(); \ + __retval = wait_event_killable(wq, (condition)); \ + freezer_count_unsafe(); \ + __retval; \ +}) + #define wait_event_freezable(wq, condition) \ ({ \ int __retval; \ @@ -277,6 +287,9 @@ static inline void set_freezable(void) {} #define wait_event_freezekillable(wq, condition) \ wait_event_killable(wq, condition) +#define wait_event_freezekillable_unsafe(wq, condition) \ + wait_event_killable(wq, condition) + #endif /* !CONFIG_FREEZER */ #endif /* FREEZER_H_INCLUDED */ -- 1.8.2.1 ^ permalink raw reply related [flat|nested] 2+ messages in thread
[parent not found: <1367949125-21809-1-git-send-email-ccross-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org>]
* Re: [PATCH v4 02/16] freezer: add unsafe versions of freezable helpers for CIFS [not found] ` <1367949125-21809-1-git-send-email-ccross-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org> @ 2013-05-07 18:11 ` Jeff Layton 0 siblings, 0 replies; 2+ messages in thread From: Jeff Layton @ 2013-05-07 18:11 UTC (permalink / raw) To: Colin Cross Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA, Pavel Machek, Rafael J. Wysocki, Peter Zijlstra, Ingo Molnar, Andrew Morton, Mandeep Singh Baines, Oleg Nesterov, linux-nfs-u79uwXL29TY76Z2rM5mHXA, linux-pm-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA, Linus Torvalds, Tejun Heo, Steve French, Len Brown, linux-cifs-u79uwXL29TY76Z2rM5mHXA, samba-technical-w/Ol4Ecudpl8XjKLYN78aQ On Tue, 7 May 2013 10:52:05 -0700 Colin Cross <ccross-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org> wrote: > CIFS calls wait_event_freezekillable_unsafe with a VFS lock held, > which is unsafe and will cause lockdep warnings when 6aa9707 > "lockdep: check that no locks held at freeze time" is reapplied > (it was reverted in dbf520a). CIFS shouldn't be doing this, but > it has long-running syscalls that must hold a lock but also > shouldn't block suspend. Until CIFS freeze handling is rewritten > to use a signal to exit out of the critical section, add a new > wait_event_freezekillable_unsafe helper that will not run the > lockdep test when 6aa9707 is reapplied, and call it from CIFS. > > In practice the likley result of holding the lock while freezing > is that a second task blocked on the lock will never freeze, > aborting suspend, but it is possible to manufacture a case using > the cgroup freezer, the lock, and the suspend freezer to create > a deadlock. Silencing the lockdep warning here will allow > problems to be found in other drivers that may have a more > serious deadlock risk, and prevent new problems from being added. > > Acked-by: Pavel Machek <pavel-+ZI9xUNit7I@public.gmane.org> > Signed-off-by: Colin Cross <ccross-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org> > --- > v4: > Corrected to include CIFS wait_for_response hunk. > The rest of this series is still at v3. > > fs/cifs/transport.c | 2 +- > include/linux/freezer.h | 13 +++++++++++++ > 2 files changed, 14 insertions(+), 1 deletion(-) > > diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c > index 1a52868..e7f22f8 100644 > --- a/fs/cifs/transport.c > +++ b/fs/cifs/transport.c > @@ -452,7 +452,7 @@ wait_for_response(struct TCP_Server_Info *server, struct mid_q_entry *midQ) > { > int error; > > - error = wait_event_freezekillable(server->response_q, > + error = wait_event_freezekillable_unsafe(server->response_q, > midQ->mid_state != MID_REQUEST_SUBMITTED); > if (error < 0) > return -ERESTARTSYS; > diff --git a/include/linux/freezer.h b/include/linux/freezer.h > index 5b31e21c..d3c038e 100644 > --- a/include/linux/freezer.h > +++ b/include/linux/freezer.h > @@ -212,6 +212,16 @@ static inline bool freezer_should_skip(struct task_struct *p) > __retval; \ > }) > > +/* DO NOT ADD ANY NEW CALLERS OF THIS FUNCTION */ > +#define wait_event_freezekillable_unsafe(wq, condition) \ > +({ \ > + int __retval; \ > + freezer_do_not_count(); \ > + __retval = wait_event_killable(wq, (condition)); \ > + freezer_count_unsafe(); \ > + __retval; \ > +}) > + > #define wait_event_freezable(wq, condition) \ > ({ \ > int __retval; \ > @@ -277,6 +287,9 @@ static inline void set_freezable(void) {} > #define wait_event_freezekillable(wq, condition) \ > wait_event_killable(wq, condition) > > +#define wait_event_freezekillable_unsafe(wq, condition) \ > + wait_event_killable(wq, condition) > + > #endif /* !CONFIG_FREEZER */ > > #endif /* FREEZER_H_INCLUDED */ Looks fine... Reviewed-by: Jeff Layton <jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> ^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-05-07 18:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CAMbhsRQ1i_dFctwjkqjg3=GJdEc8ReEDk=NnEFEXj8u3MaEqDA@mail.gmail.com>
[not found] ` <CAMbhsRQ1i_dFctwjkqjg3=GJdEc8ReEDk=NnEFEXj8u3MaEqDA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-05-07 17:52 ` [PATCH v4 02/16] freezer: add unsafe versions of freezable helpers for CIFS Colin Cross
[not found] ` <1367949125-21809-1-git-send-email-ccross-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org>
2013-05-07 18:11 ` Jeff Layton
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox