linux/net/sunrpc
NeilBrown ed2849d3ec sunrpc: prevent use-after-free on clearing XPT_BUSY
When an xprt is created, it has a refcount of 1, and XPT_BUSY is set.
The refcount is *not* owned by the thread that created the xprt
(as is clear from the fact that creators never put the reference).
Rather, it is owned by the absence of XPT_DEAD.  Once XPT_DEAD is set,
(And XPT_BUSY is clear) that initial reference is dropped and the xprt
can be freed.

So when a creator clears XPT_BUSY it is dropping its only reference and
so must not touch the xprt again.

However svc_recv, after calling ->xpo_accept (and so getting an XPT_BUSY
reference on a new xprt), calls svc_xprt_recieved.  This clears
XPT_BUSY and then svc_xprt_enqueue - this last without owning a reference.
This is dangerous and has been seen to leave svc_xprt_enqueue working
with an xprt containing garbage.

So we need to hold an extra counted reference over that call to
svc_xprt_received.

For safety, any time we clear XPT_BUSY and then use the xprt again, we
first get a reference, and the put it again afterwards.

Note that svc_close_all does not need this extra protection as there are
no threads running, and the final free can only be called asynchronously
from such a thread.

Signed-off-by: NeilBrown <neilb@suse.de>
Cc: stable@kernel.org
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
2010-12-07 20:39:55 -05:00
..
auth_gss Merge branch 'for-2.6.37' of git://linux-nfs.org/~bfields/linux 2010-10-26 09:55:25 -07:00
xprtrdma
addr.c
auth_generic.c
auth_null.c
auth_unix.c
auth.c Merge branch 'for-2.6.37' of git://linux-nfs.org/~bfields/linux 2010-10-26 09:55:25 -07:00
backchannel_rqst.c
bc_svc.c
cache.c Merge branch 'for-2.6.37' of git://linux-nfs.org/~bfields/linux 2010-10-26 09:55:25 -07:00
clnt.c SUNRPC: Fix an infinite loop in call_refresh/call_refreshresult 2010-11-22 13:22:39 -05:00
Kconfig
Makefile
netns.h
rpc_pipe.c convert get_sb_single() users 2010-10-29 04:16:28 -04:00
rpcb_clnt.c Merge branch 'for-2.6.37' of git://linux-nfs.org/~bfields/linux 2010-10-26 09:55:25 -07:00
sched.c Merge branch 'nfs-for-2.6.37' of git://git.linux-nfs.org/projects/trondmy/nfs-2.6 2010-10-25 13:48:29 -07:00
socklib.c
stats.c SUNRPC: Simplify rpc_alloc_iostats by removing pointless local variable 2010-11-16 11:58:51 -05:00
sunrpc_syms.c
sunrpc.h
svc_xprt.c sunrpc: prevent use-after-free on clearing XPT_BUSY 2010-12-07 20:39:55 -05:00
svc.c
svcauth_unix.c
svcauth.c
svcsock.c svcrpc: svc_tcp_sendto XPT_DEAD check is redundant 2010-10-25 17:59:34 -04:00
sysctl.c
timer.c
xdr.c SUNRPC: Add a helper function xdr_inline_peek 2010-10-23 15:27:32 -04:00
xprt.c
xprtsock.c Merge branch 'for-2.6.37' of git://linux-nfs.org/~bfields/linux 2010-10-26 09:55:25 -07:00