git: 6d06bc688eb5 - main - libc clnt_com_create: relock rpcsoc_lock earlier when port is obtained from portmapper
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 09 Jan 2022 05:36:11 UTC
The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=6d06bc688eb5a9f9e389b69c388d591a40edc422 commit 6d06bc688eb5a9f9e389b69c388d591a40edc422 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2022-01-09 05:09:22 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2022-01-09 05:36:06 +0000 libc clnt_com_create: relock rpcsoc_lock earlier when port is obtained from portmapper Otherwise on mapper failure we goto error handler which expect rpscoc_lock owned, but we do not. PR: 261051 Reported by: RyanCai <ryancaicse@gmail.com> Sponsored by: The FreeBSD Foundation MFC after: 1 week --- lib/libc/rpc/rpc_soc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libc/rpc/rpc_soc.c b/lib/libc/rpc/rpc_soc.c index 1e5cd86d7ed4..ae23442e9a16 100644 --- a/lib/libc/rpc/rpc_soc.c +++ b/lib/libc/rpc/rpc_soc.c @@ -120,11 +120,11 @@ clnt_com_create(struct sockaddr_in *raddr, rpcprog_t prog, rpcvers_t vers, int * proto = strcmp(tp, "udp") == 0 ? IPPROTO_UDP : IPPROTO_TCP; sport = pmap_getport(raddr, (u_long)prog, (u_long)vers, proto); + mutex_lock(&rpcsoc_lock); /* pmap_getport is recursive */ if (sport == 0) { goto err; } raddr->sin_port = htons(sport); - mutex_lock(&rpcsoc_lock); /* pmap_getport is recursive */ } /* Transform sockaddr_in to netbuf */