diff options
Diffstat (limited to 'meta/recipes-devtools/elfutils/files/CVE-2021-33294.patch')
-rw-r--r-- | meta/recipes-devtools/elfutils/files/CVE-2021-33294.patch | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/meta/recipes-devtools/elfutils/files/CVE-2021-33294.patch b/meta/recipes-devtools/elfutils/files/CVE-2021-33294.patch new file mode 100644 index 0000000000..0500a4cf83 --- /dev/null +++ b/meta/recipes-devtools/elfutils/files/CVE-2021-33294.patch | |||
@@ -0,0 +1,72 @@ | |||
1 | From 480b6fa3662ba8ffeee274bf0d37423413c01e55 Mon Sep 17 00:00:00 2001 | ||
2 | From: Mark Wielaard <mark@klomp.org> | ||
3 | Date: Wed, 3 Mar 2021 21:40:53 +0100 | ||
4 | Subject: [PATCH] readelf: Sanity check verneed and verdef offsets in handle_symtab. | ||
5 | |||
6 | We are going through vna_next, vn_next and vd_next in a while loop. | ||
7 | Make sure that all offsets are sane. We don't want things to wrap | ||
8 | around so we go in cycles. | ||
9 | |||
10 | https://sourceware.org/bugzilla/show_bug.cgi?id=27501 | ||
11 | |||
12 | Signed-off-by: Mark Wielaard <mark@klomp.org> | ||
13 | |||
14 | Upstream-Status: Backport [https://sourceware.org/git/?p=elfutils.git;a=commit;h=480b6fa3662ba8ffeee274bf0d37423413c01e55] | ||
15 | CVE: CVE-2021-33294 | ||
16 | Signed-off-by: Vijay Anusuri <vanusuri@mvista.com> | ||
17 | --- | ||
18 | src/ChangeLog | 5 +++++ | ||
19 | src/readelf.c | 10 +++++++++- | ||
20 | 2 files changed, 14 insertions(+), 1 deletion(-) | ||
21 | |||
22 | diff --git a/src/ChangeLog b/src/ChangeLog | ||
23 | index 6af977e..f0d9e39 100644 | ||
24 | --- a/src/ChangeLog | ||
25 | +++ b/src/ChangeLog | ||
26 | @@ -1,3 +1,8 @@ | ||
27 | +2021-03-03 Mark Wielaard <mark@klomp.org> | ||
28 | + | ||
29 | + * readelf.c (handle_symtab): Sanity check verneed vna_next, | ||
30 | + vn_next and verdef vd_next offsets. | ||
31 | + | ||
32 | 2019-11-26 Mark Wielaard <mark@klomp.org> | ||
33 | |||
34 | * Makefile.am (BUILD_STATIC): Add libraries needed for libdw. | ||
35 | diff --git a/src/readelf.c b/src/readelf.c | ||
36 | index 5994615..ab7a1c1 100644 | ||
37 | --- a/src/readelf.c | ||
38 | +++ b/src/readelf.c | ||
39 | @@ -2550,7 +2550,9 @@ handle_symtab (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr) | ||
40 | &vernaux_mem); | ||
41 | while (vernaux != NULL | ||
42 | && vernaux->vna_other != *versym | ||
43 | - && vernaux->vna_next != 0) | ||
44 | + && vernaux->vna_next != 0 | ||
45 | + && (verneed_data->d_size - vna_offset | ||
46 | + >= vernaux->vna_next)) | ||
47 | { | ||
48 | /* Update the offset. */ | ||
49 | vna_offset += vernaux->vna_next; | ||
50 | @@ -2567,6 +2569,9 @@ handle_symtab (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr) | ||
51 | /* Found it. */ | ||
52 | break; | ||
53 | |||
54 | + if (verneed_data->d_size - vn_offset < verneed->vn_next) | ||
55 | + break; | ||
56 | + | ||
57 | vn_offset += verneed->vn_next; | ||
58 | verneed = (verneed->vn_next == 0 | ||
59 | ? NULL | ||
60 | @@ -2602,6 +2607,9 @@ handle_symtab (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr) | ||
61 | /* Found the definition. */ | ||
62 | break; | ||
63 | |||
64 | + if (verdef_data->d_size - vd_offset < verdef->vd_next) | ||
65 | + break; | ||
66 | + | ||
67 | vd_offset += verdef->vd_next; | ||
68 | verdef = (verdef->vd_next == 0 | ||
69 | ? NULL | ||
70 | -- | ||
71 | 2.25.1 | ||
72 | |||