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 2167468 - systemd: _nss_myhostname_gethostbyname2_r in nss_myhostname returns NSS_STATUS_SUCCESS without any addresses
Summary: systemd: _nss_myhostname_gethostbyname2_r in nss_myhostname returns NSS_STATU...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: systemd
Version: 9.2
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Lukáš Nykrýn
QA Contact: Frantisek Sumsal
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-02-06 17:31 UTC by Pino Toscano
Modified: 2023-05-09 10:34 UTC (History)
11 users (show)

Fixed In Version: systemd-252-5.el9
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2023-05-09 08:22:35 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Sample getaddrinfo() program (844 bytes, text/x-csrc)
2023-02-06 17:31 UTC, Pino Toscano
no flags Details
/etc/nsswitch.conf (2.07 KB, text/plain)
2023-02-06 17:32 UTC, Pino Toscano
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Github redhat-plumbers systemd-rhel9 pull 137 0 None Merged (#2167468) nss-myhostname: two fixlets 2023-02-13 08:32:41 UTC
Github systemd systemd pull 26366 0 None Merged nss-myhostname: two fixlets 2023-02-09 11:04:57 UTC
Red Hat Issue Tracker RHELPLAN-147661 0 None None None 2023-02-06 17:31:37 UTC
Red Hat Product Errata RHBA-2023:2531 0 None None None 2023-05-09 08:22:52 UTC

Description Pino Toscano 2023-02-06 17:31:11 UTC
Created attachment 1942561 [details]
Sample getaddrinfo() program

Created attachment 1942561 [details]
Sample getaddrinfo() program

Description of problem:
getaddrinfo() crashes in case the system has no IPv6 (disabled via sysctl calls), and the hints have ai_family=AF_INET6;

Version-Release number of selected component (if applicable):
glibc-2.34-58.el9.x86_64
systemd-252-3.el9.x86_64

How reproducible:
Every time

Steps to Reproduce:
1. build the attached getaddressinfo-test.c
2. disable IPv6 on the system:
  sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
  sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1
2. run it specifying the hostname of the system, e.g. ./getaddressinfo-test `hostname`

Actual results:
The sample getaddressinfo-test exits with segmentation fault.

Expected results:
getaddressinfo-test runs fine, and either
- exits with a "getaddrinfo: " error line (expected, since IPv6 is not available)
- return something (?)

Additional info:
Attached also the /etc/nsswitch.conf of the system.

Comment 1 Pino Toscano 2023-02-06 17:32:03 UTC
Created attachment 1942562 [details]
/etc/nsswitch.conf

Comment 2 Florian Weimer 2023-02-06 17:48:16 UTC
I can reproduce it in Beaker, on a machine where nss_dns does not succeed for its host name, but _nss_myhostname_gethostbyname2_r does:

Run till exit from #0  _nss_myhostname_gethostbyname2_r (
    name=name@entry=0x7fffffffe201 "<redacted>", 
    af=af@entry=10, host=host@entry=0x7fffffffd630, buffer=0x7fffffffd920 "", 
    buflen=1024, errnop=errnop@entry=0x7ffff7fb56c0, h_errnop=0x7ffff7fb5724)
    at ../src/nss-myhostname/nss-myhostname.c:520
0x00007ffff7d36d8d in gaih_inet (name=<optimized out>, 
    name@entry=0x7fffffffe201 "<redacted>", 
    service=service@entry=0x0, req=req@entry=0x7fffffffdd90, 
    pai=pai@entry=0x7fffffffd818, naddrs=naddrs@entry=0x7fffffffd814, 
    tmpbuf=tmpbuf@entry=0x7fffffffd910) at ../sysdeps/posix/getaddrinfo.c:832
832				  gethosts (AF_INET6, struct in6_addr);
Value returned is $5 = NSS_STATUS_SUCCESS

Looking at the result in convert_hostent_to_gaih_addrtuple (the macro goo makes that a bit difficult to debug), I get:

convert_hostent_to_gaih_addrtuple (req=req@entry=0x7fffffffdd90,
    family=family@entry=10, h=h@entry=0x7fffffffd630,
    result=result@entry=0x7fffffffd618) at ../sysdeps/posix/getaddrinfo.c:201
(gdb) print *h
$13 = {h_name = 0x7fffffffd920 "<redacted>",
  h_aliases = 0x7fffffffd958, h_addrtype = 10, h_length = 16,
  h_addr_list = 0x7fffffffd968}
(gdb) print h->h_addr_list
$14 = (char **) 0x7fffffffd968
(gdb) print h->h_addr_list[0]
$15 = 0x0

So nss_myhostname returns NSS_STATUS_SUCCESS, but no data. The more usual return value for this is NSS_STATUS_TRYAGAIN, telling glibc NSS to continue processing with the next service module. I am not sure if the current protocol actually offers an authoritative NODATA response.

Assuming this analysis is correct, this is more of a systemd bug than a glibc bug.

Comment 3 Florian Weimer 2023-02-07 16:45:19 UTC
If you get a machine out of Beaker that has an IPv6 address, you can trigger this bug via:

hostnamectl hostname mycomputer

And then use “mycomputer” with the reproducer.

I cannot reproduce the issue with:

systemd-250-12.el9_1.2.x86_64
systemd-libs-250-12.el9_1.2.x86_64
systemd-pam-250-12.el9_1.2.x86_64
systemd-rpm-macros-250-12.el9_1.2.noarch
systemd-udev-250-12.el9_1.2.x86_64

I can reproduce the issue with:

systemd-252-4.el9.x86_64
systemd-libs-252-4.el9.x86_64
systemd-pam-252-4.el9.x86_64
systemd-rpm-macros-252-4.el9.noarch
systemd-udev-252-4.el9.x86_64

I suspect it is a side effect of:

commit db50d326a46beca3cc24b6354b6e1b3591902d45
Author: Yu Watanabe <watanabe.yu+github>
Date:   Fri Apr 22 10:31:22 2022 +0900

    nss-myhostname: do not return IPv6 local address if IPv6 is disabled

This came with the systemd-252 rebase.

Comment 4 Yu Watanabe 2023-02-08 21:35:00 UTC
Thank you for the report. Fix is waiting in https://github.com/systemd/systemd/pull/26366.

Comment 6 Plumber Bot 2023-02-10 09:12:01 UTC
fix merged to github main branch -> https://github.com/redhat-plumbers/systemd-rhel9/pull/137

Comment 11 errata-xmlrpc 2023-05-09 08:22:35 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 (systemd 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-2023:2531


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