From 274cdbd06c52578758b10c8fa5009fc050289bb2 Mon Sep 17 00:00:00 2001 From: gengqihu <2712504175@qq.com> Date: Tue, 26 Mar 2024 14:56:25 +0800 Subject: [PATCH] backport bugfix from upstream --- ...-libsepol-reorder-calloc-3-arguments.patch | 75 +++++++++++++++++++ libsepol.spec | 6 +- 2 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 backport-libsepol-reorder-calloc-3-arguments.patch diff --git a/backport-libsepol-reorder-calloc-3-arguments.patch b/backport-libsepol-reorder-calloc-3-arguments.patch new file mode 100644 index 0000000..5178bc8 --- /dev/null +++ b/backport-libsepol-reorder-calloc-3-arguments.patch @@ -0,0 +1,75 @@ +From a0ff05efca3bb04b08a5f5274016d9f1286e9517 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= +Date: Fri, 5 Jan 2024 19:35:31 +0100 +Subject: [PATCH] libsepol: reorder calloc(3) arguments +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The canonical order of calloc(3) parameters is the number of elements +first and the size of each element second. + +Reported by GCC 14: + + kernel_to_conf.c:814:47: warning: 'calloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Wcalloc-transposed-args] + kernel_to_conf.c:945:46: warning: 'calloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Wcalloc-transposed-args] + kernel_to_conf.c:2109:35: warning: 'calloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Wcalloc-transposed-args] + kernel_to_common.c:578:29: warning: 'calloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Wcalloc-transposed-args] + +Signed-off-by: Christian Göttsche +Acked-by: James Carter + +Reference: https://github.com/SELinuxProject/selinux/commit/a0ff05efca3bb04b08a5f5274016d9f1286e9517 +Conflict: Context adaptation in kernel_to_common.c. +--- + libsepol/src/kernel_to_common.c | 2 +- + libsepol/src/kernel_to_conf.c | 6 +++--- + 2 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/libsepol/src/kernel_to_common.c b/libsepol/src/kernel_to_common.c +index 4612eef3..2422eed0 100644 +--- a/libsepol/src/kernel_to_common.c ++++ b/libsepol/src/kernel_to_common.c +@@ -575,7 +575,7 @@ static int sort_ocontext_data(struct ocontext **ocons, int (*cmp)(const void *, + return 0; + } + +- data = calloc(sizeof(*data), num); ++ data = calloc(num, sizeof(*data)); + if (!data) { + sepol_log_err("Out of memory\n"); + return -1; +diff --git a/libsepol/src/kernel_to_conf.c b/libsepol/src/kernel_to_conf.c +index 83f46e0f..e6b449b4 100644 +--- a/libsepol/src/kernel_to_conf.c ++++ b/libsepol/src/kernel_to_conf.c +@@ -811,7 +811,7 @@ static int write_sensitivity_rules_to_conf(FILE *out, struct policydb *pdb) + num = strs_num_items(strs); + + if (num > 0) { +- sens_alias_map = calloc(sizeof(*sens_alias_map), pdb->p_levels.nprim); ++ sens_alias_map = calloc(pdb->p_levels.nprim, sizeof(*sens_alias_map)); + if (!sens_alias_map) { + rc = -1; + goto exit; +@@ -942,7 +942,7 @@ static int write_category_rules_to_conf(FILE *out, struct policydb *pdb) + num = strs_num_items(strs); + + if (num > 0) { +- cat_alias_map = calloc(sizeof(*cat_alias_map), pdb->p_cats.nprim); ++ cat_alias_map = calloc(pdb->p_cats.nprim, sizeof(*cat_alias_map)); + if (!cat_alias_map) { + rc = -1; + goto exit; +@@ -2106,7 +2106,7 @@ static int write_cond_nodes_to_conf(FILE *out, struct policydb *pdb) + return 0; + } + +- cond_data = calloc(sizeof(struct cond_data), num); ++ cond_data = calloc(num, sizeof(struct cond_data)); + if (!cond_data) { + rc = -1; + goto exit; +-- +2.33.0 + diff --git a/libsepol.spec b/libsepol.spec index 34a2783..92caf4e 100644 --- a/libsepol.spec +++ b/libsepol.spec @@ -1,6 +1,6 @@ Name: libsepol Version: 3.3 -Release: 5 +Release: 6 Summary: SELinux binary policy manipulation library License: LGPLv2+ URL: https://github.com/SELinuxProject/selinux/wiki/Releases @@ -20,6 +20,7 @@ Patch0011: backport-libsepol-expand-use-identical-type-to-avoid-implicit-co Patch0012: backport-libsepol-cil-Fix-class-permission-verification-in-CIL.patch Patch0013: backport-libsepol-validate-old-style-range-trans-classes.patch Patch0014: backport-libsepol-validate-check-low-category-is-not-bigger-than-high.patch +Patch0015: backport-libsepol-reorder-calloc-3-arguments.patch BuildRequires: gcc flex @@ -79,6 +80,9 @@ make DESTDIR="%{buildroot}" LIBDIR="%{_libdir}" SHLIBDIR="%{_libdir}" install %{_mandir}/man3/* %changelog +* Tue Mar 26 2024 gengqihu - 3.3-6 +- backport bugfix from upstream + * Mon Nov 27 2023 luhuaxin - 3.3-5 - backport upstream patch -- Gitee