Bug 14830 - glibc >= 2.34 breaks resolv_wrapper resolv.conf feature
Summary: glibc >= 2.34 breaks resolv_wrapper resolv.conf feature
Status: NEW
Alias: None
Product: cwrap
Classification: Unclassified
Component: library (show other bugs)
Version: unspecified
Hardware: All All
: P5 normal
Target Milestone: ---
Assignee: Andreas Schneider
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-09-12 02:50 UTC by Tomasz Kloczko
Modified: 2023-04-07 15:01 UTC (History)
1 user (show)

See Also:


Attachments
Debugging output (213.60 KB, text/plain)
2023-04-07 05:59 UTC, Greg Hudson
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tomasz Kloczko 2021-09-12 02:50:57 UTC
Looks like test suite i faling

+ cd resolv_wrapper-1.1.7
+ /usr/bin/make -O -j48 V=1 VERBOSE=1 -C x86_64-redhat-linux-gnu test ARGS=--output-on-failure
make: Entering directory '/home/tkloczko/rpmbuild/BUILD/resolv_wrapper-1.1.7/x86_64-redhat-linux-gnu'
Running tests...
/usr/bin/ctest --force-new-ctest-process --output-on-failure
Test project /home/tkloczko/rpmbuild/BUILD/resolv_wrapper-1.1.7/x86_64-redhat-linux-gnu
    Start 1: test_res_init
1/3 Test #1: test_res_init ....................   Passed    0.01 sec
    Start 2: test_res_query_search
2/3 Test #2: test_res_query_search ............***Failed    1.66 sec
[==========] Running 4 test(s).
[ RUN      ] test_res_nquery
[  ERROR   ] --- 0xffffffffffffffff == 0xffffffffffffffff
[   LINE   ] --- /home/tkloczko/rpmbuild/BUILD/resolv_wrapper-1.1.7/tests/test_res_query_search.c:86: error: Failure!
[  FAILED  ] test_res_nquery
[ RUN      ] test_res_query
[  ERROR   ] --- 0xffffffffffffffff == 0xffffffffffffffff
[   LINE   ] --- /home/tkloczko/rpmbuild/BUILD/resolv_wrapper-1.1.7/tests/test_res_query_search.c:117: error: Failure!
[  FAILED  ] test_res_query
[ RUN      ] test_res_nsearch
[  ERROR   ] --- 0xffffffffffffffff == 0xffffffffffffffff
[   LINE   ] --- /home/tkloczko/rpmbuild/BUILD/resolv_wrapper-1.1.7/tests/test_res_query_search.c:153: error: Failure!
[  FAILED  ] test_res_nsearch
[ RUN      ] test_res_search
[  ERROR   ] --- 0xffffffffffffffff == 0xffffffffffffffff
[   LINE   ] --- /home/tkloczko/rpmbuild/BUILD/resolv_wrapper-1.1.7/tests/test_res_query_search.c:183: error: Failure!
[  FAILED  ] test_res_search
[==========] 4 test(s) run.
[  PASSED  ] 0 test(s).
[  FAILED  ] 4 test(s), listed below:
[  FAILED  ] test_res_nquery
[  FAILED  ] test_res_query
[  FAILED  ] test_res_nsearch
[  FAILED  ] test_res_search

 4 FAILED TEST(S)

    Start 3: test_dns_fake
3/3 Test #3: test_dns_fake ....................   Passed    0.01 sec

67% tests passed, 1 tests failed out of 3

Total Test time (real) =   1.68 sec

The following tests FAILED:
          2 - test_res_query_search (Failed)
Errors while running CTest
make: *** [Makefile:117: test] Error 8
Comment 1 Andreas Schneider 2021-09-18 06:39:32 UTC
Yes, as glibc >= 2.34 moved the res_* symbols from libresolv to libc.

This means socket_wrapper can't intercept the socket communication and make the feature for changing resolv.conf pretty useless.
Comment 2 Greg Hudson 2023-04-05 22:29:17 UTC
The krb5 test suite is failing on Ubuntu 22.04 (libc 2.35, resolv_wrapper 1.1.7).  The test script (t_discover_uri.py) uses RESOLV_WRAPPER_HOSTS, not RESOLV_WRAPPER_CONF, and the relevant library function uses res_nsearch().  Is that in scope for this bug report?  The text here talks about the resolv.conf feature and commit c75587f858eb49e6b13ab610e63289df0485ddac says "this leaves us only with DNS faking", but the failing test transcript seems to be for programs calling res_nsearch() etc. and configured with RESOLV_WRAPPER_HOSTS.

If I break at res_search, the first two lines of the stack trace are:

#0  ___res_nsearch (statp=0x7fffffffd7b0, 
    name=0x55555555ebc0 "_kerberos.TEST.", class=1, type=256, 
    answer=0x5555555607c0 "#@VPNC_GENERATED@ -- this file is generated by vpnc\n# and will be overwritten by vpnc\n# as long as the above mark is intact\n# This is /run/systemd/resolve/stub-resolv.conf managed by man:systemd-resol"..., 
    anslen=4096) at ./resolv/res_query.c:562
#1  0x0000555555556b14 in krb5int_dns_init (dsp=0x7fffffffda40, 
    host=0x55555555ebc0 "_kerberos.TEST.", nclass=1, ntype=256)
    at ../../../../src/lib/krb5/os/dnsglue.c:161
[...]

I think that has to be the system version of res_nsearch since resolv_wrapper doesn't have that pathname.  "objdump -T /usr/lib/x86_64-linux-gnu/libresolv_wrapper.so" shows __res_nsearch but not ___res_nsearch.
Comment 3 Andreas Schneider 2023-04-06 06:09:09 UTC
Looks like we have a symbol with an additional underscore and need to wrap that too.

If I create a patch, can you test it?
Comment 4 Andreas Schneider 2023-04-06 09:59:46 UTC
$ /usr/lib64/libc.so.6 
GNU C Library (GNU libc) stable release version 2.36.
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Compiled by GNU CC version 12.2.1 20221121 (Red Hat 12.2.1-4).
libc ABIs: UNIQUE IFUNC ABSOLUTE
Minimum supported kernel: 3.2.0
For bug reporting instructions, please see:
<https://www.gnu.org/software/libc/bugs.html>.

$ objdump --dynamic-syms /usr/lib64/libc.so.6 | grep res_nsearch
000000000013cb3e g    DF .text  000000000000009e (GLIBC_2.2.5) __res_nsearch
000000000013cb3e g    DF .text  000000000000009e  GLIBC_2.34  res_nsearch



$ /usr/lib64/libc.so.6
GNU C Library (GNU libc) stable release version 2.37 (git a704fd9a13).
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Configured for x86_64-suse-linux.
Compiled by GNU CC version 13.0.1 20230314 (experimental) [revision 42630fadbe248717859d61c0244c821c32b4e52c].
libc ABIs: UNIQUE IFUNC ABSOLUTE
Minimum supported kernel: 3.2.0
For bug reporting instructions, please see:
<http://bugs.opensuse.org>.

$ objdump --dynamic-syms /usr/lib64/libc.so.6 | grep res_nsearch
000000000013cb3e g    DF .text  000000000000009e (GLIBC_2.2.5) __res_nsearch
000000000013cb3e g    DF .text  000000000000009e  GLIBC_2.34  res_nsearch

$ objdump --dynamic-syms /usr/lib64/libresolv.so.2 | grep res_nsearch
<empty>

Is that something specific to Ubuntu?


asn@atb-devel-224:~$ cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.2 LTS"
asn@atb-devel-224:~$ objdump --dynamic-syms /usr/lib/x86_64-linux-gnu/libc.so.6 | grep res_nsearch
000000000014e2b0 g    DF .text  000000000000009f (GLIBC_2.2.5) __res_nsearch
000000000014e2b0 g    DF .text  000000000000009f  GLIBC_2.34  res_nsearch

asn@atb-devel-224:~$ objdump --dynamic-syms /usr/lib/x86_64-linux-gnu/libresolv.so.2 | grep res_nsearch
asn@atb-devel-224:~$


I don't see ___res_nsearch

However I see that we don't detect __res_* correctly. See

https://gitlab.com/cwrap/resolv_wrapper/-/merge_requests/9
Comment 5 Andreas Schneider 2023-04-06 10:10:15 UTC
The MR fails. Looks like we are fine.

Could you run with:

LD_DEBUG=symbols mytest

Then you will see how symbols are bound and which symbols exactly.
Comment 6 Greg Hudson 2023-04-07 05:59:17 UTC
Created attachment 17856 [details]
Debugging output

I've attached the full output.  The relevant part seems to be:

   3203906:     symbol=res_nsearch;  lookup in file=./t_locate_kdc [0]
   3203906:     symbol=res_nsearch;  lookup in file=/lib/x86_64-linux-gnu/libresolv_wrapper.so [0]
   3203906:     symbol=res_nsearch;  lookup in file=/me/krb5/build/./lib/libkrb5.so.3 [0]
   3203906:     symbol=res_nsearch;  lookup in file=/me/krb5/build/./lib/libcom_err.so.3 [0]
   3203906:     symbol=res_nsearch;  lookup in file=/me/krb5/build/./lib/libkrb5support.so.0 [0]
   3203906:     symbol=res_nsearch;  lookup in file=/lib/x86_64-linux-gnu/libresolv.so.2 [0]
   3203906:     symbol=res_nsearch;  lookup in file=/lib/x86_64-linux-gnu/libc.so.6 [0]

The output of "objdump --dynamic-syms /usr/lib/x86_64-linux-gnu/libc.so.6 | grep res_nsearch" on my system agrees with yours.  Looking at the glibc source, the function is defined as ___res_nsearch() (so is displayed that way in gdb) and then aliased to res_nsearch and __res_nsearch via symbol versioning magic.
Comment 7 Greg Hudson 2023-04-07 06:17:38 UTC
t_discover_uri.py works if I point it at a resolv_wrapper I build myself, either from current sources or the resolv_wrapper-1.1.7 tag.  And I see this:

$ objdump --dynamic-syms /lib/x86_64-linux-gnu/libresolv_wrapper.so  | grep nsearch
00000000000041d0 g    DF .text	0000000000000009  Base        __res_nsearch
$ objdump --dynamic-syms /me/rwinst/lib/libresolv_wrapper.so | grep nsearch
0000000000006596 g    DF .text	0000000000000048  Base        res_nsearch

So maybe Debian (or Ubuntu) broke the package build?
Comment 8 Andreas Schneider 2023-04-07 09:41:14 UTC
Yes, looks like something is wrong on their end. Maybe they didn't recompile resolv_wrapper after they updated glibc?