linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* sunrpc: what prevents an xprt from being freed before task_cleanup runs?
@ 2010-08-03 17:24 Jeff Layton
  2010-08-03 18:40 ` Trond Myklebust
  0 siblings, 1 reply; 9+ messages in thread
From: Jeff Layton @ 2010-08-03 17:24 UTC (permalink / raw)
  To: linux-nfs; +Cc: netdev, bfields

We got a report recently about a panic in RHEL5 (2.6.18 based kernel).
The problem appears to be that a task_cleanup workqueue job ran and got
passed a pointer to an xprt that had been freed. The bug is here in
case anyone is interested in the details:

    https://bugzilla.redhat.com/show_bug.cgi?id=611938

The situation seems to be pretty difficult to reproduce, but I don't
see anything that's intended to ensure that this doesn't occur in RHEL5
or mainline. The task_cleanup workqueue job doesn't hold a reference to
the xprt, and the job isn't canceled when the xprt is torn down.

Bruce had a look and suggested that we may need something like the
patch below (pasted in, so it probably won't apply correctly). I've
tested a backported version of it on RHEL5 and it seems to work fine.

Is it reasonable to cancel task_cleanup when destroying the xprt? Or,
am I missing something that should prevent this situation in mainline
(and perhaps isn't in RHEL5's kernel).

Any help is appreciated...

-----------------------------[snip]---------------------------------
diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c
index dcd0132..2a1f664 100644
--- a/net/sunrpc/xprt.c
+++ b/net/sunrpc/xprt.c
@@ -1129,6 +1129,7 @@ static void xprt_destroy(struct kref *kref)
  rpc_destroy_wait_queue(&xprt->sending);
  rpc_destroy_wait_queue(&xprt->resend);
  rpc_destroy_wait_queue(&xprt->backlog);
+ cancel_work_sync(&xprt->task_cleanup);
  /*
   * Tear down transport state and free the rpc_xprt
   */
-----------------------------[snip]---------------------------------

Thanks,
-- 
Jeff Layton <jlayton@redhat.com>

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2010-08-03 21:32 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-03 17:24 sunrpc: what prevents an xprt from being freed before task_cleanup runs? Jeff Layton
2010-08-03 18:40 ` Trond Myklebust
2010-08-03 18:48   ` J. Bruce Fields
2010-08-03 18:56     ` Trond Myklebust
2010-08-03 19:18       ` J. Bruce Fields
2010-08-03 18:49   ` Trond Myklebust
2010-08-03 21:22     ` [PATCH] SUNRPC: prevent task_cleanup running on freed xprt J. Bruce Fields
2010-08-03 21:32       ` Trond Myklebust
2010-08-03 18:59   ` sunrpc: what prevents an xprt from being freed before task_cleanup runs? Jeff Layton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).