!13 do malloc trim after load policy

From: @HuaxinLuGitee
Reviewed-by: @zhujianwei001
Signed-off-by: @zhujianwei001
This commit is contained in:
openeuler-ci-bot 2021-06-02 16:59:24 +08:00 committed by Gitee
commit a7be8d5855
2 changed files with 40 additions and 1 deletions

View File

@ -0,0 +1,35 @@
From 3d5049f849226d54070651fdf96019d263c38363 Mon Sep 17 00:00:00 2001
From: luhuaxin <1539327763@qq.com>
Date: Wed, 2 Jun 2021 16:24:47 +0800
Subject: [PATCH] do malloc trim after load policy
---
libselinux/src/load_policy.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/libselinux/src/load_policy.c b/libselinux/src/load_policy.c
index 2aea826..ace898c 100644
--- a/libselinux/src/load_policy.c
+++ b/libselinux/src/load_policy.c
@@ -18,6 +18,7 @@
#include <dlfcn.h>
#include "policy.h"
#include <limits.h>
+#include <malloc.h>
#ifndef MNT_DETACH
#define MNT_DETACH 2
@@ -365,7 +366,9 @@ int selinux_init_load_policy(int *enforce)
}
/* Load the policy. */
- return selinux_mkload_policy(0);
+ rc = selinux_mkload_policy(0);
+ malloc_trim(0);
+ return rc;
noload:
/*
--
1.8.3.1

View File

@ -3,13 +3,14 @@
Name: libselinux Name: libselinux
Version: 3.1 Version: 3.1
Release: 2 Release: 3
License: Public Domain License: Public Domain
Summary: SELinux library and simple utilities Summary: SELinux library and simple utilities
Url: https://github.com/SELinuxProject/selinux/wiki Url: https://github.com/SELinuxProject/selinux/wiki
Source0: https://github.com/SELinuxProject/selinux/releases/download/20200710/libselinux-3.1.tar.gz Source0: https://github.com/SELinuxProject/selinux/releases/download/20200710/libselinux-3.1.tar.gz
#Patch0: libselinux-Use-Python-distutils-to-install-SELinux-p.patch #Patch0: libselinux-Use-Python-distutils-to-install-SELinux-p.patch
Patch1: do-malloc-trim-after-load-policy.patch
BuildRequires: gcc python3-devel systemd swig pcre2-devel xz-devel BuildRequires: gcc python3-devel systemd swig pcre2-devel xz-devel
BuildRequires: ruby-devel libsepol-static BuildRequires: ruby-devel libsepol-static
@ -128,6 +129,9 @@ mv %{buildroot}%{_sbindir}/getconlist %{buildroot}%{_sbindir}/selinuxconlist
%{_mandir}/ru/man8/* %{_mandir}/ru/man8/*
%changelog %changelog
* Wed Jul 2 2021 luhuaxin <1539327763@qq.com> - 3.1-3
- do malloc trim after load policy
* Tue Oct 27 2020 gaoyusong <gaoyusong1@huawei.com> - 3.1-2 * Tue Oct 27 2020 gaoyusong <gaoyusong1@huawei.com> - 3.1-2
- delete BuildRequires python2-devel - delete BuildRequires python2-devel