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

Fixed pid wrapping in sss_cli_check_socket #6616

Closed
wants to merge 2 commits into from
Closed

Fixed pid wrapping in sss_cli_check_socket #6616

wants to merge 2 commits into from

Conversation

answer9030
Copy link

Resolves: #6592

@alexey-tikhonov
Copy link
Member

What is the difference with #6608?

sss_cli_close_socket();
}
}
sss_cli_sd = -1;
mypid = getpid();
ret = lstat("/proc/self/", &selfsb);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

you already have all the data in myself_sb so, not need to call lstat() again. And I think it would be good if you can to the same with the pid and avoid calling getpid() twice..

bye,
Sumit

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,
My issue is: #6592
I do not know the use of mypid, but mypid causes this issue. so I imitate the writing method of mypid and add the selfsb and myself_sb to reduce the probability of problems caused by pid loopback.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

yes, I understand this. However, currently getpid() and with your patch lstat() as well are called twice to get the same information. Since those are system-call both need some time to execute and since the second call is redundant it would help to avoid it.

The getpid() related code it quite old and at the time it was written it might have even been cheap because glibc had a pid cache which helped to avoid a system-call. But this changed are there is currently also no alternatives, e.g. as a vDSO call, available, see e.g. https://bugzilla.redhat.com/show_bug.cgi?id=1469757 and the links in the ticket for details. I wasn't aware of this until reviewing your patch as well and thought that since your patch touched this area of the code it can be improved as part of your patch.

If @alexey-tikhonov, agrees we can keep your patch as it is but open a new ticket to remove the second getpid() and lstat()` call in a separate PR. But feel free to do the change yourself.

bye,
Sumit

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch. I think at least 2nd lstat() can be avoided within this patch.

Also I think we should really consider per-transaction sockets, as you proposed in other ticket...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, I see. The redundant second call will be deleted.

…eck_socket()

the second call to getpid() and lstat() is redundant.
@alexey-tikhonov
Copy link
Member

Thanks, ACK.

Copy link
Contributor

@sumit-bose sumit-bose left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

thanks for the update, ACK.

bye,
Sumit

@pbrezina
Copy link
Member

Pushed PR: #6616

  • master
    • 5c363bf - Fixed the problem of calling getpid() and lstat() twice in sss_cli_check_socket()
    • 0e25f0d - Fixed pid wrapping in sss_cli_check_socket

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-backport This should go to target branch only. Pushed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pid wrapping caused sss_cli_check_socket to close the file descriptor opened by the process
4 participants