Skip to content

Commit 515cb74

Browse files
[AUTO-CHERRYPICK] apparmor: add patches for CVE-2023-50471 and CVE-2023-50472 - branch main (#7149)
Co-authored-by: Dallas Delaney <106280731+dallasd1@users.noreply.github.com>
1 parent c00ee1f commit 515cb74

2 files changed

Lines changed: 68 additions & 1 deletion

File tree

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
From 60ff122ef5862d04b39b150541459e7f5e35add8 Mon Sep 17 00:00:00 2001
2+
From: Lee <peterlee@apache.org>
3+
Date: Mon, 18 Dec 2023 11:47:52 +0800
4+
Subject: [PATCH] add NULL checkings (#809)
5+
6+
* add NULL checks in cJSON_SetValuestring
7+
8+
Fixes #803(CVE-2023-50472)
9+
10+
* add NULL check in cJSON_InsertItemInArray
11+
12+
Fixes #802(CVE-2023-50471)
13+
14+
* add tests for NULL checks
15+
16+
add tests for NULL checks in cJSON_InsertItemInArray and cJSON_SetValuestring
17+
---
18+
binutils/cJSON.c | 14 ++++++++++++--
19+
tests/misc_tests.c | 21 +++++++++++++++++++++
20+
2 files changed, 33 insertions(+), 2 deletions(-)
21+
22+
diff --git a/binutils/cJSON.c b/binutils/cJSON.c
23+
index f6dd11c..faa3e29 100644
24+
--- a/binutils/cJSON.c
25+
+++ b/binutils/cJSON.c
26+
@@ -401,7 +401,12 @@ CJSON_PUBLIC(char*) cJSON_SetValuestring(cJSON *object, const char *valuestring)
27+
{
28+
char *copy = NULL;
29+
/* if object's type is not cJSON_String or is cJSON_IsReference, it should not set valuestring */
30+
- if (!(object->type & cJSON_String) || (object->type & cJSON_IsReference))
31+
+ if ((object == NULL) || !(object->type & cJSON_String) || (object->type & cJSON_IsReference))
32+
+ {
33+
+ return NULL;
34+
+ }
35+
+ /* return NULL if the object is corrupted */
36+
+ if (object->valuestring == NULL)
37+
{
38+
return NULL;
39+
}
40+
@@ -2264,7 +2269,7 @@ CJSON_PUBLIC(cJSON_bool) cJSON_InsertItemInArray(cJSON *array, int which, cJSON
41+
{
42+
cJSON *after_inserted = NULL;
43+
44+
- if (which < 0)
45+
+ if (which < 0 || newitem == NULL)
46+
{
47+
return false;
48+
}
49+
@@ -2275,6 +2280,11 @@ CJSON_PUBLIC(cJSON_bool) cJSON_InsertItemInArray(cJSON *array, int which, cJSON
50+
return add_item_to_array(array, newitem);
51+
}
52+
53+
+ if (after_inserted != array->child && after_inserted->prev == NULL) {
54+
+ /* return false if after_inserted is a corrupted array item */
55+
+ return false;
56+
+ }
57+
+
58+
newitem->next = after_inserted;
59+
newitem->prev = after_inserted->prev;
60+
after_inserted->prev = newitem;
61+
62+
--
63+
2.17.1

SPECS/apparmor/apparmor.spec

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
Summary: AppArmor is an effective and easy-to-use Linux application security system.
22
Name: apparmor
33
Version: 3.0.4
4-
Release: 2%{?dist}
4+
Release: 3%{?dist}
55
License: GPLv2
66
Vendor: Microsoft Corporation
77
Distribution: Mariner
88
Group: Productivity/Security
99
URL: https://launchpad.net/apparmor
1010
Source0: https://launchpad.net/apparmor/3.0/3.0.4/+download/%{name}-%{version}.tar.gz
1111
Patch1: apparmor-service-start-fix.patch
12+
Patch2: CVE-2023-50471.patch
1213
# CVE-2016-1585 has no upstream fix as of 2020/09/28
1314
Patch100: CVE-2016-1585.nopatch
1415
BuildRequires: apr
@@ -353,6 +354,9 @@ make DESTDIR=%{buildroot} install
353354
%exclude %{perl_archlib}/perllocal.pod
354355

355356
%changelog
357+
* Wed Dec 27 2023 Dallas Delaney <dadelan@microsoft.com> - 3.0.4-3
358+
- Add patch for CVE-2023-50471 and CVE-2023-50472
359+
356360
* Wed Sep 20 2023 Jon Slobodzian <joslobo@microsoft.com> - 3.0.4-2
357361
- Recompile with stack-protection fixed gcc version (CVE-2023-4039)
358362

0 commit comments

Comments
 (0)