Page MenuHome GnuPG

support more than 1024 fds.
Closed, ResolvedPublic


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.

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.

Just curious, why can you not start using poll() instead of select()?

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.

werner renamed this task from _gpgme_io_select crashes if fd > 1024 to support more than 1024 fds..Aug 9 2016, 11:49 AM
werner removed a project: Bug Report.
werner added a project: Feature Request.

I changed this ussie to a feature request.

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.


werner raised the priority of this task from Normal to High.Oct 4 2021, 11:08 AM

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

gniibe added a project: Restricted Project.
gniibe removed a project: Restricted Project.