summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAttila Kovacs <attila.kovacs@cfa.harvard.edu>2022-07-28 09:14:24 -0400
committerSteve Dickson <steved@redhat.com>2022-07-28 09:14:24 -0400
commit667ce638454d0995170dd8e6e0668ada733d72e7 (patch)
treedf566325060d4f93f56b99bfdd78d5c31bf7fcbc
parent3f2a5459fb00c2f529d68a4a0fd7f367a77fa65a (diff)
downloadti-rpc-667ce638454d0995170dd8e6e0668ada733d72e7.tar.gz
SUNRPC: mutexed access blacklist_read state variable.libtirpc-1-3-3-rc4
bindresvport()_sa(), in bidresvport.c checks blacklist_read w/o mutex before calling load_blacklist() which changes blacklist_read() also unmutexed. Clearly, the point is to read the blacklist only once on the first call, but because the checking whether the blacklist is loaded is not mutexed, more than one thread may race to load the blacklist concurrently, which of course can jumble the list because of the race condition. The fix simply moves the checking within the mutexed aread of the code to eliminate the race condition. Signed-off-by: Steve Dickson <steved@redhat.com>
-rw-r--r--src/bindresvport.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/bindresvport.c b/src/bindresvport.c
index ef9b345..5c0ddcf 100644
--- a/src/bindresvport.c
+++ b/src/bindresvport.c
@@ -164,10 +164,11 @@ bindresvport_sa(sd, sa)
int endport = ENDPORT;
int i;
+ mutex_lock(&port_lock);
+
if (!blacklist_read)
load_blacklist();
- mutex_lock(&port_lock);
nports = ENDPORT - startport + 1;
if (sa == NULL) {