summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRanjitsinh Rathod <ranjitsinh.rathod@kpit.com>2021-08-25 10:25:09 +0530
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-09-01 16:27:09 +0100
commit420d5551b2c36ba0d097916a8712b0313e75e39a (patch)
tree189cb05b3698e03f4de31e0c15b0740748fe86de
parent6bcc4029d4eac98632050c7a16cd81cbc54ba45e (diff)
downloadpoky-420d5551b2c36ba0d097916a8712b0313e75e39a.tar.gz
rpm: Add fix for CVE-2021-20266
Adding fix for CVE-2021-20266 Upstream-Status: Backport [https://github.com/rpm-software-management/rpm/pull/1587/commits/9646711891df851dfbf7ef54cc171574a0914b15] Note: Hunk#2 and Hunk#3 refreshed to apply patch and match value of dl_max variable to make it with current version All Hunks are refreshed to solve patch-fuzz (From OE-Core rev: 6c16aad7167eb98bc9995486f967431c39f9df15) Signed-off-by: Ranjitsinh Rathod <ranjitsinh.rathod@kpit.com> Signed-off-by: Steve Sakoman <steve@sakoman.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/recipes-devtools/rpm/files/CVE-2021-20266.patch109
-rw-r--r--meta/recipes-devtools/rpm/rpm_4.14.2.1.bb1
2 files changed, 110 insertions, 0 deletions
diff --git a/meta/recipes-devtools/rpm/files/CVE-2021-20266.patch b/meta/recipes-devtools/rpm/files/CVE-2021-20266.patch
new file mode 100644
index 0000000000..f2fc47e321
--- /dev/null
+++ b/meta/recipes-devtools/rpm/files/CVE-2021-20266.patch
@@ -0,0 +1,109 @@
1From ebbf0f0133c498d229e94ecf2ed0b41d6e6a142a Mon Sep 17 00:00:00 2001
2From: Demi Marie Obenour <athena@invisiblethingslab.com>
3Date: Mon, 8 Feb 2021 16:05:01 -0500
4Subject: [PATCH] hdrblobInit() needs bounds checks too
5
6Users can pass untrusted data to hdrblobInit() and it must be robust
7against this.
8
9Backported from commit 8f4b3c3cab8922a2022b9e47c71f1ecf906077ef
10
11Upstream-Status: Backport [https://github.com/rpm-software-management/rpm/pull/1587/commits/9646711891df851dfbf7ef54cc171574a0914b15]
12CVE: CVE-2021-20266
13Signed-off-by: Ranjitsinh Rathod <ranjitsinh.rathod@kpit.com>
14
15---
16 lib/header.c | 48 +++++++++++++++++++++++++++++++-----------------
17 1 file changed, 31 insertions(+), 17 deletions(-)
18
19diff --git a/lib/header.c b/lib/header.c
20index 5b09f8352..ad5b6dc57 100644
21--- a/lib/header.c
22+++ b/lib/header.c
23@@ -11,6 +11,7 @@
24 #include "system.h"
25 #include <netdb.h>
26 #include <errno.h>
27+#include <inttypes.h>
28 #include <rpm/rpmtypes.h>
29 #include <rpm/rpmstring.h>
30 #include "lib/header_internal.h"
31@@ -1890,6 +1891,25 @@ hdrblob hdrblobFree(hdrblob blob)
32 return NULL;
33 }
34
35+static rpmRC hdrblobVerifyLengths(rpmTagVal regionTag, uint32_t il, uint32_t dl,
36+ char **emsg) {
37+ uint32_t il_max = HEADER_TAGS_MAX;
38+ uint32_t dl_max = HEADER_DATA_MAX;
39+ if (regionTag == RPMTAG_HEADERSIGNATURES) {
40+ il_max = 32;
41+ dl_max = 8192;
42+ }
43+ if (hdrchkRange(il_max, il)) {
44+ rasprintf(emsg, _("hdr tags: BAD, no. of tags(%" PRIu32 ") out of range"), il);
45+ return RPMRC_FAIL;
46+ }
47+ if (hdrchkRange(dl_max, dl)) {
48+ rasprintf(emsg, _("hdr data: BAD, no. of bytes(%" PRIu32 ") out of range"), dl);
49+ return RPMRC_FAIL;
50+ }
51+ return RPMRC_OK;
52+}
53+
54 rpmRC hdrblobRead(FD_t fd, int magic, int exact_size, rpmTagVal regionTag, hdrblob blob, char **emsg)
55 {
56 int32_t block[4];
57@@ -1902,13 +1922,6 @@ rpmRC hdrblobRead(FD_t fd, int magic, int exact_size, rpmTagVal regionTag, hdrbl
58 size_t nb;
59 rpmRC rc = RPMRC_FAIL; /* assume failure */
60 int xx;
61- int32_t il_max = HEADER_TAGS_MAX;
62- int32_t dl_max = HEADER_DATA_MAX;
63-
64- if (regionTag == RPMTAG_HEADERSIGNATURES) {
65- il_max = 32;
66- dl_max = 8192;
67- }
68
69 memset(block, 0, sizeof(block));
70 if ((xx = Freadall(fd, bs, blen)) != blen) {
71@@ -1921,15 +1934,9 @@ rpmRC hdrblobRead(FD_t fd, int magic, int exact_size, rpmTagVal regionTag, hdrbl
72 goto exit;
73 }
74 il = ntohl(block[2]);
75- if (hdrchkRange(il_max, il)) {
76- rasprintf(emsg, _("hdr tags: BAD, no. of tags(%d) out of range"), il);
77- goto exit;
78- }
79 dl = ntohl(block[3]);
80- if (hdrchkRange(dl_max, dl)) {
81- rasprintf(emsg, _("hdr data: BAD, no. of bytes(%d) out of range"), dl);
82+ if (hdrblobVerifyLengths(regionTag, il, dl, emsg))
83 goto exit;
84- }
85
86 nb = (il * sizeof(struct entryInfo_s)) + dl;
87 uc = sizeof(il) + sizeof(dl) + nb;
88@@ -1973,11 +1980,18 @@ rpmRC hdrblobInit(const void *uh, size_t uc,
89 struct hdrblob_s *blob, char **emsg)
90 {
91 rpmRC rc = RPMRC_FAIL;
92-
93 memset(blob, 0, sizeof(*blob));
94+ if (uc && uc < 8) {
95+ rasprintf(emsg, _("hdr length: BAD"));
96+ goto exit;
97+ }
98+
99 blob->ei = (int32_t *) uh; /* discards const */
100- blob->il = ntohl(blob->ei[0]);
101- blob->dl = ntohl(blob->ei[1]);
102+ blob->il = ntohl((uint32_t)(blob->ei[0]));
103+ blob->dl = ntohl((uint32_t)(blob->ei[1]));
104+ if (hdrblobVerifyLengths(regionTag, blob->il, blob->dl, emsg) != RPMRC_OK)
105+ goto exit;
106+
107 blob->pe = (entryInfo) &(blob->ei[2]);
108 blob->pvlen = sizeof(blob->il) + sizeof(blob->dl) +
109 (blob->il * sizeof(*blob->pe)) + blob->dl;
diff --git a/meta/recipes-devtools/rpm/rpm_4.14.2.1.bb b/meta/recipes-devtools/rpm/rpm_4.14.2.1.bb
index 018b2f8700..c93654aa8f 100644
--- a/meta/recipes-devtools/rpm/rpm_4.14.2.1.bb
+++ b/meta/recipes-devtools/rpm/rpm_4.14.2.1.bb
@@ -45,6 +45,7 @@ SRC_URI = "git://github.com/rpm-software-management/rpm;branch=rpm-4.14.x \
45 file://0001-Rip-out-partial-support-for-unused-MD2-and-RIPEMD160.patch \ 45 file://0001-Rip-out-partial-support-for-unused-MD2-and-RIPEMD160.patch \
46 file://0001-rpmplugins.c-call-dlerror-prior-to-dlsym.patch \ 46 file://0001-rpmplugins.c-call-dlerror-prior-to-dlsym.patch \
47 file://CVE-2021-3421.patch \ 47 file://CVE-2021-3421.patch \
48 file://CVE-2021-20266.patch \
48 " 49 "
49 50
50PE = "1" 51PE = "1"