-
Notifications
You must be signed in to change notification settings - Fork 3k
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
management interface: Reverted management_io to its original state to prevent the following problem: #46
base: master
Are you sure you want to change the base?
Conversation
problem: man_read -> ... -> man_output_list_push_finalize -> management_io -> man_read After some digging I found this commit made by James Yonan in 2010: https://sourceforge.net/p/openvpn/openvpn-testing/ci/3cf6c9328250061600b78c8a7deb0edc850e739b In this commit he put both writing to and reading from the socket into the same "if" branch, which leads to the problem I've mentioned above. man_read after having been called recursively goes nuts and screws its input buffer, as result openvpn can processes the same command several times and then fail to read the rest of them correctly. I'm not sure that what I did here is the best way to solve this problem, but it seems to work for me.
Here is a small testcase I used to reproduce and debug the problem:
Of course, as with any race condition, your ability to reproduce this bug might depend on your particular machine and/or luck. |
And in terms of code the problem looks like this: 002fefd0 0126d7a9 openvpn!man_read+0x27 It goes like this:
|
Hi, On Tue, May 17, 2016 at 12:13:04PM -0700, Alexander Matveyev wrote:
Thanks for the patch and the detailed description. I've asked James and gert USENET is not the non-clickable part of WWW! |
Notifying @jamesyonan |
Aaand, of course I made a stupid mistake when fixing the bug in my local fork. One closing '}' brace is in the wrong place. I debugged and worked on one source tree and sent you changes from another, typical me :) It doesn't change anything about the bug description, just disregard my patch, the fix is trivial anyway, you can easily do it from scratch or even decide to fix the problem in a totally different place. |
@schwabe is this still an issue? |
@selvanair might also have some insights here, having fixed one of the management recursion issues recently... |
This does look related to the bug for which we merged a quick-fix (allow a few levels of recursion in virtual_output_callback(): commit 4dfd592). However, I can't reproduce the behaviour reported here. I tried with and without my patch: in both cases repeatedly sending "state on/off" as suggested here works correctly. Also checked that the daemon does respond with "SUCCESS: " for each command (tested on Linux). This is not definitive as such race-condition/timing related bugs are hard to reproduce. @amatveyev-gh could you test again whether this is still an issue? I'm also curious to know whether the fix proposed here could also handle the lost messages problem without allowing recursion. In the mean time I stumbled up on commit b2b6617 which seems to indicate that allowing recursion as I did may have undesirable side effects. @dsommers Does commit 4dfd592 break your bug-fix in commit b2b6617 ? |
man_read -> ... -> man_output_list_push_finalize -> management_io ->
man_read
After some digging I found this commit made by James Yonan in 2010:
https://sourceforge.net/p/openvpn/openvpn-testing/ci/3cf6c9328250061600b78c8a7deb0edc850e739b
In this commit he put both writing to and reading from the socket into the
same "if" branch, which leads to the problem I've mentioned above.
man_read after having been called recursively goes totally nuts and screws its input
buffer, as result, openvpn can processes the same command several times
and then fail to read the rest of them correctly.
I'm not sure that what I did here is the best way to solve this problem,
but it seems to work for me.