RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1701092 - segfault when using pam passthru and addn plugins together
Summary: segfault when using pam passthru and addn plugins together
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: 389-ds-base
Version: 7.6
Hardware: Unspecified
OS: Unspecified
high
low
Target Milestone: rc
: 7.7
Assignee: mreynolds
QA Contact: RHDS QE
URL:
Whiteboard:
Depends On:
Blocks: 1718184 1721912
TreeView+ depends on / blocked
 
Reported: 2019-04-18 03:40 UTC by Scott Nicholas
Modified: 2020-09-13 22:20 UTC (History)
10 users (show)

Fixed In Version: 389-ds-base-1.3.9.1-8.el7
Doc Type: Bug Fix
Doc Text:
Cause: Using PAM plugin and Addn plugin in Directory Server. Consequence: The server can crash when deferenceing a NULL DN pointer. Fix: Check for NULL before dereferencing the normalized DN pointer. Result: The server does not crash.
Clone Of:
: 1718184 1721912 (view as bug list)
Environment:
Last Closed: 2019-08-06 12:59:17 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github 389ds 389-ds-base issues 3454 0 None None None 2020-09-13 22:20:57 UTC
Red Hat Product Errata RHBA-2019:2152 0 None None None 2019-08-06 12:59:29 UTC

Description Scott Nicholas 2019-04-18 03:40:27 UTC
Description of problem:

A device I have only does LDAP auth to Active Directory. Therefore I have configured the PAM passthru plugin and addn plugin to dirsrv. I then setup pam to use pam_radius_auth, but I don't think that is required to reproduce this. If an attempt is made to bind to a dn that doesn't exist, ns-slapd segfaults:

kernel: ns-slapd[26414]: segfault at 0 ip 00007ff0e692a91d sp 00007ff0d12df6c0 error 4 in libpam-passthru-plugin.so[7ff0e6925000+8000]

Version-Release number of selected component (if applicable):

389-ds-base-1.3.8.4-23.el7.x86_64

How reproducible:

100% once minimal configuration made on fresh install of ipa-server with 389-ds-base.

Steps to Reproduce:
1. configure addn plugin per https://www.port389.org/docs/389ds/howto/howto-addn.html
2. configure pam passthru per https://directory.fedoraproject.org/docs/389ds/howto/howto-pam-pass-through.html
3. attempt to ldapsearch -D 'bob' (or any nonexistant user)

Actual results:
ldapsearch fails that server is unavailable

Expected results:
query results.

Additional info:

gdb output -- 

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffd1988700 (LWP 27086)]
0x00007fffe5fd091d in pam_passthru_bindpreop (pb=0x5555572f9980) at ldap/servers/plugins/pam_passthru/pam_ptpreop.c:439
439         if ((method != LDAP_AUTH_SIMPLE) || (*normbinddn == '\0') ||


the non-pam ldap/servers/plugins/passthru/ptpreop.c does this:

   121      normbinddn = slapi_sdn_get_dn(sdn);
   122      if (normbinddn == NULL) {
   123          normbinddn = "";
   124      }

but looks like pam_passthru has no NULL check. I am so far successful using this patch:

[root@kdc1 SOURCES]# cat 0024-Fix-pam-passthrough.patch
diff -ru a/ldap/servers/plugins/pam_passthru/pam_ptpreop.c b/ldap/servers/plugins/pam_passthru/pam_ptpreop.c
--- a/ldap/servers/plugins/pam_passthru/pam_ptpreop.c   2018-06-21 12:55:37.000000000 -0400
+++ b/ldap/servers/plugins/pam_passthru/pam_ptpreop.c   2019-04-17 22:55:25.847280405 -0400
@@ -436,8 +436,8 @@
      * We only handle simple bind requests that include non-NULL binddn and
      * credentials.  Let the Directory Server itself handle everything else.
      */
-    if ((method != LDAP_AUTH_SIMPLE) || (*normbinddn == '\0') ||
-        (creds->bv_len == 0)) {
+    if ((method != LDAP_AUTH_SIMPLE) || (normbinddn == NULL) ||
+        (*normbinddn == '\0') || (creds->bv_len == 0)) {
         slapi_log_err(SLAPI_LOG_PLUGIN, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
                       "pam_passthru_bindpreop - Not handled (not simple bind or NULL dn/credentials)\n");
         return retcode;

Comment 2 mreynolds 2019-05-20 19:12:28 UTC
Fixed upstream

Comment 7 Viktor Ashirov 2019-06-21 13:32:12 UTC
============================================================================ test session starts =============================================================================
platform linux -- Python 3.6.3, pytest-4.6.3, py-1.8.0, pluggy-0.12.0 -- /opt/rh/rh-python36/root/usr/bin/python3
cachedir: .pytest_cache
389-ds-base: 1.3.9.1-10.el7
nss: 3.44.0-4.el7
nspr: 4.21.0-1.el7
openldap: 2.4.44-21.el7_6
cyrus-sasl: 2.1.26-23.el7
FIPS: disabled
rootdir: /workspace/ds/dirsrvtests, inifile: pytest.ini
collected 1 item                                                                                                                                                             

dirsrvtests/tests/suites/plugins/regression_test.py::test_crash_in_pam_pta_plugin_when_user_doesnt_exist PASSED                                                        [100%]

=================================================================== 1 passed, 3 warnings in 19.65 seconds ====================================================================

Comment 9 errata-xmlrpc 2019-08-06 12:59:17 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, 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-2019:2152


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