Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An improper locking bug(e.g., deadlock) on the lock up_inode_ctx->client_list_lock #2789

Closed
ryancaicse opened this issue Sep 15, 2021 · 10 comments
Labels
wontfix Managed by stale[bot]

Comments

@ryancaicse
Copy link
Contributor

Hi, developers, thank you for your checking. It seems the lock up_inode_ctx->client_list_lock is not released correctly when __upcall_cleanup_client_entry(up_client); returns true in the function upcall_cleanup_expired_clients?

pthread_mutex_lock(&up_inode_ctx->client_list_lock);
{
list_for_each_entry_safe(up_client, tmp, &up_inode_ctx->client_list,
client_list)
{
t_expired = now - up_client->access_time;
if (t_expired > (2 * timeout)) {
gf_log(THIS->name, GF_LOG_TRACE, "Cleaning up client_entry(%s)",
up_client->client_uid);
ret = __upcall_cleanup_client_entry(up_client);
if (ret) {
gf_msg("upcall", GF_LOG_WARNING, 0,
UPCALL_MSG_INTERNAL_ERROR,
"Client entry cleanup failed (%p)", up_client);
goto out;
}
}
}
}
pthread_mutex_unlock(&up_inode_ctx->client_list_lock);
ret = 0;
out:
return ret;
}

Best,

@ryancaicse
Copy link
Contributor Author

Similarly, for the lock pl_inode->mutex

pthread_mutex_lock(&pl_inode->mutex);
if (pl_inode_has_owners(xl, frame->root->client, pl_inode, &now, contend)) {
error = -1;
/* We skip the unlock here because the caller must create a stub when
* we return -1 and do a call to pl_inode_remove_complete(), which
* assumes the lock is still acquired and will release it once
* everything else is prepared. */
goto done;
}
pl_inode->is_locked = _gf_true;
pl_inode->remove_running++;
pthread_mutex_unlock(&pl_inode->mutex);
done:
*ppl_inode = pl_inode;
return error;

@pranithk
Copy link
Member

@ryancaicse First one is a bug. 2nd one has a comment that explains that the unlock should be taken care by the caller and it seems to be doing so. Do you want to send a PR for the first one?

@ryancaicse
Copy link
Contributor Author

@pranithk Thanks

amarts pushed a commit that referenced this issue Sep 27, 2021
Fix a bug due to the unreleased lock in the upcall_cleanup_expired_clients

Updates:  #2789
Signed-off-by: Ryan Cai <ryancaicse@gmail.com>
@ryancaicse
Copy link
Contributor Author

Hi, any security impacts for the first bug?
I think there could be security issues - unreleased lock could lead to deadlock(a DoS), wreaking a DoS.
Could we apply CVE for this?

@mykaul
Copy link
Contributor

mykaul commented Oct 17, 2021

Hi, any security impacts for the first bug? I think there could be security issues - unreleased lock could lead to deadlock(a DoS), wreaking a DoS. Could we apply CVE for this?

@ryancaicse - how could __upcall_cleanup_client_entry() return anything but 0?

@ryancaicse
Copy link
Contributor Author

Hi, any security impacts for the first bug? I think there could be security issues - unreleased lock could lead to deadlock(a DoS), wreaking a DoS. Could we apply CVE for this?

@ryancaicse - how could __upcall_cleanup_client_entry() return anything but 0?

I don't know since I did not write them. I am also asking questions.

@pranithk
Copy link
Member

As it stands now, it won't. the patch is more of future proofing if someone were to introduce cases where -ve value will be returned. So it is not a CVE

@ryancaicse
Copy link
Contributor Author

ryancaicse commented Oct 17, 2021

@pranithk @mykaul Many thanks for your reply

mykaul pushed a commit to mykaul/glusterfs that referenced this issue Oct 17, 2021
Following gluster#2789, a bit of a cleanup to the function.

Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
amarts pushed a commit that referenced this issue Oct 20, 2021
Following #2789, a bit of a cleanup to the function.

Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
@stale
Copy link

stale bot commented Jun 4, 2022

Thank you for your contributions.
Noticed that this issue is not having any activity in last ~6 months! We are marking this issue as stale because it has not had recent activity.
It will be closed in 2 weeks if no one responds with a comment here.

@stale stale bot added the wontfix Managed by stale[bot] label Jun 4, 2022
@stale
Copy link

stale bot commented Jun 23, 2022

Closing this issue as there was no update since my last update on issue. If this is an issue which is still valid, feel free to open it.

@stale stale bot closed this as completed Jun 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix Managed by stale[bot]
Projects
None yet
Development

No branches or pull requests

3 participants