Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
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 1761047

Summary: Null dereference in sssctl/sssctl_domains.c:sssctl_domain_status_active_server()
Product: Red Hat Enterprise Linux 8 Reporter: Niranjan Mallapadi Raghavender <mniranja>
Component: sssdAssignee: Alexey Tikhonov <atikhono>
Status: CLOSED ERRATA QA Contact: sssd-qe <sssd-qe>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 8.1CC: atikhono, grajaiya, jhrozek, lslebodn, mzidek, pbrezina, sgoveas, tscherf
Target Milestone: rcFlags: pm-rhel: mirror+
Target Release: 8.0   
Hardware: x86_64   
OS: Linux   
URL: http://faf.lab.eng.brq.redhat.com/faf/reports/bthash/bb0690fb74e529f186895fdff7aff8ddd234c1bd/
Whiteboard: sync-to-jira
Fixed In Version: sssd-2.2.3-2.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-04-28 16:56:04 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Niranjan Mallapadi Raghavender 2019-10-12 04:26:29 UTC
This bug has been created based on an anonymous crash report requested by the package maintainer.

Report URL: http://faf.lab.eng.brq.redhat.com/faf/reports/bthash/bb0690fb74e529f186895fdff7aff8ddd234c1bd/


sssctl crashes with core dump when sssd.conf is configured with multiple domains 

[root@vm-10-0-154-49 abrt]# cat /etc/sssd/sssd.conf
[sssd]
config_file_version = 2
sbus_timeout = 30
services = pam, nss
domains = proxy, ldap2

[domain/proxy]
auth_provider = proxy
enumerate = True
id_provider = proxy
debug_level = 0xFFF0
proxy_lib_name = ldap
proxy_pam_target = sssdproxyldap

[domain/ldap2]
id_provider = ldap
auth_provider = ldap
chpass_provider = ldap
ldap_id_use_start_tls = True
debug_level = 0xFFF0
enumerate = True
ldap_tls_cacert = /etc/openldap/cacerts/cacert.pem
ldap_search_base = dc=example1,dc=test
ldap_uri = ldaps://vm-10-0-154-50.hosted.upshift.rdu2.redhat.com

[nss]
filter_groups = root
filter_users = root

[pam]
debug_level = 9


Run sssctl. 

[root@vm-10-0-154-49 abrt]# sssctl domain-status proxy
Online status: Online

Active servers:
Segmentation fault (core dumped)

Comment 3 Alexey Tikhonov 2019-10-16 15:03:20 UTC
```
(gdb) finish
Run till exit from #0  sbus_call_ifp_domain_ListServices (mem_ctx=mem_ctx@entry=0x555555819660, 
    conn=conn@entry=0x555555816890, busname=busname@entry=0x555555568e50 "org.freedesktop.sssd.infopipe", 
    object_path=object_path@entry=0x5555557a0290 "/org/freedesktop/sssd/infopipe/Domains/proxy", 
    _arg_services=_arg_services@entry=0x7fffffffd8c8) at src/responder/ifp/ifp_iface/sbus_ifp_client_sync.c:1023
0x000055555555e816 in sssctl_domain_status_active_server (
    domain_path=0x5555557a0290 "/org/freedesktop/sssd/infopipe/Domains/proxy", conn=0x555555816890)
    at src/tools/sssctl/sssctl_domains.c:203
203	    ret = sbus_call_ifp_domain_ListServices(tmp_ctx, conn, IFP_BUS,
Value returned is $1 = 0
(gdb) list
198	    if (tmp_ctx == NULL) {
199	        DEBUG(SSSDBG_CRIT_FAILURE, "talloc_new() failed\n");
200	        return ENOMEM;
201	    }
202	
203	    ret = sbus_call_ifp_domain_ListServices(tmp_ctx, conn, IFP_BUS,
204	                                            domain_path, &services);
205	    if (ret != EOK) {
206	        DEBUG(SSSDBG_CRIT_FAILURE, "Unable to get domain services [%d]: %s\n",
207	              ret, sss_strerror(ret));
(gdb) step
205	    if (ret != EOK) {
(gdb) p ret
$3 = 0
(gdb) p services
$4 = (const char **) 0x0
```

So `sbus_call_ifp_domain_ListServices()` returned EOK and `services==NULL`, but `sssctl_domain_status_active_server()` is not ready to handle this.

I think it is worth to add check for `services==NULL` in `sssctl_domain_status_active_server()` in any case.

But I am not sure if `sbus_call_ifp_domain_ListServices()` behaves as expected.

Pavel, I guess it is ok to have empty list of services and to return EOK in this case. But could you please clarify, if `sbus_call_ifp_domain_ListServices()` should return NULL or list with one "NULL"-entry in this case?

Comment 4 Pavel Březina 2019-10-17 08:52:58 UTC
Yes, this is expected. See sbus_iterator_readers.c:96. But perhaps it would make sence to change it to return [NULL] instead of NULL so consumers do not have to worry about this case.

Comment 5 Alexey Tikhonov 2019-10-17 13:30:09 UTC
Ok, so I will only touch sssctl_domain_status_active_server() to fix tis bz.

Comment 6 Alexey Tikhonov 2019-10-18 15:08:53 UTC
Upstream ticket:
https://pagure.io/SSSD/sssd/issue/4102

Comment 7 Alexey Tikhonov 2019-10-21 14:12:41 UTC
PR: https://github.com/SSSD/sssd/pull/909

Comment 8 Pavel Březina 2019-10-31 11:54:06 UTC
* `master`
    * 75b1fe68433a5b6276fe5da38e004b863710f335 - sssctl/sssctl_domains.c: null dereference fixed

Comment 10 Niranjan Mallapadi Raghavender 2020-02-07 01:57:31 UTC
Versions:
sssd-winbind-idmap-2.2.3-13.el8.x86_64
sssd-common-pac-2.2.3-13.el8.x86_64
sssd-ad-2.2.3-13.el8.x86_64
sssd-libwbclient-2.2.3-11.el8.x86_64
sssd-common-2.2.3-13.el8.x86_64
sssd-krb5-2.2.3-13.el8.x86_64
sssd-2.2.3-13.el8.x86_64
python3-sssdconfig-2.2.3-13.el8.noarch
sssd-client-2.2.3-13.el8.x86_64
sssd-krb5-common-2.2.3-13.el8.x86_64
sssd-ldap-2.2.3-13.el8.x86_64
sssd-ipa-2.2.3-13.el8.x86_64
sssd-tools-2.2.3-13.el8.x86_64
sssd-dbus-2.2.3-13.el8.x86_64
sssd-nfs-idmap-2.2.3-11.el8.x86_64
sssd-proxy-2.2.3-13.el8.x86_64
sssd-kcm-2.2.3-13.el8.x86_64

[root@vm-10-0-154-50 ~]# cat /etc/sssd/sssd.conf
[sssd]
config_file_version = 2
services = nss, pam
domains = example1, proxy

[domain/example1]
ldap_search_base = dc=example,dc=test
id_provider = ldap
auth_provider = ldap
ldap_user_home_directory = /home/%u
ldap_uri = ldaps://vm-10-0-153-149.hosted.upshift.rdu2.redhat.com
ldap_tls_cacert = /etc/openldap/cacerts/cacert.pem
use_fully_qualified_names = True
debug_level = 9

[domain/proxy]
auth_provider = proxy
id_provider = proxy
debug_level = 0xFFF0
proxy_lib_name = ldap
proxy_pam_target = sssdproxyldap

Execute sssctl on domain proxy 

[root@vm-10-0-154-50 ~]# sssctl domain-status proxy
Online status: Online

This domain has no active servers.

No servers discovered.

Execute sssctl on domain example1

[root@vm-10-0-154-50 ~]# sssctl domain-status example1
Online status: Online

Active servers:
LDAP: vm-10-0-153-149.hosted.upshift.rdu2.redhat.com

Discovered LDAP servers:
- vm-10-0-153-149.hosted.upshift.rdu2.redhat.com

Comment 12 errata-xmlrpc 2020-04-28 16:56:04 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-2020:1863