diff options
| author | Xavi Hernandez <xhernandez@redhat.com> | 2018-03-09 22:48:33 +0100 |
|---|---|---|
| committer | Shyamsundar Ranganathan <srangana@redhat.com> | 2018-03-20 10:59:57 +0000 |
| commit | 2bb0623cfbeca29264a1b8102c738851fa0d9202 (patch) | |
| tree | a2adc31ef32a1294443ea66cdebe7147440749d3 /xlators/protocol/client/src/client-handshake.c | |
| parent | a644d52a4fe000827020b28736062a54c9a91b44 (diff) | |
protocol/client: fix memory corruption
There was an issue when some accesses to saved_fds list were
protected by the wrong mutex (lock instead of fd_lock).
Additionally, the retrieval of fdctx from fd's context and any
checks done on it have also been protected by fd_lock to avoid
fdctx to become outdated just after retrieving it.
Backport of:
> BUG: 1553129
Change-Id: If2910508bcb7d1ff23debb30291391f00903a6fe
BUG: 1554235
Signed-off-by: Xavi Hernandez <xhernandez@redhat.com>
Diffstat (limited to 'xlators/protocol/client/src/client-handshake.c')
| -rw-r--r-- | xlators/protocol/client/src/client-handshake.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/xlators/protocol/client/src/client-handshake.c b/xlators/protocol/client/src/client-handshake.c index 74c601bbcbd..5c0b4750e2e 100644 --- a/xlators/protocol/client/src/client-handshake.c +++ b/xlators/protocol/client/src/client-handshake.c @@ -926,11 +926,14 @@ client_attempt_reopen (fd_t *fd, xlator_t *this) conf = this->private; - fdctx = this_fd_get_ctx (fd, this); - if (!fdctx) - goto out; pthread_spin_lock (&conf->fd_lock); { + fdctx = this_fd_get_ctx (fd, this); + if (!fdctx) { + pthread_spin_unlock(&conf->fd_lock); + goto out; + } + if (__is_fd_reopen_in_progress (fdctx)) goto unlock; if (fdctx->remote_fd != -1) |
