Compare commits

...

No commits in common. 'c9' and 'c8-stream-5.24' have entirely different histories.

@ -1,79 +0,0 @@
From 159042c71bbdd5909f792208dcdffffb1674ecfe Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
Date: Thu, 19 Aug 2021 16:07:06 +0200
Subject: [PATCH] Fix a crash in gss_release_oid() when destructing out_mech
returned by gss_accept_sec_context()
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
If Perl GSSAPI was built against MIT krb5, an example gss-server.pl
script crashed like this:
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x00007f27f3d48b23 in __GI___libc_free (mem=<optimized out>)
at malloc.c:3131
3131 ar_ptr = arena_for_chunk (p);
(gdb) bt
#0 0x00007f27f3d48b23 in __GI___libc_free (mem=<optimized out>)
at malloc.c:3131
#1 0x00007f27f2fe17c6 in generic_gss_release_oid (
minor_status=minor_status@entry=0x7fffc750333c,
oid=oid@entry=0x7fffc7503340) at oid_ops.c:102
#2 0x00007f27f2fee6df in gss_release_oid (
minor_status=minor_status@entry=0x7fffc750333c,
oid=oid@entry=0x7fffc7503340) at g_initialize.c:202
#3 0x00007f27f322f5cf in XS_GSSAPI__OID_DESTROY (my_perl=<optimized out>,
cv=0x564037c87130) at ./xs/OID.xs:24
#4 0x00007f27f4f58149 in Perl_pp_entersub (my_perl=0x5640378d42a0)
at pp_hot.c:4227
The cause is that gss_accept_sec_context() returns a pointer to
a static storage in out_mech argument. When GSSAPI passed out_mech to
a desctructor, the invoked gss_release_oid() crashed when freeing the
memory.
Accoding to RFC 2744, the static storage is correct. Hence the flaw is
on Perl GSSAPI side. This patch fixes it by copying the out_mech OID
object on a heap which is then correctly processed by
gss_release_oid().
CPAN RT#121873.
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
xs/Context.xs | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/xs/Context.xs b/xs/Context.xs
index d176f08..4549595 100644
--- a/xs/Context.xs
+++ b/xs/Context.xs
@@ -80,6 +80,24 @@ accept(context, acc_cred, in_token, binding, out_name, out_mech, out_token, out_
&in_token, binding, out_name, out_mech,
&out_token, out_flags, out_time,
delegated_cred);
+#if !defined(HEIMDAL)
+ if (out_mech && *out_mech) {
+ /* RFC 2744 documents that the returned *out_mech is a pointer
+ * to static data. To prevent from freeing them when destructing
+ * out_mech, we change *out_mech into a pointer to a heap-allocated
+ * buffer with the same content. Otherwise, MITKRB5-provided
+ * gss_release_oid() deallocator which cannot recognize this static
+ * storage would crash. We use malloc() because gss_release_oid() used
+ * free(). */
+ GSSAPI__OID copy = malloc(sizeof(*copy));
+ if (!copy) croak("Not enough memory for copying out_mech!");
+ copy->elements = malloc((*out_mech)->length);
+ if (!copy->elements) croak("Not enough memory for copying out_mech!");
+ memcpy(copy->elements, (*out_mech)->elements, (*out_mech)->length);
+ copy->length = (*out_mech)->length;
+ *out_mech = copy;
+ }
+#endif
OUTPUT:
RETVAL
context
--
2.31.1

@ -6,16 +6,12 @@
Name: perl-GSSAPI Name: perl-GSSAPI
Version: 0.28 Version: 0.28
Release: 37%{?dist} Release: 18%{?dist}
Summary: Perl extension providing access to the GSSAPIv2 library Summary: Perl extension providing access to the GSSAPIv2 library
License: GPL+ or Artistic License: GPL+ or Artistic
URL: https://metacpan.org/release/GSSAPI Group: Development/Libraries
Source0: https://cpan.metacpan.org/authors/id/A/AG/AGROLMS/GSSAPI-%{version}.tar.gz URL: http://search.cpan.org/dist/GSSAPI/
# Fix a crash in gss_release_oid() when destructing out_mech (rhbz #1994263, CPAN RT#121873) Source0: http://www.cpan.org/authors/id/A/AG/AGROLMS/GSSAPI-%{version}.tar.gz
Patch0: GSSAPI-0.28-Fix-a-crash-in-gss_release_oid-when-destructing-out_.patch
BuildRequires: make
BuildRequires: findutils
BuildRequires: gcc
BuildRequires: krb5-devel BuildRequires: krb5-devel
BuildRequires: which BuildRequires: which
%{?_with_testsuite:BuildRequires: perl(constant)} %{?_with_testsuite:BuildRequires: perl(constant)}
@ -23,8 +19,7 @@ BuildRequires: which
%{?_with_testsuite:BuildRequires: perl(Exporter)} %{?_with_testsuite:BuildRequires: perl(Exporter)}
BuildRequires: perl-devel BuildRequires: perl-devel
BuildRequires: perl-generators BuildRequires: perl-generators
BuildRequires: perl-interpreter BuildRequires: perl(ExtUtils::MakeMaker)
BuildRequires: perl(ExtUtils::MakeMaker) >= 6.76
%{?_with_testsuite:BuildRequires: perl(ExtUtils::testlib)} %{?_with_testsuite:BuildRequires: perl(ExtUtils::testlib)}
BuildRequires: perl(Getopt::Long) BuildRequires: perl(Getopt::Long)
%{?_with_testsuite:BuildRequires: perl(Test::More)} %{?_with_testsuite:BuildRequires: perl(Test::More)}
@ -39,16 +34,17 @@ distribution from MIT.
%prep %prep
%setup -q -n GSSAPI-%{version} %setup -q -n GSSAPI-%{version}
%patch0 -p1
chmod -c a-x examples/*.pl chmod -c a-x examples/*.pl
%build %build
perl Makefile.PL INSTALLDIRS=vendor OPTIMIZE="%{optflags}" NO_PACKLIST=1 NO_PERLLOCAL=1 perl Makefile.PL INSTALLDIRS=vendor OPTIMIZE="%{optflags}"
%{make_build} make %{?_smp_mflags}
%install %install
%{make_install} make pure_install DESTDIR=%{buildroot}
find %{buildroot} -type f -name '*.bs' -empty -delete find %{buildroot} -type f -name .packlist -exec rm -f {} \;
find %{buildroot} -type f -name '*.bs' -empty -exec rm -f {} \;
find %{buildroot} -depth -type d -exec rmdir {} 2>/dev/null \;
%{_fixperms} %{buildroot}/* %{_fixperms} %{buildroot}/*
%check %check
@ -62,66 +58,6 @@ find %{buildroot} -type f -name '*.bs' -empty -delete
%{_mandir}/man3/* %{_mandir}/man3/*
%changelog %changelog
* Thu Aug 19 2021 Jitka Plesnikova <jplesnik@redhat.com> - 0.28-37
- Resolves: rhbz#1994263 - Fix a crash in gss_release_oid() when destructing out_mech
* Mon Aug 16 2021 Jitka Plesnikova <jplesnik@redhat.com> - 0.28-36
- Resolves: rhbz#1994263 - Fix comparison of OID structure
* Mon Aug 09 2021 Mohan Boddu <mboddu@redhat.com> - 0.28-35
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
Related: rhbz#1991688
* Fri Apr 16 2021 Mohan Boddu <mboddu@redhat.com> - 0.28-34
- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937
* Wed Jan 27 2021 Fedora Release Engineering <releng@fedoraproject.org> - 0.28-33
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
* Tue Jul 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 0.28-32
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
* Mon Jun 22 2020 Jitka Plesnikova <jplesnik@redhat.com> - 0.28-31
- Perl 5.32 rebuild
* Tue Feb 04 2020 Tom Stellard <tstellar@redhat.com> - 0.28-30
- Spec file cleanups: Use make_build and make_install macros
- https://docs.fedoraproject.org/en-US/packaging-guidelines/#_parallel_make
- https://fedoraproject.org/wiki/Perl/Tips#ExtUtils::MakeMake
* Thu Jan 30 2020 Fedora Release Engineering <releng@fedoraproject.org> - 0.28-29
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
* Fri Jul 26 2019 Fedora Release Engineering <releng@fedoraproject.org> - 0.28-28
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
* Thu May 30 2019 Jitka Plesnikova <jplesnik@redhat.com> - 0.28-27
- Perl 5.30 rebuild
* Fri Feb 01 2019 Fedora Release Engineering <releng@fedoraproject.org> - 0.28-26
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.28-25
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
* Wed Jun 27 2018 Jitka Plesnikova <jplesnik@redhat.com> - 0.28-24
- Perl 5.28 rebuild
* Mon Feb 19 2018 Jitka Plesnikova <jplesnik@redhat.com> - 0.28-23
- Add build-require gcc
* Thu Feb 08 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.28-22
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
* Thu Aug 03 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.28-21
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild
* Thu Jul 27 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.28-20
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild
* Sun Jun 04 2017 Jitka Plesnikova <jplesnik@redhat.com> - 0.28-19
- Perl 5.26 rebuild
* Sat Feb 11 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.28-18 * Sat Feb 11 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.28-18
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild - Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild

Loading…
Cancel
Save