From nobody Mon Jun 16 18:52:49 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 4bLfJj6JXHz5yGhn; Mon, 16 Jun 2025 18:52:53 +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 4bLfJj17QDz3VQk; Mon, 16 Jun 2025 18:52:53 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Authentication-Results: mx1.freebsd.org; none Received: from shw-obgw-4004a.ext.cloudfilter.net ([10.228.9.227]) by cmsmtp with ESMTPS id R6u8uN6ss5MqyREwuuCaV9; Mon, 16 Jun 2025 18:52:52 +0000 Received: from spqr.komquats.com ([70.66.136.217]) by cmsmtp with ESMTPSA id REwsu91NNJhBPREwtulAbN; Mon, 16 Jun 2025 18:52:52 +0000 X-Auth-User: cschuber X-Authority-Analysis: v=2.4 cv=QY3Fvdbv c=1 sm=1 tr=0 ts=68506804 a=h7br+8Ma+Xn9xscxy5znUg==:117 a=h7br+8Ma+Xn9xscxy5znUg==:17 a=kj9zAlcOel0A:10 a=6IFa9wvqVegA:10 a=6I5d2MoRAAAA:8 a=EkcXrb_YAAAA:8 a=YxBL1-UpAAAA:8 a=J8UYeav3V4dppdFX0RAA:9 a=CjuIK1q_8ugA:10 a=LK5xJRSDVpKd5WXXoEvA:22 a=Ia-lj3WSrqcvXOmTRaiG:22 Received: from slippy.cwsent.com (slippy [10.1.1.91]) by spqr.komquats.com (Postfix) with ESMTP id D57EF40C; Mon, 16 Jun 2025 11:52:49 -0700 (PDT) Received: by slippy.cwsent.com (Postfix, from userid 1000) id CF79711A; Mon, 16 Jun 2025 11:52:49 -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: Shawn Webb cc: Cy Schubert , src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: 98f18cd98824 - main - pam_ksu: Move the realm free to end of function In-reply-to: References: <202506161842.55GIgf9M052877@gitrepo.freebsd.org> Comments: In-reply-to Shawn Webb message dated "Mon, 16 Jun 2025 18:46:08 -0000." 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: Mon, 16 Jun 2025 11:52:49 -0700 Message-Id: <20250616185249.CF79711A@slippy.cwsent.com> X-CMAE-Envelope: MS4xfM0PZGaKHp3L9MkubGq9eZQdl6zxVDMWOC5wYnw4TNsjgLP0wJG1p7FyJzQ9H25qWGzD/6IqxzqRFC/sSJlGnlbVmGs9SjL1mhwptF2IJEfGPwWctZ6t hunTPRjESfZ6G055FcM9vjt4wtC/OVCNi0t97ZT0cXRhtoCRnOnIpUWuWXC/MhxgTITfNC/5VtmNL6arFWTvjG6oi7qle8p4Lg6nWE/UW6C/Qx2VmQxsbH14 3uxnDZ/fKedeBQZkQHOvWkbY1xsBj4vdqM06AZYcVWr+Ci8Vz2LGidtYxfpCY7AFFqy5d6tz9Go2Wb7sdi6sdUJy7+o07gNueNIzlbKyBg+QvATEEN9qzS8g 91sXfssf0bgaG5+7Z33DAlsVM1Z9sg== X-Rspamd-Queue-Id: 4bLfJj17QDz3VQk X-Spamd-Bar: ---- X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:16509, ipnet:3.96.0.0/15, country:US] In message , S hawn Webb writes: > > > --jol37ovfjjuqkati > Content-Type: text/plain; protected-headers=v1; charset=us-ascii > Content-Disposition: inline > Content-Transfer-Encoding: quoted-printable > Subject: Re: git: 98f18cd98824 - main - pam_ksu: Move the realm free to end > of function > MIME-Version: 1.0 > > On Mon, Jun 16, 2025 at 06:42:41PM +0000, Cy Schubert wrote: > > The branch main has been updated by cy: > >=20 > > URL: https://cgit.FreeBSD.org/src/commit/?id=3D98f18cd98824acdf1045e74615= > f2db0219019f0b > >=20 > > commit 98f18cd98824acdf1045e74615f2db0219019f0b > > Author: Cy Schubert > > AuthorDate: 2025-06-16 18:40:51 +0000 > > Commit: Cy Schubert > > CommitDate: 2025-06-16 18:42:30 +0000 > >=20 > > pam_ksu: Move the realm free to end of function > > =20 > > This avoids a use after free. > > =20 > > Noted by: jhb > > --- > > lib/libpam/modules/pam_ksu/pam_ksu.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > >=20 > > diff --git a/lib/libpam/modules/pam_ksu/pam_ksu.c b/lib/libpam/modules/pa= > m_ksu/pam_ksu.c > > index a6b3f043d3f4..e50c3e387311 100644 > > --- a/lib/libpam/modules/pam_ksu/pam_ksu.c > > +++ b/lib/libpam/modules/pam_ksu/pam_ksu.c > > @@ -85,8 +85,6 @@ krb5_make_principal(krb5_context context, krb5_principa= > l principal, > > if ((rc =3D krb5_get_default_realm(context, &temp_realm))) > > return (rc); > > realm=3Dtemp_realm; > > - if (temp_realm) > > - free(temp_realm); > > } > > va_start(ap, realm); > > /* > > @@ -99,6 +97,8 @@ krb5_make_principal(krb5_context context, krb5_principa= > l principal, > > */ > > rc =3D krb5_build_principal_va(context, principal, strlen(realm), realm > = > , ap); > > va_end(ap); > > + if (temp_realm) > > + free(temp_realm); > > Hey Cy, > > I think the call to free can be made unconditional as it's safe to > call free on a NULL pointer (which turns into a no-op). It does but this avoids the overhead of a function call when not needed. -- Cheers, Cy Schubert FreeBSD UNIX: Web: https://FreeBSD.org NTP: Web: https://nwtime.org e**(i*pi)+1=0