URL:
https://github.com/SSSD/sssd/pull/618
Title: #618: Add an option to only print the host public keys for sss_ssh_knownhostsproxy
jhrozek commented:
"""
I'm sorry, but I'm getting a segfault with the simple case of requesting a key for
a host:
valgrind:
```
libtool --mode=execute valgrind ./sss_ssh_knownhostsproxy -k client.ipa.test
==22333== Memcheck, a memory error detector
==22333== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==22333== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==22333== Command: /dev/shm/sssd/.libs/lt-sss_ssh_knownhostsproxy -k client.ipa.test
==22333==
==22333== Conditional jump or move depends on uninitialised value(s)
==22333== at 0x405099: main (sss_ssh_knownhostsproxy.c:310)
==22333==
==22333== Use of uninitialised value of size 8
==22333== at 0x405188: main (sss_ssh_knownhostsproxy.c:311)
==22333==
==22333==
==22333== HEAP SUMMARY:
==22333== in use at exit: 18,604 bytes in 6 blocks
==22333== total heap usage: 136 allocs, 130 frees, 118,122 bytes allocated
==22333==
==22333== LEAK SUMMARY:
==22333== definitely lost: 0 bytes in 0 blocks
==22333== indirectly lost: 0 bytes in 0 blocks
==22333== possibly lost: 0 bytes in 0 blocks
==22333== still reachable: 18,604 bytes in 6 blocks
==22333== suppressed: 0 bytes in 0 blocks
==22333== Rerun with --leak-check=full to see details of leaked memory
==22333==
==22333== For counts of detected and suppressed errors, rerun with: -v
==22333== Use --track-origins=yes to see where uninitialised values come from
==22333== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
```
gdb:
```
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff35103b0 in __memcmp_avx2_movbe () from /lib64/libc.so.6
Missing separate debuginfos, use: dnf debuginfo-install dbus-libs-1.12.8-1.fc27.x86_64
glib2-2.54.3-2.fc27.x86_64 libbasicobjects-0.1.1-36.fc27.x86_64
libcollection-0.7.0-36.fc27.x86_64 libcrypt-nss-2.26-28.fc27.x86_64
libdhash-0.5.0-36.fc27.x86_64 libgcc-7.3.1-5.fc27.x86_64 libgcrypt-1.8.1-1.fc27.x86_64
libgpg-error-1.27-3.fc27.x86_64 libini_config-1.3.1-36.fc2
7.x86_64 libldb-1.3.2-1.fc27.x86_64 libpath_utils-0.2.1-33.fc27.x86_64
libref_array-0.1.5-36.fc27.x86_64 libselinux-2.7-3.fc27.x86_64
libtalloc-2.1.13-1.fc27.x86_64 libtdb-1.3.15-2.fc27.x86_64 libtevent-0.9.36-1.fc27.x86_64
lz4-libs-1.8.0-1.fc27.x86_64 nspr-4.19.0-1.fc27.x86_64 nss-3.37.3-1.0.fc27.x86_64
nss-softokn-freebl-3.37.3-1.0.fc27.x86_64 nss-util-3.37.3-
1.0.fc27.x86_64 pcre-8.42-2.fc27.x86_64 pcre2-10.31-5.fc27.x86_64 popt-1.16-12.fc27.x86_64
systemd-libs-234-11.git5f8984e.fc27.x86_64 xz-libs-5.2.3-4.fc27.x86_64
(gdb) bt
#0 0x00007ffff35103b0 in __memcmp_avx2_movbe () from /lib64/libc.so.6
#1 0x00007ffff7bae740 in sss_ssh_format_pubkey (mem_ctx=0x611d30, pubkey=0x7ffff7ffeb70,
result=0x7fffffffd988) at /sssd/src/util/sss_ssh.c:162
#2 0x00007ffff7bae966 in sss_ssh_print_pubkey (pubkey=0x7ffff7ffeb70) at
/sssd/src/util/sss_ssh.c:230
#3 0x00000000004050d0 in main (argc=3, argv=0x7fffffffe098) at
/sssd/src/sss_client/ssh/sss_ssh_knownhostsproxy.c:312
(gdb) bt full
#0 0x00007ffff35103b0 in __memcmp_avx2_movbe () from /lib64/libc.so.6
No symbol table info available.
#1 0x00007ffff7bae740 in sss_ssh_format_pubkey (mem_ctx=0x611d30, pubkey=0x7ffff7ffeb70,
result=0x7fffffffd988) at /sssd/src/util/sss_ssh.c:162
tmp_ctx = 0x611e60
ret = 0
blob = 0x7ffff7ff5000 ""
algo = 0x0
out = 0x0
i = 0
len = 0
#2 0x00007ffff7bae966 in sss_ssh_print_pubkey (pubkey=0x7ffff7ffeb70) at
/sssd/src/util/sss_ssh.c:230
tmp_ctx = 0x611d30
repr = 0x0
repr_break = 0x0
ret = 0
__FUNCTION__ = "sss_ssh_print_pubkey"
#3 0x00000000004050d0 in main (argc=3, argv=0x7fffffffe098) at
/sssd/src/sss_client/ssh/sss_ssh_knownhostsproxy.c:312
i = 0
mem_ctx = 0x60f130
pc_debug = 16
pc_port = 22
pc_domain = 0x0
pc_host = 0x7fffffffe38c "client.ipa.test"
pc_args = 0x0
pc_pubkeys = 1
long_options = {{longName = 0x0, shortName = 0 '\000', argInfo = 4, arg =
0x607260 <poptHelpOptions@@LIBPOPT_0>, val = 0, descrip = 0x4057a7 "Help
options:",
argDescrip = 0x0}, {longName = 0x4057b5 "debug", shortName = 0
'\000', argInfo = 1073741826, arg = 0x7fffffffd9c4, val = 0,
descrip = 0x4057bb "The debug level to run with", argDescrip = 0x0},
{longName = 0x4057d7 "port", shortName = 112 'p', argInfo = 2, arg =
0x7fffffffd9c8, val = 0,
descrip = 0x4057e0 "The port to use to connect to the host",
argDescrip = 0x0}, {longName = 0x405807 "domain", shortName = 100 'd',
argInfo = 1, arg = 0x7fffffffd9f0,
val = 0, descrip = 0x40580e "The SSSD domain to use", argDescrip =
0x0}, {longName = 0x405825 "pubkey", shortName = 107 'k', argInfo = 0,
arg = 0x7fffffffd9cc, val = 0,
descrip = 0x405830 "Print the host ssh public keys", argDescrip =
0x0}, {longName = 0x0, shortName = 0 '\000', argInfo = 0, arg = 0x0, val = 0,
descrip = 0x0,
argDescrip = 0x0}}
pc = 0x60f140
strport = "22\000\177\000"
ai_hint = {ai_flags = 1058, ai_family = 0, ai_socktype = 1, ai_protocol = 6,
ai_addrlen = 0, ai_addr = 0x0, ai_canonname = 0x0, ai_next = 0x0}
ai = 0x611c80
canonhost =
"\300\333\377\377\377\177\000\000\000\000\000\000\001\000\000\000\220\331\377\367\377\177\000\000\344\207\335\367\377\177\000\000\377\377\377\377\000\000\000\000\200\317o\367\377\177\000\000\000\060<\363\377\177\000\000\300\031\376\367\377\177\000\000\320Y\377\367\377\177\000\000\a\000\000\000)\000\000\000\200\335\377\377\377\177\000\000\244\
351N\363\377\177", '\000' <repeats 22 times>,
"\001\000\000\000\b\242\377\367\377\177\000\000\000\000\000\000 ",
'\000' <repeats 19 times>,
"Ȍ\335\367\377\177\000\000\a\000\000\000\000\000\000\000\060\204\335\367\377\177\000\000\220\331\377\367\377\177\000\000\a\000\000\000\006\000\000\000\200\335\377\377\377\177\000\000p"...
host = 0x611c60 "client.ipa.test"
ent = 0x7ffff7ffe6d0
ret = 2
__FUNCTION__ = "main"
(gdb) frame 3
#3 0x00000000004050d0 in main (argc=3, argv=0x7fffffffe098) at
/sssd/src/sss_client/ssh/sss_ssh_knownhostsproxy.c:312
312 ret = sss_ssh_print_pubkey(&ent->pubkeys[i]);
(gdb) p ent->pubkeys[0]
$1 = {data = 0x64762d78756e696c <error: Cannot access memory at address
0x64762d78756e696c>, data_len = 13843330067492723}
(gdb) quit
```
"""
See the full comment at
https://github.com/SSSD/sssd/pull/618#issuecomment-406649233