diff options
author | Vitaliy Makkoveev <mvs@cvs.openbsd.org> | 2021-11-17 22:56:20 +0000 |
---|---|---|
committer | Vitaliy Makkoveev <mvs@cvs.openbsd.org> | 2021-11-17 22:56:20 +0000 |
commit | c6a370580753cdef2a818e447ad4911083eeae8e (patch) | |
tree | 6b56d156d487b3480e1a411cf57ce45d6591e12c | |
parent | c298c050bef4d7b9e876718ae298372db53e7980 (diff) |
When unp_connect() releases both solock() and vnode(9) locks the socket we
were connected could be closed by concurrent thread. Check connection
state and return ECONNREFUSED if the connection was lost.
ok bluhm@
-rw-r--r-- | sys/kern/uipc_usrreq.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c index 2db67d7c619..1c0a4454458 100644 --- a/sys/kern/uipc_usrreq.c +++ b/sys/kern/uipc_usrreq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_usrreq.c,v 1.157 2021/11/16 08:56:19 mvs Exp $ */ +/* $OpenBSD: uipc_usrreq.c,v 1.158 2021/11/17 22:56:19 mvs Exp $ */ /* $NetBSD: uipc_usrreq.c,v 1.18 1996/02/09 19:00:50 christos Exp $ */ /* @@ -716,6 +716,13 @@ unlock: solock(so); unp->unp_flags &= ~UNP_CONNECTING; + /* + * The peer socket could be closed by concurrent thread + * when `so' and `vp' are unlocked. + */ + if (error == 0 && unp->unp_conn == NULL) + error = ECONNREFUSED; + return (error); } |