summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVijay Anusuri <vanusuri@mvista.com>2023-06-28 12:58:12 +0530
committerSteve Sakoman <steve@sakoman.com>2023-07-04 05:37:07 -1000
commit725643695784353c7465173d08d3774c1c1b38ed (patch)
tree274746808c7726077d99a8a2ff7e1cbd14b7dcad
parentf25b3632334c6ee4920e1dfd4634111344672b3f (diff)
downloadpoky-725643695784353c7465173d08d3774c1c1b38ed.tar.gz
libcap: backport Debian patches to fix CVE-2023-2602 and CVE-2023-2603
import patches from ubuntu to fix CVE-2023-2602 CVE-2023-2603 Upstream-Status: Backport [import from ubuntu https://git.launchpad.net/ubuntu/+source/libcap2/tree/debian/patches?h=ubuntu/focal-security Upstream commit https://git.kernel.org/pub/scm/libs/libcap/libcap.git/commit/?id=bc6b36682f188020ee4770fae1d41bde5b2c97bb & https://git.kernel.org/pub/scm/libs/libcap/libcap.git/commit/?id=422bec25ae4a1ab03fd4d6f728695ed279173b18] (From OE-Core rev: d0718a43a00223aa074f14e769214ba11d4f8ef2) Signed-off-by: Vijay Anusuri <vanusuri@mvista.com> Signed-off-by: Steve Sakoman <steve@sakoman.com>
-rw-r--r--meta/recipes-support/libcap/files/CVE-2023-2602.patch52
-rw-r--r--meta/recipes-support/libcap/files/CVE-2023-2603.patch58
-rw-r--r--meta/recipes-support/libcap/libcap_2.32.bb2
3 files changed, 112 insertions, 0 deletions
diff --git a/meta/recipes-support/libcap/files/CVE-2023-2602.patch b/meta/recipes-support/libcap/files/CVE-2023-2602.patch
new file mode 100644
index 0000000000..ca04d7297a
--- /dev/null
+++ b/meta/recipes-support/libcap/files/CVE-2023-2602.patch
@@ -0,0 +1,52 @@
1Backport of:
2
3From bc6b36682f188020ee4770fae1d41bde5b2c97bb Mon Sep 17 00:00:00 2001
4From: "Andrew G. Morgan" <morgan@kernel.org>
5Date: Wed, 3 May 2023 19:18:36 -0700
6Subject: Correct the check of pthread_create()'s return value.
7
8This function returns a positive number (errno) on error, so the code
9wasn't previously freeing some memory in this situation.
10
11Discussion:
12
13 https://stackoverflow.com/a/3581020/14760867
14
15Credit for finding this bug in libpsx goes to David Gstir of
16X41 D-Sec GmbH (https://x41-dsec.de/) who performed a security
17audit of the libcap source code in April of 2023. The audit
18was sponsored by the Open Source Technology Improvement Fund
19(https://ostif.org/).
20
21Audit ref: LCAP-CR-23-01 (CVE-2023-2602)
22
23Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
24
25Upstream-Status: Backport [import from ubuntu https://git.launchpad.net/ubuntu/+source/libcap2/tree/debian/patches/CVE-2023-2602.patch?h=ubuntu/focal-security
26Upstream commit https://git.kernel.org/pub/scm/libs/libcap/libcap.git/commit/?id=bc6b36682f188020ee4770fae1d41bde5b2c97bb]
27CVE: CVE-2023-2602
28Signed-off-by: Vijay Anusuri <vanusuri@mvista.com>
29---
30 psx/psx.c | 2 +-
31 1 file changed, 1 insertion(+), 1 deletion(-)
32
33--- a/libcap/psx.c
34+++ b/libcap/psx.c
35@@ -272,7 +272,7 @@ int psx_pthread_create(pthread_t *thread
36
37 psx_wait_for_idle();
38 int ret = pthread_create(thread, attr, start_routine, arg);
39- if (ret != -1) {
40+ if (ret == 0) {
41 psx_do_registration(*thread);
42 }
43 psx_resume_idle();
44@@ -287,7 +287,7 @@ int __wrap_pthread_create(pthread_t *thr
45 void *(*start_routine) (void *), void *arg) {
46 psx_wait_for_idle();
47 int ret = __real_pthread_create(thread, attr, start_routine, arg);
48- if (ret != -1) {
49+ if (ret == 0) {
50 psx_do_registration(*thread);
51 }
52 psx_resume_idle();
diff --git a/meta/recipes-support/libcap/files/CVE-2023-2603.patch b/meta/recipes-support/libcap/files/CVE-2023-2603.patch
new file mode 100644
index 0000000000..cf86ac2a46
--- /dev/null
+++ b/meta/recipes-support/libcap/files/CVE-2023-2603.patch
@@ -0,0 +1,58 @@
1Backport of:
2
3From 422bec25ae4a1ab03fd4d6f728695ed279173b18 Mon Sep 17 00:00:00 2001
4From: "Andrew G. Morgan" <morgan@kernel.org>
5Date: Wed, 3 May 2023 19:44:22 -0700
6Subject: Large strings can confuse libcap's internal strdup code.
7
8Avoid something subtle with really long strings: 1073741823 should
9be enough for anybody. This is an improved fix over something attempted
10in libcap-2.55 to address some static analysis findings.
11
12Reviewing the library, cap_proc_root() and cap_launcher_set_chroot()
13are the only two calls where the library is potentially exposed to a
14user controlled string input.
15
16Credit for finding this bug in libcap goes to Richard Weinberger of
17X41 D-Sec GmbH (https://x41-dsec.de/) who performed a security audit
18of the libcap source code in April of 2023. The audit was sponsored
19by the Open Source Technology Improvement Fund (https://ostif.org/).
20
21Audit ref: LCAP-CR-23-02 (CVE-2023-2603)
22
23Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
24
25Upstream-Status: Backport [import from ubuntu https://git.launchpad.net/ubuntu/+source/libcap2/tree/debian/patches/CVE-2023-2603.patch?h=ubuntu/focal-security
26Upstream commit https://git.kernel.org/pub/scm/libs/libcap/libcap.git/commit/?id=422bec25ae4a1ab03fd4d6f728695ed279173b18]
27CVE: CVE-2023-2603
28Signed-off-by: Vijay Anusuri <vanusuri@mvista.com>
29---
30 libcap/cap_alloc.c | 12 +++++++-----
31 1 file changed, 7 insertions(+), 5 deletions(-)
32
33--- a/libcap/cap_alloc.c
34+++ b/libcap/cap_alloc.c
35@@ -76,13 +76,22 @@ cap_t cap_init(void)
36 char *_libcap_strdup(const char *old)
37 {
38 __u32 *raw_data;
39+ size_t len;
40
41 if (old == NULL) {
42 errno = EINVAL;
43 return NULL;
44 }
45
46- raw_data = malloc( sizeof(__u32) + strlen(old) + 1 );
47+ len = strlen(old);
48+ if ((len & 0x3fffffff) != len) {
49+ _cap_debug("len is too long for libcap to manage");
50+ errno = EINVAL;
51+ return NULL;
52+ }
53+ len += sizeof(__u32) + 1;
54+
55+ raw_data = malloc(len);
56 if (raw_data == NULL) {
57 errno = ENOMEM;
58 return NULL;
diff --git a/meta/recipes-support/libcap/libcap_2.32.bb b/meta/recipes-support/libcap/libcap_2.32.bb
index d67babb5e9..64d5190aa7 100644
--- a/meta/recipes-support/libcap/libcap_2.32.bb
+++ b/meta/recipes-support/libcap/libcap_2.32.bb
@@ -13,6 +13,8 @@ SRC_URI = "${KERNELORG_MIRROR}/linux/libs/security/linux-privs/${BPN}2/${BPN}-${
13 file://0001-ensure-the-XATTR_NAME_CAPS-is-defined-when-it-is-use.patch \ 13 file://0001-ensure-the-XATTR_NAME_CAPS-is-defined-when-it-is-use.patch \
14 file://0002-tests-do-not-run-target-executables.patch \ 14 file://0002-tests-do-not-run-target-executables.patch \
15 file://0001-tests-do-not-statically-link-a-test.patch \ 15 file://0001-tests-do-not-statically-link-a-test.patch \
16 file://CVE-2023-2602.patch \
17 file://CVE-2023-2603.patch \
16 " 18 "
17SRC_URI[md5sum] = "7416119c9fdcfd0e8dd190a432c668e9" 19SRC_URI[md5sum] = "7416119c9fdcfd0e8dd190a432c668e9"
18SRC_URI[sha256sum] = "1005e3d227f2340ad1e3360ef8b69d15e3c72a29c09f4894d7aac038bd26e2be" 20SRC_URI[sha256sum] = "1005e3d227f2340ad1e3360ef8b69d15e3c72a29c09f4894d7aac038bd26e2be"