Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F109801922
D48677.id149952.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D48677.id149952.diff
View Options
diff --git a/sys/rpc/rpcsec_tls/rpctls_impl.c b/sys/rpc/rpcsec_tls/rpctls_impl.c
--- a/sys/rpc/rpcsec_tls/rpctls_impl.c
+++ b/sys/rpc/rpcsec_tls/rpctls_impl.c
@@ -228,6 +228,35 @@
return (error);
}
+/* Error handling for both client and server failed RPC upcalls. */
+static void
+rpctls_rpc_failed(struct upsock *ups, struct socket *so)
+{
+
+ mtx_lock(&rpctls_lock);
+ if (RB_FIND(upsock_t, &upcall_sockets, ups)) {
+ struct upsock *removed __diagused;
+
+ removed = RB_REMOVE(upsock_t, &upcall_sockets, ups);
+ mtx_unlock(&rpctls_lock);
+ MPASS(removed == ups);
+ /*
+ * Do a shutdown on the socket, since the daemon is
+ * probably stuck in SSL_accept() trying to read the
+ * socket. Do not soclose() the socket, since the
+ * daemon will close() the socket after SSL_accept()
+ * returns an error.
+ */
+ soshutdown(so, SHUT_RD);
+ } else {
+ /*
+ * The daemon has taken the socket from the tree, but
+ * failed to do the handshake.
+ */
+ mtx_unlock(&rpctls_lock);
+ }
+}
+
/* Do an upcall for a new socket connect using TLS. */
enum clnt_stat
rpctls_connect(CLIENT *newclient, char *certname, struct socket *so,
@@ -270,34 +299,11 @@
arg.socookie = (uintptr_t)so;
stat = rpctlscd_connect_2(&arg, &res, cl);
if (stat == RPC_SUCCESS) {
-#ifdef INVARIANTS
MPASS((RB_FIND(upsock_t, &upcall_sockets, &ups) == NULL));
-#endif
- *reterr = res.reterr;
- } else {
- mtx_lock(&rpctls_lock);
- if (RB_FIND(upsock_t, &upcall_sockets, &ups)) {
- struct upsock *removed __diagused;
- removed = RB_REMOVE(upsock_t, &upcall_sockets, &ups);
- mtx_unlock(&rpctls_lock);
- MPASS(removed == &ups);
- /*
- * Do a shutdown on the socket, since the daemon is
- * probably stuck in SSL_accept() trying to read the
- * socket. Do not soclose() the socket, since the
- * daemon will close() the socket after SSL_accept()
- * returns an error.
- */
- soshutdown(so, SHUT_RD);
- } else {
- /*
- * The daemon has taken the socket from the tree, but
- * failed to do the handshake.
- */
- mtx_unlock(&rpctls_lock);
- }
- }
+ *reterr = res.reterr;
+ } else
+ rpctls_rpc_failed(&ups, so);
/* Unblock reception. */
CLNT_CONTROL(newclient, CLSET_BLOCKRCV, &(int){0});
@@ -397,9 +403,8 @@
arg.socookie = (uintptr_t)xprt->xp_socket;
stat = rpctlssd_connect_2(&arg, &res, cl);
if (stat == RPC_SUCCESS) {
-#ifdef INVARIANTS
MPASS((RB_FIND(upsock_t, &upcall_sockets, &ups) == NULL));
-#endif
+
*flags = res.flags;
if ((*flags & (RPCTLS_FLAGS_CERTUSER |
RPCTLS_FLAGS_DISABLED)) == RPCTLS_FLAGS_CERTUSER) {
@@ -410,30 +415,8 @@
for (i = 0; i < *ngrps; i++)
*gidp++ = *gidv++;
}
- } else {
- mtx_lock(&rpctls_lock);
- if (RB_FIND(upsock_t, &upcall_sockets, &ups)) {
- struct upsock *removed __diagused;
-
- removed = RB_REMOVE(upsock_t, &upcall_sockets, &ups);
- mtx_unlock(&rpctls_lock);
- MPASS(removed == &ups);
- /*
- * Do a shutdown on the socket, since the daemon is
- * probably stuck in SSL_accept() trying to read the
- * socket. Do not soclose() the socket, since the
- * daemon will close() the socket after SSL_accept()
- * returns an error.
- */
- soshutdown(xprt->xp_socket, SHUT_RD);
- } else {
- /*
- * The daemon has taken the socket from the tree, but
- * failed to do the handshake.
- */
- mtx_unlock(&rpctls_lock);
- }
- }
+ } else
+ rpctls_rpc_failed(&ups, xprt->xp_socket);
mem_free(res.gid.gid_val, 0);
return (stat);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Feb 10, 5:43 PM (5 h, 22 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16167591
Default Alt Text
D48677.id149952.diff (3 KB)
Attached To
Mode
D48677: rpcsec_tls: merge RPC failure for rpctls_connect() and rpctls_server()
Attached
Detach File
Event Timeline
Log In to Comment