base-krb5 issues (segfaults when adding principals in openssl)

From: Alexander Leidinger <Alexander_at_Leidinger.net>
Date: Tue, 03 Oct 2023 13:02:04 UTC
Hi,

has someone else issues with krb5 on -current when adding principals?

With -current as of 2023-09-11 I get a segfault in openssl:
---snip---
Reading symbols from /usr/bin/kadmin...
Reading symbols from /usr/lib/debug//usr/bin/kadmin.debug...
[New LWP 270171]
btCore was generated by `kadmin -l'.
Program terminated with signal SIGSEGV, Segmentation fault.
Address not mapped to object.
#0  0x0000000000000000 in ?? ()
(gdb) bt
#0  0x0000000000000000 in ?? ()
#1  0x00000e118da145f8 in ARCFOUR_string_to_key (context=0x44f9fba1a000, 
enctype=KRB5_ENCTYPE_ARCFOUR_HMAC_MD5, password=..., salt=..., 
opaque=..., key=0x44f9fba211d8)
     at /space/system/usr_src/crypto/heimdal/lib/krb5/salt-arcfour.c:84
#2  0x00000e118da156e9 in krb5_string_to_key_data_salt_opaque 
(enctype=KRB5_ENCTYPE_ARCFOUR_HMAC_MD5, salt=..., opaque=..., 
context=<optimized out>, password=...,
     key=<optimized out>) at 
/space/system/usr_src/crypto/heimdal/lib/krb5/salt.c:201
#3  krb5_string_to_key_data_salt (context=0x44f9fba1a000, 
enctype=KRB5_ENCTYPE_ARCFOUR_HMAC_MD5, password=..., salt=..., 
key=0x44f9fba211d8)
     at /space/system/usr_src/crypto/heimdal/lib/krb5/salt.c:173
#4  0x00000e118da158cb in krb5_string_to_key_salt 
(context=0x44f9fba4bc60, context@entry=0x44f9fba1a000, 
enctype=-1980854121, password=0x0,
     password@entry=0xe1189ee9510 "1kad$uwi6!", salt=..., key=0x5) at 
/space/system/usr_src/crypto/heimdal/lib/krb5/salt.c:225
#5  0x00000e118ba75423 in hdb_generate_key_set_password 
(context=0x44f9fba1a000, principal=<optimized out>, 
password=password@entry=0xe1189ee9510 "1kad$uwi6!",
     keys=keys@entry=0xe1189ee9210, 
num_keys=num_keys@entry=0xe1189ee9208) at 
/space/system/usr_src/crypto/heimdal/lib/hdb/keys.c:381
#6  0x00000e118ca91c9a in _kadm5_set_keys 
(context=context@entry=0x44f9fba1a140, ent=ent@entry=0xe1189ee9258, 
password=0x1 <error: Cannot access memory at address 0x1>,
     password@entry=0xe1189ee9510 "1kad$uwi6!") at 
/space/system/usr_src/crypto/heimdal/lib/kadm5/set_keys.c:51
#7  0x00000e118ca8caac in kadm5_s_create_principal 
(server_handle=0x44f9fba1a140, princ=<optimized out>, mask=<optimized 
out>, password=0xe1189ee9510 "1kad$uwi6!")
     at /space/system/usr_src/crypto/heimdal/lib/kadm5/create_s.c:172
#8  0x00000e0969e1a57b in add_one_principal (name=<optimized out>, 
rand_key=0, rand_password=0, use_defaults=0, password=0xe1189ee9510 
"1kad$uwi6!", key_data=0x0,
     max_ticket_life=<optimized out>, max_renewable_life=<optimized out>, 
attributes=0x0, expiration=<optimized out>, pw_expiration=0x0)
     at /space/system/usr_src/crypto/heimdal/kadmin/ank.c:141
#9  add_new_key (opt=opt@entry=0xe1189ee9960, argc=argc@entry=1, 
argv=0x44f9fba49238, argv@entry=0x44f9fba49230) at 
/space/system/usr_src/crypto/heimdal/kadmin/ank.c:243
#10 0x00000e0969e1e124 in add_wrap (argc=<optimized out>, 
argv=0x44f9fba49230) at kadmin-commands.c:210
#11 0x00000e0969e23945 in sl_command (cmds=<optimized out>, argc=2, 
argv=0x44f9fba49230) at 
/space/system/usr_src/crypto/heimdal/lib/sl/sl.c:209
#12 sl_command_loop (cmds=cmds@entry=0xe0969e282a0 <commands>, 
prompt=prompt@entry=0xe0969e15cca "kadmin> ", data=<optimized out>)
     at /space/system/usr_src/crypto/heimdal/lib/sl/sl.c:328
#13 0x00000e0969e1d876 in main (argc=<optimized out>, argv=<optimized 
out>) at /space/system/usr_src/crypto/heimdal/kadmin/kadmin.c:275
(gdb) up 1
#1  0x00000e118da145f8 in ARCFOUR_string_to_key (context=0x44f9fba1a000, 
enctype=KRB5_ENCTYPE_ARCFOUR_HMAC_MD5, password=..., salt=..., 
opaque=..., key=0x44f9fba211d8)
     at /space/system/usr_src/crypto/heimdal/lib/krb5/salt-arcfour.c:84
84              EVP_DigestUpdate (m, &p, 1);
(gdb) list
79
80          /* LE encoding */
81          for (i = 0; i < len; i++) {
82              unsigned char p;
83              p = (s[i] & 0xff);
84              EVP_DigestUpdate (m, &p, 1);
85              p = (s[i] >> 8) & 0xff;
86              EVP_DigestUpdate (m, &p, 1);
87          }
88
(gdb) print i
$1 = 0
(gdb) print len
$2 = <optimized out>
(gdb) print p
$3 = 49 '1'
(gdb) print m
$4 = (EVP_MD_CTX *) 0x43e31de4bc60
(gdb) print *m
$5 = {reqdigest = 0x17e678afd470, digest = 0x0, engine = 0x0, flags = 0, 
md_data = 0x0, pctx = 0x0, update = 0x0, algctx = 0x0, fetched_digest = 
0x0}
(gdb)
---snip---

Bye,
Alexander.

-- 
http://www.Leidinger.net Alexander@Leidinger.net: PGP 0x8F31830F9F2772BF
http://www.FreeBSD.org    netchild@FreeBSD.org  : PGP 0x8F31830F9F2772BF