Skip to content

auth_gss: Fix netns refcount leaks when use-gss-proxy==1

Wang Hai linux-nfs lkml netdev 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 13 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2net: Modify unix_stream_connect to not reference count the netns of kernel socketsnet/unix/af_unix.c+2 -11 reply
2/2auth_gss: Fix deadlock that blocks rpcsec_gss_exit_net when use-gss-proxy==1include/linux/sunrpc/clnt.h include/linux/sunrpc/xprt.h net/sunrpc/auth_gss/gss_rpc_upcall.c +5 more+23 -1012 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH net 0/2] auth_gss: Fix netns refcount leaks when use-gss-proxy==1

When use-gss-proxy is set to 1, write_gssp() creates a rpc client in gssp_rpc_create(), this increases netns refcount by 2 [1], these refcounts are supposed to be released in rpcsec_gss_exit_net(), but it will never happen because rpcsec_gss_exit_net() is triggered only when netns refcount gets to 0, specifically:

     refcount=0 -> cleanup_net() -> ops_exit_list -> rpcsec_gss_exit_net

It is a deadlock situation here, refcount will never get to 0 unless rpcsec_gss_exit_net() is called.

[1]
SyS_write
vfs_write
proc_reg_write
write_gssp
set_gssp_clnt
gssp_rpc_create
rpc_create
xprt_create_transport
xs_setup_local
xs_setup_xprt
xprt_alloc // get net refcount
xs_local_setup_socket
unix_create kernel_connect // get net refcount

In this case, the net refcount shouldn't be increased when creating rpc client, otherwise it will lead to deadlock.

This patchset removes the increased netns reference count.

Wang Hai (2):
net: Modify unix_stream_connect to not reference count the netns of
kernel sockets
auth_gss: Fix deadlock that blocks rpcsec_gss_exit_net when

    use-gss-proxy==1
 include/linux/sunrpc/clnt.h                |  1 +
 include/linux/sunrpc/xprt.h                |  6 ++++--
 net/sunrpc/auth_gss/gss_rpc_upcall.c       |  3 ++-
 net/sunrpc/clnt.c                          |  2 ++
 net/sunrpc/xprt.c                          | 13 +++++++++----
 net/sunrpc/xprtrdma/svc_rdma_backchannel.c |  2 +-
 net/sunrpc/xprtrdma/transport.c            |  2 +-
 net/sunrpc/xprtsock.c                      |  4 +++-
 net/unix/af_unix.c                         |  3 ++-
 9 files changed, 25 insertions(+), 11 deletions(-)
Signature · 1 line
2.17.1