Compare commits

...

No commits in common. "imports/c9-beta/mcstrans-3.2-4.el9" and "c8" have entirely different histories.

9 changed files with 136 additions and 183 deletions

2
.gitignore vendored
View File

@ -1 +1 @@
SOURCES/mcstrans-3.2.tar.gz
SOURCES/mcstrans-2.9.tar.gz

View File

@ -1 +1 @@
0e1213c80f9317f3456520514d6e9cf88e8b3372 SOURCES/mcstrans-3.2.tar.gz
64bea2c1cd56e0550049a548dde0ac2e53f71714 SOURCES/mcstrans-2.9.tar.gz

View File

@ -1,16 +1,16 @@
From a9eae01e435c2d6f13f3672a50f545bab03e9992 Mon Sep 17 00:00:00 2001
From eeac35fa98b8b2d323741703a2e59593d1ad200a Mon Sep 17 00:00:00 2001
From: Petr Lautrbach <plautrba@redhat.com>
Date: Wed, 28 Nov 2018 18:28:05 +0100
Subject: [PATCH] mcstrans: Fir RESOURCE_LEAK and USE_AFTER_FREE coverity scan
defects
---
mcstrans/src/mcstrans.c | 21 +++++++++++++++++++--
mcstrans/src/mcstrans.c | 17 ++++++++++++++++-
mcstrans/src/mcstransd.c | 4 +++-
2 files changed, 22 insertions(+), 3 deletions(-)
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/mcstrans/src/mcstrans.c b/mcstrans/src/mcstrans.c
index 96bdbdff7d8b..0d9d0f3e25b7 100644
index 96bdbdff..29cadb78 100644
--- a/mcstrans/src/mcstrans.c
+++ b/mcstrans/src/mcstrans.c
@@ -633,16 +633,23 @@ add_cache(domain_t *domain, char *raw, char *trans) {
@ -62,7 +62,7 @@ index 96bdbdff7d8b..0d9d0f3e25b7 100644
free(ltrans);
free(range);
return -1;
@@ -1647,14 +1657,19 @@ untrans_context(const security_context_t incon, security_context_t *rcon) {
@@ -1647,7 +1657,9 @@ untrans_context(const security_context_t incon, security_context_t *rcon) {
canonical = compute_trans_from_raw(raw, domain);
if (canonical && strcmp(canonical, range))
if (add_cache(domain, raw, canonical) < 0) {
@ -72,18 +72,15 @@ index 96bdbdff7d8b..0d9d0f3e25b7 100644
return -1;
}
}
- if (canonical)
+ if (canonical) {
@@ -1655,6 +1667,7 @@ untrans_context(const security_context_t incon, security_context_t *rcon) {
free(canonical);
+ free(raw);
+ }
if (add_cache(domain, raw, range) < 0) {
free(range);
+ free(raw);
return -1;
}
} else {
@@ -1672,6 +1687,7 @@ untrans_context(const security_context_t incon, security_context_t *rcon) {
@@ -1672,6 +1685,7 @@ untrans_context(const security_context_t incon, security_context_t *rcon) {
canonical = compute_trans_from_raw(lraw, domain);
if (canonical)
if (add_cache(domain, lraw, canonical) < 0) {
@ -91,7 +88,7 @@ index 96bdbdff7d8b..0d9d0f3e25b7 100644
free(lraw);
free(range);
return -1;
@@ -1703,6 +1719,7 @@ untrans_context(const security_context_t incon, security_context_t *rcon) {
@@ -1703,6 +1717,7 @@ untrans_context(const security_context_t incon, security_context_t *rcon) {
canonical = compute_trans_from_raw(uraw, domain);
if (canonical)
if (add_cache(domain, uraw, canonical) < 0) {
@ -100,7 +97,7 @@ index 96bdbdff7d8b..0d9d0f3e25b7 100644
free(lraw);
free(range);
diff --git a/mcstrans/src/mcstransd.c b/mcstrans/src/mcstransd.c
index 858994932e4f..a1ec81acb3c8 100644
index 85899493..a1ec81ac 100644
--- a/mcstrans/src/mcstransd.c
+++ b/mcstrans/src/mcstransd.c
@@ -335,6 +335,7 @@ process_events(struct pollfd **ufds, int *nfds)
@ -125,5 +122,5 @@ index 858994932e4f..a1ec81acb3c8 100644
" for fd (%d)\n", revents, connfd);
--
2.23.0
2.21.0

View File

@ -1,4 +1,4 @@
From 0173a950563b23080fd40433f55efcb1d6b77923 Mon Sep 17 00:00:00 2001
From 659cb59cd6cfe36c954c77f945c06a0cd8218287 Mon Sep 17 00:00:00 2001
From: Petr Lautrbach <plautrba@redhat.com>
Date: Mon, 15 Apr 2019 15:22:51 +0200
Subject: [PATCH] mcstrans: Do not accept incomplete contexts
@ -32,7 +32,7 @@ Signed-off-by: Petr Lautrbach <plautrba@redhat.com>
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/mcstrans/src/mcscolor.c b/mcstrans/src/mcscolor.c
index 4ee0db507ef2..3a3a6de9a02b 100644
index 6ea1aa97..79fc1c8b 100644
--- a/mcstrans/src/mcscolor.c
+++ b/mcstrans/src/mcscolor.c
@@ -272,10 +272,14 @@ static const unsigned precedence[N_COLOR][N_COLOR - 1] = {
@ -55,5 +55,5 @@ index 4ee0db507ef2..3a3a6de9a02b 100644
return 0;
}
--
2.23.0
2.21.0

View File

@ -1,28 +0,0 @@
From d09b54cfffaa3923c22bb3ff7818cb4a19325905 Mon Sep 17 00:00:00 2001
From: Petr Lautrbach <plautrba@redhat.com>
Date: Thu, 9 May 2019 16:44:43 +0200
Subject: [PATCH] mcstrans: Fix USER_AFTER_FREE problem
---
mcstrans/src/mcstrans.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/mcstrans/src/mcstrans.c b/mcstrans/src/mcstrans.c
index 0d9d0f3e25b7..29cadb78b62c 100644
--- a/mcstrans/src/mcstrans.c
+++ b/mcstrans/src/mcstrans.c
@@ -1663,10 +1663,8 @@ untrans_context(const security_context_t incon, security_context_t *rcon) {
return -1;
}
}
- if (canonical) {
+ if (canonical)
free(canonical);
- free(raw);
- }
if (add_cache(domain, raw, range) < 0) {
free(range);
free(raw);
--
2.23.0

View File

@ -0,0 +1,56 @@
From 7426ba3f8d9edc5222db5663c8a9e5312f489e92 Mon Sep 17 00:00:00 2001
From: Vit Mojzis <vmojzis@redhat.com>
Date: Tue, 2 Jul 2019 14:09:04 +0200
Subject: [PATCH] Revert "mcstransd select correct colour range."
This reverts commit fe17b3d2d924018750386c5ee74f12ca4b054136.
MLS ranges should be compared based on dominance.
This fixes mlscolor-test on mcstrans examples.
Eg. mlscolor-test using /usr/share/mcstrans/examples/urcsts when executed on mls
machine fails as follows:
\#pushd /usr/share/mcstrans/examples/urcsts
\#cp -f secolor.conf /etc/selinux/mls/secolor.conf
\#cp -f setrans.conf /etc/selinux/mls/setrans.conf
\#systemctl restart mcstransd
\#python3 /usr/share/mcstrans/util/mlscolor-test urcsts.color
For 'system_u:system_r:inetd_t:SystemLow' got
'#000000 #000000 #000000 #000000 #000000 #000000 #000000 #000000' expected
'#000000 #000000 #000000 #000000 #000000 #000000 #000000 #008000'
...
mlscolor-test done with 19 errors
Signed-off-by: Vit Mojzis <vmojzis@redhat.com>
---
mcstrans/src/mcscolor.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/mcstrans/src/mcscolor.c b/mcstrans/src/mcscolor.c
index 79fc1c8b..f9c64da3 100644
--- a/mcstrans/src/mcscolor.c
+++ b/mcstrans/src/mcscolor.c
@@ -134,12 +134,12 @@ static const secolor_t *find_color(int idx, const char *component,
}
while (ptr) {
- if (fnmatch(ptr->pattern, component, 0) == 0) {
- if (idx == COLOR_RANGE) {
- if (check_dominance(ptr->pattern, raw) == 0)
- return &ptr->color;
- } else
- return &ptr->color;
+ if (idx == COLOR_RANGE) {
+ if (check_dominance(ptr->pattern, raw) == 0)
+ return &ptr->color;
+ } else {
+ if (fnmatch(ptr->pattern, component, 0) == 0)
+ return &ptr->color;
}
ptr = ptr->next;
}
--
2.21.0

View File

@ -0,0 +1,44 @@
From 90a4f2b9a5194a2d1ab4c45b7a90bbb6c8099a68 Mon Sep 17 00:00:00 2001
From: Vit Mojzis <vmojzis@redhat.com>
Date: Tue, 2 Jul 2019 14:09:05 +0200
Subject: [PATCH] Fix mcstrans secolor examples
According to "check_dominance" function:
Range defined as "s15:c0.c1023" does not dominate any other range than
"s15:c0.c1023" (does not dominate "s15", "s15:c0.c200", etc.).
While range defined as "s15-s15:c0.c1023" dominates all of the above.
This is either a bug, or "s15:c0.c1023" should not be used in the
examples.
Signed-off-by: Vit Mojzis <vmojzis@redhat.com>
---
mcstrans/share/examples/urcsts-via-include/secolor.conf | 2 +-
mcstrans/share/examples/urcsts/secolor.conf | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/mcstrans/share/examples/urcsts-via-include/secolor.conf b/mcstrans/share/examples/urcsts-via-include/secolor.conf
index d35b3c67..3b3f5430 100644
--- a/mcstrans/share/examples/urcsts-via-include/secolor.conf
+++ b/mcstrans/share/examples/urcsts-via-include/secolor.conf
@@ -17,5 +17,5 @@ range s3-s3:c0.c1023 = black tan
range s5-s5:c0.c1023 = white blue
range s7-s7:c0.c1023 = black red
range s9-s9:c0.c1023 = black orange
-range s15:c0.c1023 = black yellow
+range s15-s15:c0.c1023 = black yellow
diff --git a/mcstrans/share/examples/urcsts/secolor.conf b/mcstrans/share/examples/urcsts/secolor.conf
index d35b3c67..3b3f5430 100644
--- a/mcstrans/share/examples/urcsts/secolor.conf
+++ b/mcstrans/share/examples/urcsts/secolor.conf
@@ -17,5 +17,5 @@ range s3-s3:c0.c1023 = black tan
range s5-s5:c0.c1023 = white blue
range s7-s7:c0.c1023 = black red
range s9-s9:c0.c1023 = black orange
-range s15:c0.c1023 = black yellow
+range s15-s15:c0.c1023 = black yellow
--
2.21.0

View File

@ -1,63 +0,0 @@
From 52872e0193f650b1fd4ab9125453e7ebdac152bd Mon Sep 17 00:00:00 2001
From: Petr Lautrbach <plautrba@redhat.com>
Date: Thu, 5 Aug 2021 16:26:44 +0200
Subject: [PATCH] mcstrans: fix RESOURCE_LEAK (CWE-772)
Fixes:
Error: RESOURCE_LEAK (CWE-772): [#def1]
mcstrans-3.2/src/mcstrans.c:1527: alloc_fn: Storage is returned from allocation function "compute_trans_from_raw".
mcstrans-3.2/src/mcstrans.c:1527: var_assign: Assigning: "trans" = storage returned from "compute_trans_from_raw(range, domain)".
mcstrans-3.2/src/mcstrans.c:1529: noescape: Resource "trans" is not freed or pointed-to in "add_cache".
mcstrans-3.2/src/mcstrans.c:1515: overwrite_var: Overwriting "trans" in "trans = find_in_hashtable(range, domain, domain->raw_to_trans)" leaks the storage that "trans" points to.
# 1513| domain_t *domain = domains;
# 1514| for (;domain; domain = domain->next) {
# 1515|-> trans = find_in_hashtable(range, domain, domain->raw_to_trans);
# 1516| if (trans) break;
# 1517|
Error: RESOURCE_LEAK (CWE-772): [#def2]
mcstrans-3.2/src/mcstrans.c:1654: alloc_fn: Storage is returned from allocation function "compute_raw_from_trans".
mcstrans-3.2/src/mcstrans.c:1654: var_assign: Assigning: "raw" = storage returned from "compute_raw_from_trans(range, domain)".
mcstrans-3.2/src/mcstrans.c:1656: noescape: Resource "raw" is not freed or pointed-to in "find_in_hashtable".
mcstrans-3.2/src/mcstrans.c:1669: noescape: Resource "raw" is not freed or pointed-to in "add_cache".
mcstrans-3.2/src/mcstrans.c:1642: overwrite_var: Overwriting "raw" in "raw = find_in_hashtable(range, domain, domain->trans_to_raw)" leaks the storage that "raw" points to.
# 1640| domain_t *domain = domains;
# 1641| for (;domain; domain = domain->next) {
# 1642|-> raw = find_in_hashtable(range, domain, domain->trans_to_raw);
# 1643| if (raw) break;
# 1644|
Signed-off-by: Petr Lautrbach <plautrba@redhat.com>
---
mcstrans/src/mcstrans.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/mcstrans/src/mcstrans.c b/mcstrans/src/mcstrans.c
index 8678418a1570..4e110e02f73a 100644
--- a/mcstrans/src/mcstrans.c
+++ b/mcstrans/src/mcstrans.c
@@ -1598,6 +1598,10 @@ trans_context(const char *incon, char **rcon) {
}
if (dashp)
*dashp = '-';
+ if (trans) {
+ free(trans);
+ trans = NULL;
+ }
}
if (trans) {
@@ -1769,6 +1773,10 @@ untrans_context(const char *incon, char **rcon) {
}
if (dashp)
*dashp = '-';
+ if (raw) {
+ free(raw);
+ raw = NULL;
+ }
}
if (raw) {
--
2.32.0

View File

@ -1,21 +1,17 @@
Summary: SELinux Translation Daemon
Name: mcstrans
Version: 3.2
Release: 4%{?dist}
Version: 2.9
Release: 2%{?dist}
License: GPL+
Url: https://github.com/SELinuxProject/selinux/wiki
Source: https://github.com/SELinuxProject/selinux/releases/download/3.2/mcstrans-3.2.tar.gz
Source: https://github.com/SELinuxProject/selinux/releases/download/20190315/mcstrans-2.9.tar.gz
Source2: secolor.conf.8
# fedora-selinux/selinux: git format-patch -N 3.2 -- mcstrans
# i=1; for j in 00*patch; do printf "Patch%04d: %s\n" $i $j; i=$((i+1));done
# Patch list start
Patch0001: 0001-mcstrans-Fir-RESOURCE_LEAK-and-USE_AFTER_FREE-coveri.patch
Patch0002: 0002-mcstrans-Fix-USER_AFTER_FREE-problem.patch
Patch0003: 0003-mcstrans-Do-not-accept-incomplete-contexts.patch
Patch0004: 0004-mcstrans-fix-RESOURCE_LEAK-CWE-772.patch
# Patch list end
Patch0002: 0002-mcstrans-Do-not-accept-incomplete-contexts.patch
Patch0003: 0003-Revert-mcstransd-select-correct-colour-range.patch
Patch0004: 0004-Fix-mcstrans-secolor-examples.patch
BuildRequires: gcc
BuildRequires: make
BuildRequires: libselinux-devel >= %{version}
BuildRequires: libcap-devel pcre-devel libsepol-devel libsepol-static
BuildRequires: systemd
@ -23,6 +19,7 @@ Requires: pcre
%{?systemd_requires}
Provides: setransd
Provides: libsetrans
Obsoletes: libsetrans
%description
Security-enhanced Linux is a feature of the Linux® kernel and a number
@ -43,17 +40,15 @@ from internal representations to user defined representation.
%build
%set_build_flags
%make_build LIBDIR="%{_libdir}"
make LIBDIR="%{_libdir}" %{?_smp_mflags}
%install
rm -rf %{buildroot}
mkdir -p %{buildroot}/%{_lib}
mkdir -p %{buildroot}/%{_libdir}
mkdir -p %{buildroot}%{_usr}/share/mcstrans
mkdir -p %{buildroot}%{_sysconfdir}/selinux/mls/setrans.d
%make_install LIBDIR="%{_libdir}" SHLIBDIR="%{_lib}" SBINDIR="%{_sbindir}"
make DESTDIR="%{buildroot}" LIBDIR="%{_libdir}" SHLIBDIR="%{_lib}" SBINDIR="%{_sbindir}" install
rm -f %{buildroot}%{_libdir}/*.a
cp -r share/* %{buildroot}%{_usr}/share/mcstrans/
# Systemd
@ -62,6 +57,9 @@ ln -s %{_unitdir}/mcstrans.service %{buildroot}/%{_unitdir}/mcstransd.service
rm -rf %{buildroot}/%{_sysconfdir}/rc.d/init.d/mcstrans
install -m644 %{SOURCE2} %{buildroot}%{_mandir}/man8/
%clean
rm -rf %{buildroot}
%post
%systemd_post mcstransd.service
@ -72,12 +70,13 @@ install -m644 %{SOURCE2} %{buildroot}%{_mandir}/man8/
%systemd_postun mcstransd.service
%files
%defattr(-,root,root,0755)
%{_mandir}/man8/mcs.8.gz
%{_mandir}/man8/mcstransd.8.gz
%{_mandir}/man5/setrans.conf.5.gz
%{_mandir}/man8/setrans.conf.8.gz
%{_mandir}/ru/man8/mcs.8.gz
%{_mandir}/ru/man8/mcstransd.8.gz
%{_mandir}/ru/man5/setrans.conf.5.gz
%{_mandir}/ru/man8/setrans.conf.8.gz
%{_mandir}/man8/secolor.conf.8.gz
/usr/sbin/mcstransd
%{_unitdir}/mcstrans.service
@ -95,71 +94,19 @@ install -m644 %{SOURCE2} %{buildroot}%{_mandir}/man8/
%{_usr}/share/mcstrans/util/*
%changelog
* Mon Aug 09 2021 Mohan Boddu <mboddu@redhat.com> - 3.2-4
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
Related: rhbz#1991688
* Fri Nov 08 2019 Vit Mojzis <vmojzis@redhat.com> - 2.9-2
- Revert "mcstransd select correct colour range." (#1731451)
- Fix mcstrans secolor examples (#1731451)
* Thu Aug 5 2021 Petr Lautrbach <plautrba@redhat.com> - 3.2-3
- Fix RESOURCE_LEAK (CWE-772)
* Fri Apr 16 2021 Mohan Boddu <mboddu@redhat.com> - 3.2-2
- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937
* Tue Mar 9 2021 Petr Lautrbach <plautrba@redhat.com> - 3.2-1
- SELinux userspace 3.2 release
* Sun Feb 7 2021 Petr Lautrbach <plautrba@redhat.com> - 3.2-0.rc2.1
- SELinux userspace 3.2-rc2 release
* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 3.2-0.rc1.1.1
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
* Fri Jan 22 2021 Petr Lautrbach <plautrba@redhat.com> - 3.2-0.rc1.1
- SELinux userspace 3.2-rc1 release
* Tue Jul 28 2020 Tom Stellard <tstellar@redhat.com> - 3.1-3
- Use make macros
- https://fedoraproject.org/wiki/Changes/UseMakeBuildInstallMacro
* Tue Jul 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 3.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
* Thu Jul 16 2020 Petr Lautrbach <plautrba@redhat.com> - 3.1-1
- SELinux userspace 3.1 release
* Wed Jan 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 3.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
* Fri Dec 6 2019 Petr Lautrbach <plautrba@redhat.com> - 3.0-1
- SELinux userspace 3.0 release
* Mon Nov 11 2019 Petr Lautrbach <plautrba@redhat.com> - 3.0-0.rc1.1
- SELinux userspace 3.0-rc1 release candidate
* Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 2.9-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
* Tue Mar 19 2019 Petr Lautrbach <plautrba@redhat.com> - 2.9-1
* Fri Apr 12 2019 Petr Lautrbach <plautrba@redhat.com> - 2.9-1.2
- SELinux userspace 2.9 release
* Mon Mar 11 2019 Petr Lautrbach <plautrba@redhat.com> - 2.9-0.rc2.1
- SELinux userspace 2.9-rc2 release
* Fri Feb 01 2019 Fedora Release Engineering <releng@fedoraproject.org> - 2.9-0.rc1.1.1
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
* Wed Jan 30 2019 Petr Lautrbach <plautrba@redhat.com> - 2.9-0.rc1.1
- Update to mcstrans-2.9-rc1
* Sun Dec 16 2018 Petr Lautrbach <plautrba@redhat.com> - 2.8-2
- Fix RESOURCE_LEAK and USE_AFTER_FREE coverity scan defects
* Tue Oct 2 2018 Petr Lautrbach <plautrba@redhat.com> - 2.8-1
- Update to mcstrans-2.8
* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.3.4-13
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
* Thu Feb 08 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.3.4-12
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
* Thu Aug 03 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.3.4-11
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild