From nobody Thu Jul 31 14:55:23 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 4btBvz18YXz63ws0; Thu, 31 Jul 2025 14:55:27 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from omta004.cacentral1.a.cloudfilter.net (omta002.cacentral1.a.cloudfilter.net [3.97.99.33]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "Client", Issuer "CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4btBvy4YJTz3JZw; Thu, 31 Jul 2025 14:55:26 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Authentication-Results: mx1.freebsd.org; dkim=none; spf=pass (mx1.freebsd.org: domain of cy.schubert@cschubert.com designates 3.97.99.33 as permitted sender) smtp.mailfrom=cy.schubert@cschubert.com; dmarc=permerror reason="p tag has invalid value: quarantine rua=mailto:p[ostmaster@cschubert.com" header.from=cschubert.com (policy=permerror) Received: from shw-obgw-4003a.ext.cloudfilter.net ([10.228.9.183]) by cmsmtp with ESMTPS id hPDku1Ykj5MqyhUgouSfST; Thu, 31 Jul 2025 14:55:26 +0000 Received: from spqr.komquats.com ([70.66.136.217]) by cmsmtp with ESMTPSA id hUgluUYcpWbOahUgnucIMt; Thu, 31 Jul 2025 14:55:25 +0000 X-Auth-User: cschuber X-Authority-Analysis: v=2.4 cv=Q5lx4J2a c=1 sm=1 tr=0 ts=688b83de a=h7br+8Ma+Xn9xscxy5znUg==:117 a=h7br+8Ma+Xn9xscxy5znUg==:17 a=kj9zAlcOel0A:10 a=Wb1JkmetP80A:10 a=6I5d2MoRAAAA:8 a=EkcXrb_YAAAA:8 a=hEh3JUyyAAAA:8 a=zdPUvaFGAAAA:8 a=04oDvr9pAAAA:8 a=YxBL1-UpAAAA:8 a=gxyqz0aHM-HxaGc6Q_gA:9 a=CjuIK1q_8ugA:10 a=LK5xJRSDVpKd5WXXoEvA:22 a=fvD0gfNcX4AKPV7IvcuC:22 a=sT4bYkpex2i6d5iwGOJT:22 a=Ia-lj3WSrqcvXOmTRaiG:22 Received: from slippy.cwsent.com (slippy [10.1.1.91]) by spqr.komquats.com (Postfix) with ESMTP id 695AFE9; Thu, 31 Jul 2025 07:55:23 -0700 (PDT) Received: by slippy.cwsent.com (Postfix, from userid 1000) id 5EE98286; Thu, 31 Jul 2025 07:55:23 -0700 (PDT) X-Mailer: exmh version 2.9.0 11/07/2018 with nmh-1.8+dev Reply-to: Cy Schubert From: Cy Schubert X-os: FreeBSD X-Sender: cy@cwsent.com X-URL: http://www.cschubert.com/ To: Rick Macklem cc: Benjamin Kaduk , Konstantin Belousov , Cy Schubert , Jessica Clarke , Cy Schubert , "src-committers@freebsd.org" , "dev-commits-src-all@freebsd.org" , "dev-commits-src-main@freebsd.org" Subject: Re: git: c7da9fb90b0b - main - KRB5: Enable MIT KRB5 by default In-reply-to: References: <202507211410.56LEAD6J066633@gitrepo.freebsd.org> <47C3CC37-6F32-4376-900A-B5387B9817D5@freebsd.org> <20250721144645.3BA391BE@slippy.cwsent.com> <20250722155941.AC7EB121@slippy.cwsent.com> Comments: In-reply-to Rick Macklem message dated "Thu, 31 Jul 2025 07:18:59 -0700." 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 Content-Type: text/plain; charset=us-ascii Date: Thu, 31 Jul 2025 07:55:23 -0700 Message-Id: <20250731145523.5EE98286@slippy.cwsent.com> X-CMAE-Envelope: MS4xfNjJPdECMeWfwreD5CVbnG8D9gxKxg+inxuTU8Hy/TPXnEYIlK/23csYESfKWR98zPrBVvuP8w4Pe+KzxN/uR0J8Rq/X9IkkpHDjEeZeX+BpzzftHyPK t2qNGEIzUbv4SXXrfZng5qQ1nEc7GcRysGtYh+HPwfSHuFgf08pcxjpp00thnwsuRW7F//lgutdRmcFYINICsvfwFktLJ2+9msIaLq1H5Pi3CSX/bLpA4L78 TtJRHUjPFjLZvMxoL7vWApuGPi5CfP0lbRen4UQ29RTa9qQFVow7//QoP+tcpADKyOybWWHC9j9oqpRuA5jQ7BkDRwrmH72YNGFWbQM3ClMkzNQZF7QrlFz8 yVhu9wq/OSqYT1DNoGiXph4Bn0XNICe0rVftP11nvYniCterC9t9xUaEgRejVXuTqwVinBuE4NJ1uked3xJU9/uQmiJEfxiSVvkCx5aBenQYHwfpcAA= X-Spamd-Result: default: False [-3.30 / 15.00]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-0.999]; MV_CASE(0.50)[]; RWL_MAILSPIKE_EXCELLENT(-0.40)[3.97.99.33:from]; R_SPF_ALLOW(-0.20)[+ip4:3.97.99.32/31]; RCVD_IN_DNSWL_LOW(-0.10)[3.97.99.33:from]; MIME_GOOD(-0.10)[text/plain]; TO_DN_SOME(0.00)[]; RCVD_TLS_LAST(0.00)[]; FREEMAIL_CC(0.00)[gmail.com,cschubert.com,freebsd.org]; TO_DN_EQ_ADDR_SOME(0.00)[]; RCVD_COUNT_THREE(0.00)[4]; FREEMAIL_TO(0.00)[gmail.com]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; DMARC_BAD_POLICY(0.00)[cschubert.com : p tag has invalid value: quarantine rua=mailto:p[ostmaster@cschubert.com]; RCVD_VIA_SMTP_AUTH(0.00)[]; HAS_REPLYTO(0.00)[Cy.Schubert@cschubert.com]; TO_MATCH_ENVRCPT_SOME(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; ASN(0.00)[asn:16509, ipnet:3.96.0.0/15, country:US]; MLMMJ_DEST(0.00)[dev-commits-src-all@freebsd.org,dev-commits-src-main@freebsd.org]; RCPT_COUNT_SEVEN(0.00)[9]; R_DKIM_NA(0.00)[]; TAGGED_RCPT(0.00)[]; REPLYTO_EQ_FROM(0.00)[] X-Rspamd-Queue-Id: 4btBvy4YJTz3JZw X-Spamd-Bar: --- In message , Rick Macklem writes: > On Thu, Jul 31, 2025 at 6:51=E2=80=AFAM Rick Macklem m> wrote: > > > > On Thu, Jul 31, 2025 at 6:07=E2=80=AFAM Rick Macklem com> wrote: > > > > > > On Wed, Jul 30, 2025 at 9:24=E2=80=AFPM Benjamin Kaduk om> wrote: > > > > > > > > On Wed, Jul 30, 2025 at 10:36=E2=80=AFAM Rick Macklem mail.com> wrote: > > > >> > > > >> On Mon, Jul 28, 2025 at 3:32=E2=80=AFPM Benjamin Kaduk l.com> wrote: > > > >> > > > > >> > On Mon, Jul 28, 2025 at 3:04=E2=80=AFPM Benjamin Kaduk ail.com> wrote: > > > >> >> > > > >> >> > > > >> >> Note that MIT krb5 provides the gss_krb5_export_lucid_sec_context= > () API that does a lot of the work of getting useful bits out of an establi= > shed GSS security context. > > > >> >> > > > >> > > > > >> > > > > >> > > > > >> > > > > >> > And a bit more context on what is going on here and why kgssapi ha= > s to care: > > > >> > The GSS-API (RFC 2743) is all about a way to "establish a security= > context" (i.e., do crypto negotiation, authentication, sometimes authoriza= > tion, etc.) between two entities, the initiator and the acceprot, and then = > exchanging protected messages between the two (which can be either encrypte= > d or just integrity protection tags for otherweise cleartext data); later e= > xtensions included the ability to produce identical PRF output on both part= > ies, etc.. The details are "mechanism-specific", and for this purpose we'r= > e exclusively talking about the krb5 mechanism. The steps to establish the= > security context are complicated and sometimes fiddly, and in the general = > case can require a large number of round-trips between the initiator and ac= > ceptor before the security context is established. The individual message-= > protection parts are comparatively simple and amendable to implementation i= > n the kernel for processing efficiency. > > > >> > RFC 2743 also defines functions for GSS_Export_sec_context() and G= > SS_Import_sec_context(), that are designed essentially to pass information = > about an established security context from one process to another on the sa= > me machine (which are presumably using the same implementation and version = > of the implementation), so the contents of the exported blob are opaque and= > implementation-specific. We are abusing that mechanism to export informat= > ion about the security context that gssd has established and feed that info= > rmation into the kernel implementation of the per-message processing routin= > es. At present, this necessarily entails knowing the details of the implem= > entation-specific opaque blob that is the "export sec context token", which= > is what the sys/kgssapi/krb5/krb5_mech.c code is doing. But if we can get= > the information we want without breaking the abstraction barrier, such as = > via the gss_krb5_export_lucid_sec_context() API, we are in a more robust po= > sture overall and somewhat future-proofed against future evolution by MIT k= > rb5. > > > >> > (I note that recent Heimdal versions seem to also expose a gss_krb= > 5_export_lucid_sec_context() API, so part of the problem is just that the H= > eimdal 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 the = > 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_external= > _lucid_ctx_v1() > > > >> function. This function only knows about the 0 and 1 setting for gct= > x->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 RF= > C 1964 format) or 1 (for the "CFX" format of RFC 4121, with wider sequence = > numbers for message-protection formats, etc.). So maybe it's worth posting= > 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, ctx= > , > > > 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 f= > rom the > > > string + a 1 byte), it returns major =3D=3D GSS_S_COMPLETE, but no data= > 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_cont= > ext() > > returns GSS_S_BAD_MECH. Looking at the src, that error has to be fro= > m > > gss_inquire_sec_context_by_oid(). So, same function fails, but a dif= > ferent > > 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 that > > 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 reas= > on? > > > > I'm going to try building krb5 from ports and linking to that, to see if = > it > > does the same thing. > Finally some good news... > All I did was "pkg install krb5" and then linked the gssd to the libraries = > in > /usr/local/lib and it worked!! I will double check the generated gssapi.h from its .et files in krb5/lib/gssapi/generic. > > 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 defi= > ne > GSS_DLLIMP for example.) This is generated from one of the .et files. > > I'm going to leave figuring out why the libraries in /usr/lib are messed up > to someone else. > > rick > -- Cheers, Cy Schubert FreeBSD UNIX: Web: https://FreeBSD.org NTP: Web: https://nwtime.org e**(i*pi)+1=0