summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/recipes-support/libcap/files/CVE-2023-2603.patch60
-rw-r--r--meta/recipes-support/libcap/libcap_2.66.bb1
2 files changed, 61 insertions, 0 deletions
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..e09be78640
--- /dev/null
+++ b/meta/recipes-support/libcap/files/CVE-2023-2603.patch
@@ -0,0 +1,60 @@
1From 422bec25ae4a1ab03fd4d6f728695ed279173b18 Mon Sep 17 00:00:00 2001
2From: "Andrew G. Morgan" <morgan@kernel.org>
3Date: Wed, 3 May 2023 19:44:22 -0700
4Subject: Large strings can confuse libcap's internal strdup code.
5
6Avoid something subtle with really long strings: 1073741823 should
7be enough for anybody. This is an improved fix over something attempted
8in libcap-2.55 to address some static analysis findings.
9
10Reviewing the library, cap_proc_root() and cap_launcher_set_chroot()
11are the only two calls where the library is potentially exposed to a
12user controlled string input.
13
14Credit for finding this bug in libcap goes to Richard Weinberger of
15X41 D-Sec GmbH (https://x41-dsec.de/) who performed a security audit
16of the libcap source code in April of 2023. The audit was sponsored
17by the Open Source Technology Improvement Fund (https://ostif.org/).
18
19Audit ref: LCAP-CR-23-02 (CVE-2023-2603)
20
21Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
22
23Upstream-Status: Backport [https://git.kernel.org/pub/scm/libs/libcap/libcap.git/commit/?id=422bec25ae4a1ab03fd4d6f728695ed279173b18]
24CVE: CVE-2023-2603
25Signed-off-by: Vivek Kumbhar <vkumbhar@mvista.com>
26
27---
28 libcap/cap_alloc.c | 12 +++++++-----
29 1 file changed, 7 insertions(+), 5 deletions(-)
30
31diff --git a/libcap/cap_alloc.c b/libcap/cap_alloc.c
32index c826e7a..25f9981 100644
33--- a/libcap/cap_alloc.c
34+++ b/libcap/cap_alloc.c
35@@ -105,15 +105,17 @@ char *_libcap_strdup(const char *old)
36 errno = EINVAL;
37 return NULL;
38 }
39- len = strlen(old) + 1 + 2*sizeof(__u32);
40- if (len < sizeof(struct _cap_alloc_s)) {
41- len = sizeof(struct _cap_alloc_s);
42- }
43- if ((len & 0xffffffff) != len) {
44+
45+ len = strlen(old);
46+ if ((len & 0x3fffffff) != len) {
47 _cap_debug("len is too long for libcap to manage");
48 errno = EINVAL;
49 return NULL;
50 }
51+ len += 1 + 2*sizeof(__u32);
52+ if (len < sizeof(struct _cap_alloc_s)) {
53+ len = sizeof(struct _cap_alloc_s);
54+ }
55
56 raw_data = calloc(1, len);
57 if (raw_data == NULL) {
58--
592.25.1
60
diff --git a/meta/recipes-support/libcap/libcap_2.66.bb b/meta/recipes-support/libcap/libcap_2.66.bb
index d3189fb105..7534063b7d 100644
--- a/meta/recipes-support/libcap/libcap_2.66.bb
+++ b/meta/recipes-support/libcap/libcap_2.66.bb
@@ -17,6 +17,7 @@ SRC_URI = "${KERNELORG_MIRROR}/linux/libs/security/linux-privs/${BPN}2/${BPN}-${
17 file://0001-ensure-the-XATTR_NAME_CAPS-is-defined-when-it-is-use.patch \ 17 file://0001-ensure-the-XATTR_NAME_CAPS-is-defined-when-it-is-use.patch \
18 file://0002-tests-do-not-run-target-executables.patch \ 18 file://0002-tests-do-not-run-target-executables.patch \
19 file://CVE-2023-2602.patch \ 19 file://CVE-2023-2602.patch \
20 file://CVE-2023-2603.patch \
20 " 21 "
21SRC_URI:append:class-nativesdk = " \ 22SRC_URI:append:class-nativesdk = " \
22 file://0001-nativesdk-libcap-Raise-the-size-of-arrays-containing.patch \ 23 file://0001-nativesdk-libcap-Raise-the-size-of-arrays-containing.patch \