The function _gpgme_io_select in posix-io.c uses a select call to get the file
descriptors which are ready to be processed. However select() has a limitation of only
working if fd < __FD_SETSIZE which is usually 1024. If fd > 1024 is provided process
crashes with 'buffer overflow detected'. The fix I made locally was to switch to a
poll() call instead.
Description
Revisions and Commits
Status | Assigned | Task | ||
---|---|---|---|---|
Resolved | • gniibe | T2385 support more than 1024 fds. | ||
Resolved | • gniibe | T5637 Use poll for libgcrypt (support more than 1024 fds) | ||
Resolved | • gniibe | T5748 Adding poll/ppoll to NPTH |
Event Timeline
We can't easily solve this. For now I pushed a fix to return an error instead
of crashing. (commit 8173c4f). Thanks for reporting.
poll is not available on all platforms and has other semantics. Thus we will
introduce new bugs. We are planning to move some of the lower level I/O stuff
to libgpg-error and in the course of this we will fix this problem.
Hi, was there any update on this? I found the following bug [0] in libgcrypt, which we solved [1] with using poll ages ago.
It works for us fine because we do not have to bother about other platforms with different semantics, but it would be great if we could solve this systematically upstream in all the places.
I see the gpgrt has gpgrt_poll() so I would like to check if a patch rewriting the uses of select to gpgrt_poll() would be acceptable upstream or if there is some more about that to work on.
[0] https://bugzilla.redhat.com/show_bug.cgi?id=913773
[1] https://src.fedoraproject.org/rpms/libgcrypt/blob/rawhide/f/libgcrypt-1.8.4-use-poll.patch
For libgcrypt, it was fixed in: T5637: Use poll for libgcrypt (support more than 1024 fds)
For libgpg-error internal, it uses poll (for many POSIX system) already.
If we can put aside (for factoring out from gpgme to gpgrt), here is a patch:
D539: Using poll instead, removing use of select for POSIX system