The Samba-Bugzilla – Bug 10731
sys_poll_intr(): wrong unit for timeout value
Last modified: 2014-09-01 19:16:57 UTC
Created attachment 10130 [details]
sys_poll_intr: fix timeout arithmetic
Callers of sys_poll_intr() assume the timeout parameter to be in milliseconds, just like poll(2) expects it. If the poll() call gets interrupted before the timeout expires, the timeout arithmetic in sys_poll_intr() assumes nanosecond units instead. This will usually lead to a negative new timeout value. Hence, after an EINTR, sys_poll_intr() might hang.
I'm attaching a patch that should fix this problem in sys_poll_intr().
Both patches were created against 4.1.9, but should apply to master as well.
(We only noticed the bug while calling receive_smb_talloc() with a non-zero timeout for debugging purposes. In the unmodified code, few callers seem to end up in sys_poll_intr() with a positive timeout.)
Created attachment 10133 [details]
Patch in git-format patch format for master
Entirely correct, thanks Daniel!
For future patches, it would be great if you could use "git format-patch --stdout" to upload patches. This makes it easier to apply them locally with "git am -3".
(In reply to comment #1)
> Created attachment 10133 [details]
> Patch in git-format patch format
> Entirely correct, thanks Daniel!
> For future patches, it would be great if you could use "git format-patch
> --stdout" to upload patches. This makes it easier to apply them locally with
> "git am -3".
Created attachment 10142 [details]
Patch for v4-1
This is what ended up in master, with all required tags
What about v4-0*?
(In reply to comment #4)
> What about v4-0*?
Well, the code is the same there, thus it also has the same bug. The patch applies cleanly to v4-0-test as well. I'll leave it to Karolin whether it's worth also taking for 4.0.
Pushed to autobuild-v4-[0|1]-test.
(In reply to comment #6)
> Pushed to autobuild-v4-[0|1]-test.
Pushed to both branches.
Closing out bug report.