Note: This is a public test instance of Red Hat Bugzilla. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback at bugzilla.redhat.com.
Bug 1875361 - CLDAP ldap_result hangs if nobody listens on the port
Summary: CLDAP ldap_result hangs if nobody listens on the port
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: openldap
Version: 8.3
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: 8.0
Assignee: Simon Pichugin
QA Contact: RHDS QE
URL:
Whiteboard:
Depends On:
Blocks: 1877754
TreeView+ depends on / blocked
 
Reported: 2020-09-03 11:53 UTC by Pavel Březina
Modified: 2021-05-18 13:19 UTC (History)
4 users (show)

Fixed In Version: openldap-2.4.46-16.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1877754 (view as bug list)
Environment:
Last Closed: 2021-05-18 13:14:50 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
minimal reproducer (1.58 KB, text/x-csrc)
2020-09-03 11:53 UTC, Pavel Březina
no flags Details

Description Pavel Březina 2020-09-03 11:53:54 UTC
Created attachment 1713590 [details]
minimal reproducer

SSSD wants to perform multiple CLDAP pings to Active Directory in parallel. However openldap has a bug that cause a blocking i/o call when connection to the UDP port can not be established.

Upstream BZ (merged):
https://bugs.openldap.org/show_bug.cgi?id=9328

When using LDAP over UDP, calling ldap_result() hangs if there is nobody listening on the remote port.

The problem is that it calls recvfrom() twice, the first attempt returns ECONNREFUSED but this is ignored. The seconds read then blocks/timeouts/returns EAGAIN depending on the sockets settings, however we know that we will never receive any data so it should return an error. See [1]

poll([{fd=20, events=POLLIN|POLLPRI}], 1, 0) = 1 ([{fd=20, revents=POLLERR}])
recvfrom(20, 0x18dade0, 16256, 0, 0x18dad60, [128]) = -1 ECONNREFUSED (Connection refused)
recvfrom(20,  <unfinished ...>)         = ? 

[1] https://git.openldap.org/pbrezina/openldap/-/blob/master/libraries/libldap/result.c#L489

Reproducer:
$ gcc -ggdb3 -o client ./main.c -lldap
$ strace ./client
...
sendto(3, "0'\2\1\1\4\0c \4\0\n\1\0\n\1\0\2\1\0\2\1\0\1\1\0\207\vobje"..., 41, 0, {sa_family=AF_INET, sin_port=htons(3333), sin_addr=inet_addr("127.0.0.1")}, 16) = 41
poll([{fd=3, events=POLLIN|POLLPRI}], 1, 1000) = 1 ([{fd=3, revents=POLLERR}])
recvfrom(3, 0x493b10, 16256, 0, 0x493a90, [128]) = -1 ECONNREFUSED (Connection refused)
recvfrom(3, 

No LDAP server is running at localhost.

Comment 8 errata-xmlrpc 2021-05-18 13:14:50 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (openldap bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2021:1570


Note You need to log in before you can comment on or make changes to this bug.