summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonas Brich <Jonas.Brich@bmw.de>2021-10-08 14:47:14 +0200
committerJoe MacDonald <joe@deserted.net>2021-10-18 13:09:28 -0400
commitd6ff5a0e67afe519ce3c03a92d423481e4e41ca2 (patch)
tree02cb9c5ee3d8d3e9adcababa1ad3c490e6df5f8e
parent10187c3ceeb38acdfb92e8f3d8dd735e2bf485e1 (diff)
downloadmeta-selinux-d6ff5a0e67afe519ce3c03a92d423481e4e41ca2.tar.gz
libselinux: Backport NULL pointer fix from 3.1
Using function restorecon_init inside selinux_restorecon.c can result in a NULL pointer. This happens because function selinux_restorecon_set_sehandle can return a NULL pointer. But it is not checked and directly given to the next function. This problem is already fixed in libselinux 3.1 and above. Therefore backport this fix. Upstream-Status: Backport [https://github.com/SELinuxProject/selinux/commit/08f5e30177218fae7ce9f5c8d6856690126b2b30] Issue: MGURSU-7259 Change-Id: Ice5c7c94987441ba53431aeffc200c0b9c5697a4 Signed-off-by: Joe MacDonald <joe@deserted.net>
-rw-r--r--recipes-security/selinux/libselinux/0001-Fix-NULL-pointer-use-in-selinux_restorecon_set_sehandle.patch30
-rw-r--r--recipes-security/selinux/libselinux_3.0.bb1
2 files changed, 31 insertions, 0 deletions
diff --git a/recipes-security/selinux/libselinux/0001-Fix-NULL-pointer-use-in-selinux_restorecon_set_sehandle.patch b/recipes-security/selinux/libselinux/0001-Fix-NULL-pointer-use-in-selinux_restorecon_set_sehandle.patch
new file mode 100644
index 0000000..8a9fb7c
--- /dev/null
+++ b/recipes-security/selinux/libselinux/0001-Fix-NULL-pointer-use-in-selinux_restorecon_set_sehandle.patch
@@ -0,0 +1,30 @@
1From 08f5e30177218fae7ce9f5c8d6856690126b2b30 Mon Sep 17 00:00:00 2001
2From: Ji Qin <jiqin.ji@huawei.com>
3Date: Sun, 14 Jun 2020 21:20:23 -0400
4Subject: [PATCH] libselinux: Fix NULL pointer use in
5 selinux_restorecon_set_sehandle
6
7error occur when selinux_restorecon_default_handle return NULL in
8restorecon_init.
9
10fixes: https://github.com/SELinuxProject/selinux/issues/249
11
12Signed-off-by: Ji Qin <jiqin.ji@huawei.com>
13Acked-by: Stephen Smalley <stephen.smalley.work@gmail.com>
14---
15 libselinux/src/selinux_restorecon.c | 2 ++
16 1 file changed, 2 insertions(+)
17
18diff --git a/libselinux/src/selinux_restorecon.c b/libselinux/src/selinux_restorecon.c
19index d1ce830c5..6993be6fd 100644
20--- a/libselinux/src/selinux_restorecon.c
21+++ b/libselinux/src/selinux_restorecon.c
22@@ -1154,6 +1154,8 @@ void selinux_restorecon_set_sehandle(struct selabel_handle *hndl)
23 size_t num_specfiles, fc_digest_len;
24
25 fc_sehandle = (struct selabel_handle *) hndl;
26+ if (!fc_sehandle)
27+ return;
28
29 /* Check if digest requested in selabel_open(3), if so use it. */
30 if (selabel_digest(fc_sehandle, &fc_digest, &fc_digest_len,
diff --git a/recipes-security/selinux/libselinux_3.0.bb b/recipes-security/selinux/libselinux_3.0.bb
index 05d2346..4a60962 100644
--- a/recipes-security/selinux/libselinux_3.0.bb
+++ b/recipes-security/selinux/libselinux_3.0.bb
@@ -12,4 +12,5 @@ SRC_URI += "\
12 file://libselinux-make-SOCK_CLOEXEC-optional.patch \ 12 file://libselinux-make-SOCK_CLOEXEC-optional.patch \
13 file://libselinux-define-FD_CLOEXEC-as-necessary.patch \ 13 file://libselinux-define-FD_CLOEXEC-as-necessary.patch \
14 file://0001-Fix-building-against-musl-and-uClibc-libc-libraries.patch \ 14 file://0001-Fix-building-against-musl-and-uClibc-libc-libraries.patch \
15 file://0001-Fix-NULL-pointer-use-in-selinux_restorecon_set_sehandle.patch \
15 " 16 "