Commit 3942302e authored by NeilBrown's avatar NeilBrown Committed by J. Bruce Fields

sunrpc: svc_sock_names should hold ref to socket being closed.

Currently svc_sock_names calls svc_close_xprt on a svc_sock to
which it does not own a reference.
As soon as svc_close_xprt sets XPT_CLOSE, the socket could be
freed by a separate thread (though this is a very unlikely race).

It is safer to hold a reference while calling svc_close_xprt.
Signed-off-by: default avatarNeilBrown <neilb@suse.de>
Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
parent 7c96aef7
...@@ -324,19 +324,21 @@ int svc_sock_names(struct svc_serv *serv, char *buf, const size_t buflen, ...@@ -324,19 +324,21 @@ int svc_sock_names(struct svc_serv *serv, char *buf, const size_t buflen,
len = onelen; len = onelen;
break; break;
} }
if (toclose && strcmp(toclose, buf + len) == 0) if (toclose && strcmp(toclose, buf + len) == 0) {
closesk = svsk; closesk = svsk;
else svc_xprt_get(&closesk->sk_xprt);
} else
len += onelen; len += onelen;
} }
spin_unlock_bh(&serv->sv_lock); spin_unlock_bh(&serv->sv_lock);
if (closesk) if (closesk) {
/* Should unregister with portmap, but you cannot /* Should unregister with portmap, but you cannot
* unregister just one protocol... * unregister just one protocol...
*/ */
svc_close_xprt(&closesk->sk_xprt); svc_close_xprt(&closesk->sk_xprt);
else if (toclose) svc_xprt_put(&closesk->sk_xprt);
} else if (toclose)
return -ENOENT; return -ENOENT;
return len; return len;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment