From nobody Thu Jul 31 14:35:07 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4btBSt6V6Wz63vbr; Thu, 31 Jul 2025 14:35:26 +0000 (UTC) (envelope-from rick.macklem@gmail.com) Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "WR4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4btBSt0rqrz3HFs; Thu, 31 Jul 2025 14:35:26 +0000 (UTC) (envelope-from rick.macklem@gmail.com) Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20230601 header.b=jBkjDSDX; spf=pass (mx1.freebsd.org: domain of rick.macklem@gmail.com designates 2a00:1450:4864:20::533 as permitted sender) smtp.mailfrom=rick.macklem@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-6155e75a9acso656501a12.0; Thu, 31 Jul 2025 07:35:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753972519; x=1754577319; darn=freebsd.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=RvZ/Ec4FwdZmQsVhku36uHWeA5wHf7cDP4/x76ozV7Y=; b=jBkjDSDXhdYhpgTU6kqC92stE0q/GwwUZhKeYu+yuHdkGm7NtrTpexL4j3csLyY9SE m46OgpBgGU2KtAnVIzjKoLBWEHjAQ8/n5mfV805Suwjio0JeXlmx0d0PDGS2ZAJLXVbQ GihaidzbNjH/hJ6uo8njQLSRjAdnMJh/aemghA6zXLnMu9nMQ1BATacuaH0gaGTfG5YK lejMAwfFr8TVXN/iAD/t4YAFs/shqXlKlRJmEj7CNZr7WfewCUw1aE4eGpICQeeHSwVz ou9iYKfw+F3zrZS+q2yMXyYwdnwsdM1QqS1ahlvPp91hQRYanuWP5DSAqVK4etPO3uai Xr0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753972519; x=1754577319; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RvZ/Ec4FwdZmQsVhku36uHWeA5wHf7cDP4/x76ozV7Y=; b=ruwtMZm8IQun0GOmdMI0K9YiNAHhsyw58S5RjEQ07L8DKSqYr6vrNsjlM2w4yEvq6N aojp3Hg5QCXZRGWuJyO7Z9N3MooWVsgp1g7UxqK1jZVTE3ycqBQEgW/3XRAI9beFqt5h 5XPUkbocncn/2c4cgXmJFOhzrOjgwyUn+mupu455q3rS3+6K7B4YsTyUHjnpso09BOc0 V1NS1ybZAVJU2SOVFDB7oheYl2cBUvScf15YOuF+QwNpltrFfHUZ4ytWsSGGj3SIGwpb OVgK8RSD6I+5Q0zBNrjvSwTQ3sZB8XzFV00JER1d6uX6CwIulzVvN0gGbKRaBdgQf0w5 +P/A== X-Forwarded-Encrypted: i=1; AJvYcCVAMTr4L/QgeXIACAiFV/QHudqArl0tZRc/qIrJoEisonSQX313CpeIpugx601yoLYpc3Jsn2q9OFdPwnqrPiw=@freebsd.org, AJvYcCVCDms+TrPamaCBK0X+pijsZKJrhw3jzDrKkUpZ6fRVh/Z6JpJ+P/PTwWCa3WjTTkrG5Ypj6Mx12QHo7USjXXrMGEJM8Q==@freebsd.org, AJvYcCVEVePU33KaWosmqKYesjHimEAa8FI8LFrGbXCqFnUoMpamsCM1zw6yVD3ihGH4eTHsK+vFIclu@freebsd.org, AJvYcCWbos9kqvgd1/6o69cx339yI335h25d9SwiAHfEVjDQP62TBmUMQlGvDIAMXB8vMURzXQ==@freebsd.org, AJvYcCWn6JVc9RuL63vN5CmlxdlU+HwWFYciNK/hlAsw8blLM0mh0eXoToWWPfEZzrmJf1g5zFl2PtB8nYUD8OX8PZ2h6kXHYVk=@freebsd.org X-Gm-Message-State: AOJu0YzzNRNXZhq87KQRcUIRyw2FojNVA06W00ySjJhlKSx7wZ7/OzbH 1k2rO5su3Eu8lHKSVIg+QpAYlB2zBvFYUYKNr+Vp7p7COY3W52Vo3EZVszi5fkgbNurw+ak39MI Kjs1m6tATQoMApx9xedNkf1Z5vnUBS46DlE4= X-Gm-Gg: ASbGncvN+eOHN0z8wX5LWHa1XRVy43PCFmWETzol7oAvwZmnmx80IFXiBLIC+xHSwNA mZrG5Wz8/fT0dcM61f1r4vg6DaVr9wXUJ3dCPHHn4iObR6l8kEodNp482eof50Nwuu3rNSEwlMq 4Z1mTq43NFfWfbMzrys7tBpQ8Mr7PRWmvKv8tMCGxn+7o0ghwAOZxR6BHlSdwePDeBuvfPHy0UG mz3HefJQKiPsfw+6LjW47Ei9X4YG3TZh1s7a+E= X-Google-Smtp-Source: AGHT+IEKoa73AZFgn+JylFw3hL7vxuEVuHjAHCnJeJNi1xHIUygmY2JREcGGKf/BVbxaOd8a+/DMaAvvIx3HWDvu8II= X-Received: by 2002:a05:6402:2756:b0:615:6482:7498 with SMTP id 4fb4d7f45d1cf-615872191b9mr7480322a12.31.1753972519117; Thu, 31 Jul 2025 07:35:19 -0700 (PDT) List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 References: <202507211410.56LEAD6J066633@gitrepo.freebsd.org> <47C3CC37-6F32-4376-900A-B5387B9817D5@freebsd.org> <20250721144645.3BA391BE@slippy.cwsent.com> <20250722155941.AC7EB121@slippy.cwsent.com> In-Reply-To: From: Rick Macklem Date: Thu, 31 Jul 2025 07:35:07 -0700 X-Gm-Features: Ac12FXyxUmUFB3KDb8KZGOuLAb6YmaSzL82o6wvecyv7NqhhekstwaiJga-hL3o Message-ID: Subject: Re: git: c7da9fb90b0b - main - KRB5: Enable MIT KRB5 by default To: Benjamin Kaduk Cc: Konstantin Belousov , Cy Schubert , Jessica Clarke , Cy Schubert , "src-committers@freebsd.org" , "dev-commits-src-all@freebsd.org" , "dev-commits-src-main@freebsd.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-4.00 / 15.00]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_SHORT(-1.00)[-0.999]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; R_SPF_ALLOW(-0.20)[+ip6:2a00:1450:4000::/36:c]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20230601]; MIME_GOOD(-0.10)[text/plain]; TO_DN_EQ_ADDR_SOME(0.00)[]; FREEMAIL_TO(0.00)[gmail.com]; RCVD_TLS_LAST(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; DWL_DNSWL_NONE(0.00)[gmail.com:dkim]; ARC_NA(0.00)[]; FREEMAIL_FROM(0.00)[gmail.com]; TO_DN_SOME(0.00)[]; TAGGED_FROM(0.00)[]; DKIM_TRACE(0.00)[gmail.com:+]; FREEMAIL_ENVFROM(0.00)[gmail.com]; MID_RHS_MATCH_FROMTLD(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; FREEMAIL_CC(0.00)[gmail.com,cschubert.com,freebsd.org]; MLMMJ_DEST(0.00)[dev-commits-src-all@freebsd.org,dev-commits-src-main@freebsd.org]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US]; RCPT_COUNT_SEVEN(0.00)[8]; MISSING_XM_UA(0.00)[]; RCVD_COUNT_ONE(0.00)[1]; RCVD_IN_DNSWL_NONE(0.00)[2a00:1450:4864:20::533:from] X-Rspamd-Queue-Id: 4btBSt0rqrz3HFs X-Spamd-Bar: --- On Thu, Jul 31, 2025 at 7:18=E2=80=AFAM Rick Macklem wrote: > > On Thu, Jul 31, 2025 at 6:51=E2=80=AFAM Rick Macklem wrote: > > > > On Thu, Jul 31, 2025 at 6:07=E2=80=AFAM Rick Macklem wrote: > > > > > > On Wed, Jul 30, 2025 at 9:24=E2=80=AFPM Benjamin Kaduk wrote: > > > > > > > > On Wed, Jul 30, 2025 at 10:36=E2=80=AFAM Rick Macklem wrote: > > > >> > > > >> On Mon, Jul 28, 2025 at 3:32=E2=80=AFPM Benjamin Kaduk wrote: > > > >> > > > > >> > On Mon, Jul 28, 2025 at 3:04=E2=80=AFPM Benjamin Kaduk wrote: > > > >> >> > > > >> >> > > > >> >> Note that MIT krb5 provides the gss_krb5_export_lucid_sec_conte= xt() API that does a lot of the work of getting useful bits out of an estab= lished GSS security context. > > > >> >> > > > >> > > > > >> > > > > >> > > > > >> > > > > >> > And a bit more context on what is going on here and why kgssapi = has to care: > > > >> > The GSS-API (RFC 2743) is all about a way to "establish a securi= ty context" (i.e., do crypto negotiation, authentication, sometimes authori= zation, etc.) between two entities, the initiator and the acceprot, and the= n exchanging protected messages between the two (which can be either encryp= ted or just integrity protection tags for otherweise cleartext data); later= extensions included the ability to produce identical PRF output on both pa= rties, etc.. The details are "mechanism-specific", and for this purpose we= 're exclusively talking about the krb5 mechanism. The steps to establish t= he security context are complicated and sometimes fiddly, and in the genera= l case can require a large number of round-trips between the initiator and = acceptor before the security context is established. The individual messag= e-protection parts are comparatively simple and amendable to implementation= in the kernel for processing efficiency. > > > >> > RFC 2743 also defines functions for GSS_Export_sec_context() and= GSS_Import_sec_context(), that are designed essentially to pass informatio= n about an established security context from one process to another on the = same machine (which are presumably using the same implementation and versio= n of the implementation), so the contents of the exported blob are opaque a= nd implementation-specific. We are abusing that mechanism to export inform= ation about the security context that gssd has established and feed that in= formation into the kernel implementation of the per-message processing rout= ines. At present, this necessarily entails knowing the details of the impl= ementation-specific opaque blob that is the "export sec context token", whi= ch is what the sys/kgssapi/krb5/krb5_mech.c code is doing. But if we can g= et the information we want without breaking the abstraction barrier, such a= s via the gss_krb5_export_lucid_sec_context() API, we are in a more robust = posture overall and somewhat future-proofed against future evolution by MIT= krb5. > > > >> > (I note that recent Heimdal versions seem to also expose a gss_k= rb5_export_lucid_sec_context() API, so part of the problem is just that the= Heimdal in base is so old.) > > > >> > > > >> Well, here's some "not so good" news... > > > >> I've been trying to use gss_inquire_sec_context_by_oid(..) with th= e oid > > > >> for the GSS_KRB5_EXPORT_LUCID_SEC_CONTEXT_OID with version 1. > > > >> It kept failing. > > > >> The problem seems to be that "gctx->proto =3D=3D 4" in make_extern= al_lucid_ctx_v1() > > > >> function. This function only knows about the 0 and 1 setting for g= ctx->proto. > > > >> > > > >> Any ideas, rick > > > >> > > > > > > > > > > > > I'm not seeing anything to suggest that a "gctx->proto" value of 4 = is ever expected; it looks like it's supposed to just be 0 (for the legacy = RFC 1964 format) or 1 (for the "CFX" format of RFC 4121, with wider sequenc= e numbers for message-protection formats, etc.). So maybe it's worth posti= ng your current WIP somewhere to take a closer look at what's going on. > > > > > > Yea, the debugging I did was flawed (I probably got the wrong offset > > > in the structure). > > > It is weird, though. If I do gss_inquire_sec_context_by_oid(&minor, c= tx, > > > OID_FOR_GSS_INQUIRE_SSPI_SESSION_KEY, &key), it > > > works and gives me the key and encryption type. > > > > > > If I do the same, but with the 12 byte OID for LUCID v1 (the 11 bytes= from the > > > string + a 1 byte), it returns major =3D=3D GSS_S_COMPLETE, but no da= ta and > > > a weird 39756046(decimal) or 0x25ea10e(hex) minor. > > > (Oh, and I tried gss_krb5_export_lucid_sec_context() and got the same > > > weird error.) > > --> Now (after doing a "make buildworld"), gss_krb5_export_lucid_sec_co= ntext() > > returns GSS_S_BAD_MECH. Looking at the src, that error has to be f= rom > > gss_inquire_sec_context_by_oid(). So, same function fails, but a d= ifferent > > error return? > > > > It looks like "gssint_get_mechanism (ctx->mech_type)" is failing. > > I'm currently just passing GSS_C_NULL_OID into gss_init_sec_context(), > > but I've also tried the Kerberos 9 byte OID (both work, in the sense th= at > > gss_init_sec_context() seems to work, except that the actual_mech_type > > returned by it has a bogus pointer in the reply). > > --> It looks like the "mech_type" field of "ctx" is busted, for some re= ason? > > > > I'm going to try building krb5 from ports and linking to that, to see i= f it > > does the same thing. > Finally some good news... > All I did was "pkg install krb5" and then linked the gssd to the librarie= s in > /usr/local/lib and it worked!! Just to clarify, "it" refers to the gss_krb5_export_lucid_sec_context() call. I now have to debug the patch that uses it to get the kerberized NFS mounts working. rick > > Now I can test/debug the changes. > > Btw, the stuff in /usr/local/include/gssapi are correct and not messed up > like the stuff in /usr/include/gssapi. (The ones in /usr/local/include de= fine > GSS_DLLIMP for example.) > > I'm going to leave figuring out why the libraries in /usr/lib are messed = up > to someone else. > > rick > > > > > rick > > > > > > > > Also, if I look at the actual_mech_type returned by gss_init_sec_cont= ext(), > > > I get an instant crash, because the "elements" pointer cannot be > > > accessed (this doesn't much matter, since the info should always be j= ust > > > the Kerberos OID). > > > --> I suspect there is some problem w.r.t. how the libraries are bein= g built? > > > > > > I'm now building from sources to try and dig into the library functio= ns. > > > > > > rick > > > > > > > > > > > From your previous message, > > > > > > > > > I am working on using gss_inquire_sec_context_by_oid(), which I t= hink is just a front-end to gss_krb5_export_lucid_sec_context()? If that do= esn't work, I'll switch to gss_krb5_export_lucid_sec_context(). (I am still= waiting for the day when there is another mechanism. I have heard rumbling= s w.r.t. a mechanism for the Oauth stuff, but as far as I know, about all t= hat they did was define an OID for it.) > > > > > > > > It looks like a front-end to the same core implementation at least = (technically not a wrapper for the public API, though). > > > > (There are a bunch of non-krb5 mechanisms, most not in terribly wid= espread use.) > > > > > > > > > Btw, do you have any experience porting KDC databases from Heimda= l to MIT? (At this point, Cy has done it, but after doing so, the passwords= all had to be reset. He thought he had used "--decrypt" when he dumped the= Heimdal KDC.) > > > > > > > > I do not have such experience, but the conventional way to do it in= volves an unencrypted dump (which I presume is what the aforementioned "--d= ecrypt" does). Heimdal and MIT use (or at least used, the last time I look= ed) different techniques for encrypting the per-principal data in the dump = file, so a trip through plaintext helps. I do remember reading about Heimd= al having grown some support for the MIT database format; the commit messag= e at https://github.com/heimdal/heimdal/commit/57f1545a46fdad9207a71903a56f= 3c1d1fff3a10 is perhaps a very high-level description of what is expected t= o be possible. > > > > > > > > -Ben