diff options
author | Zqiang <qiang.zhang@windriver.com> | 2021-09-10 11:21:04 +0800 |
---|---|---|
committer | Bruce Ashfield <bruce.ashfield@gmail.com> | 2021-09-16 18:04:28 -0400 |
commit | 15388c440d6792592f7d0cdeea1a3f15bda414e5 (patch) | |
tree | 9ba3fd6b04932fe7d9a92839012e7e9a3c66f6d8 | |
parent | 47f9bdaa9ea883b23f596342033ecebd905c890e (diff) | |
download | meta-virtualization-15388c440d6792592f7d0cdeea1a3f15bda414e5.tar.gz |
openvswitch: fix CVE-2021-36980
Open vSwitch (aka openvswitch) 2.11.0 through 2.15.0 has
a use-after-free in decode_NXAST_RAW_ENCAP (called from
ofpact_decode and ofpacts_decode) during the decoding of
a RAW_ENCAP action.
Reference:
https://nvd.nist.gov/vuln/detail/CVE-2021-36980
Patches from:
https://github.com/openvswitch/ovs/commit/65c61b0c23a0d474696d7b1cea522a5016a8aeb3
Signed-off-by: Zqiang <qiang.zhang@windriver.com>
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
-rw-r--r-- | recipes-networking/openvswitch/files/0001-ofp-actions-Fix-use-after-free-while-decoding-RAW_EN.patch | 97 | ||||
-rw-r--r-- | recipes-networking/openvswitch/openvswitch_git.bb | 1 |
2 files changed, 98 insertions, 0 deletions
diff --git a/recipes-networking/openvswitch/files/0001-ofp-actions-Fix-use-after-free-while-decoding-RAW_EN.patch b/recipes-networking/openvswitch/files/0001-ofp-actions-Fix-use-after-free-while-decoding-RAW_EN.patch new file mode 100644 index 00000000..3afd1bad --- /dev/null +++ b/recipes-networking/openvswitch/files/0001-ofp-actions-Fix-use-after-free-while-decoding-RAW_EN.patch | |||
@@ -0,0 +1,97 @@ | |||
1 | From 77cccc74deede443e8b9102299efc869a52b65b2 Mon Sep 17 00:00:00 2001 | ||
2 | From: Ilya Maximets <i.maximets@ovn.org> | ||
3 | Date: Tue, 16 Feb 2021 23:27:30 +0100 | ||
4 | Subject: [PATCH] ofp-actions: Fix use-after-free while decoding RAW_ENCAP. | ||
5 | |||
6 | While decoding RAW_ENCAP action, decode_ed_prop() might re-allocate | ||
7 | ofpbuf if there is no enough space left. However, function | ||
8 | 'decode_NXAST_RAW_ENCAP' continues to use old pointer to 'encap' | ||
9 | structure leading to write-after-free and incorrect decoding. | ||
10 | |||
11 | ==3549105==ERROR: AddressSanitizer: heap-use-after-free on address | ||
12 | 0x60600000011a at pc 0x0000005f6cc6 bp 0x7ffc3a2d4410 sp 0x7ffc3a2d4408 | ||
13 | WRITE of size 2 at 0x60600000011a thread T0 | ||
14 | #0 0x5f6cc5 in decode_NXAST_RAW_ENCAP lib/ofp-actions.c:4461:20 | ||
15 | #1 0x5f0551 in ofpact_decode ./lib/ofp-actions.inc2:4777:16 | ||
16 | #2 0x5ed17c in ofpacts_decode lib/ofp-actions.c:7752:21 | ||
17 | #3 0x5eba9a in ofpacts_pull_openflow_actions__ lib/ofp-actions.c:7791:13 | ||
18 | #4 0x5eb9fc in ofpacts_pull_openflow_actions lib/ofp-actions.c:7835:12 | ||
19 | #5 0x64bb8b in ofputil_decode_packet_out lib/ofp-packet.c:1113:17 | ||
20 | #6 0x65b6f4 in ofp_print_packet_out lib/ofp-print.c:148:13 | ||
21 | #7 0x659e3f in ofp_to_string__ lib/ofp-print.c:1029:16 | ||
22 | #8 0x659b24 in ofp_to_string lib/ofp-print.c:1244:21 | ||
23 | #9 0x65a28c in ofp_print lib/ofp-print.c:1288:28 | ||
24 | #10 0x540d11 in ofctl_ofp_parse utilities/ovs-ofctl.c:2814:9 | ||
25 | #11 0x564228 in ovs_cmdl_run_command__ lib/command-line.c:247:17 | ||
26 | #12 0x56408a in ovs_cmdl_run_command lib/command-line.c:278:5 | ||
27 | #13 0x5391ae in main utilities/ovs-ofctl.c:179:9 | ||
28 | #14 0x7f6911ce9081 in __libc_start_main (/lib64/libc.so.6+0x27081) | ||
29 | #15 0x461fed in _start (utilities/ovs-ofctl+0x461fed) | ||
30 | |||
31 | Fix that by getting a new pointer before using. | ||
32 | |||
33 | Credit to OSS-Fuzz. | ||
34 | |||
35 | Fuzzer regression test will fail only with AddressSanitizer enabled. | ||
36 | |||
37 | Reported-at: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=27851 | ||
38 | Fixes: f839892a206a ("OF support and translation of generic encap and decap") | ||
39 | Acked-by: William Tu <u9012063@gmail.com> | ||
40 | Signed-off-by: Ilya Maximets <i.maximets@ovn.org> | ||
41 | --- | ||
42 | lib/ofp-actions.c | 2 ++ | ||
43 | tests/automake.mk | 3 ++- | ||
44 | tests/fuzz-regression-list.at | 1 + | ||
45 | tests/fuzz-regression/ofp_print_fuzzer-6540965472632832 | 0 | ||
46 | 4 files changed, 5 insertions(+), 1 deletion(-) | ||
47 | create mode 100644 tests/fuzz-regression/ofp_print_fuzzer-6540965472632832 | ||
48 | |||
49 | diff --git a/lib/ofp-actions.c b/lib/ofp-actions.c | ||
50 | index e2e829772..0342a228b 100644 | ||
51 | --- a/lib/ofp-actions.c | ||
52 | +++ b/lib/ofp-actions.c | ||
53 | @@ -4431,6 +4431,7 @@ decode_NXAST_RAW_ENCAP(const struct nx_action_encap *nae, | ||
54 | { | ||
55 | struct ofpact_encap *encap; | ||
56 | const struct ofp_ed_prop_header *ofp_prop; | ||
57 | + const size_t encap_ofs = out->size; | ||
58 | size_t props_len; | ||
59 | uint16_t n_props = 0; | ||
60 | int err; | ||
61 | @@ -4458,6 +4459,7 @@ decode_NXAST_RAW_ENCAP(const struct nx_action_encap *nae, | ||
62 | } | ||
63 | n_props++; | ||
64 | } | ||
65 | + encap = ofpbuf_at_assert(out, encap_ofs, sizeof *encap); | ||
66 | encap->n_props = n_props; | ||
67 | out->header = &encap->ofpact; | ||
68 | ofpact_finish_ENCAP(out, &encap); | ||
69 | diff --git a/tests/automake.mk b/tests/automake.mk | ||
70 | index 677b99a6b..fc80e027d 100644 | ||
71 | --- a/tests/automake.mk | ||
72 | +++ b/tests/automake.mk | ||
73 | @@ -134,7 +134,8 @@ FUZZ_REGRESSION_TESTS = \ | ||
74 | tests/fuzz-regression/ofp_print_fuzzer-5722747668791296 \ | ||
75 | tests/fuzz-regression/ofp_print_fuzzer-6285128790704128 \ | ||
76 | tests/fuzz-regression/ofp_print_fuzzer-6470117922701312 \ | ||
77 | - tests/fuzz-regression/ofp_print_fuzzer-6502620041576448 | ||
78 | + tests/fuzz-regression/ofp_print_fuzzer-6502620041576448 \ | ||
79 | + tests/fuzz-regression/ofp_print_fuzzer-6540965472632832 | ||
80 | $(srcdir)/tests/fuzz-regression-list.at: tests/automake.mk | ||
81 | $(AM_V_GEN)for name in $(FUZZ_REGRESSION_TESTS); do \ | ||
82 | basename=`echo $$name | sed 's,^.*/,,'`; \ | ||
83 | diff --git a/tests/fuzz-regression-list.at b/tests/fuzz-regression-list.at | ||
84 | index e3173fb88..2347c690e 100644 | ||
85 | --- a/tests/fuzz-regression-list.at | ||
86 | +++ b/tests/fuzz-regression-list.at | ||
87 | @@ -21,3 +21,4 @@ TEST_FUZZ_REGRESSION([ofp_print_fuzzer-5722747668791296]) | ||
88 | TEST_FUZZ_REGRESSION([ofp_print_fuzzer-6285128790704128]) | ||
89 | TEST_FUZZ_REGRESSION([ofp_print_fuzzer-6470117922701312]) | ||
90 | TEST_FUZZ_REGRESSION([ofp_print_fuzzer-6502620041576448]) | ||
91 | +TEST_FUZZ_REGRESSION([ofp_print_fuzzer-6540965472632832]) | ||
92 | diff --git a/tests/fuzz-regression/ofp_print_fuzzer-6540965472632832 b/tests/fuzz-regression/ofp_print_fuzzer-6540965472632832 | ||
93 | new file mode 100644 | ||
94 | index 000000000..e69de29bb | ||
95 | -- | ||
96 | 2.17.1 | ||
97 | |||
diff --git a/recipes-networking/openvswitch/openvswitch_git.bb b/recipes-networking/openvswitch/openvswitch_git.bb index 412a7075..303f200b 100644 --- a/recipes-networking/openvswitch/openvswitch_git.bb +++ b/recipes-networking/openvswitch/openvswitch_git.bb | |||
@@ -28,6 +28,7 @@ SRC_URI += "git://github.com/openvswitch/ovs.git;protocol=git;branch=branch-2.15 | |||
28 | file://systemd-update-tool-paths.patch \ | 28 | file://systemd-update-tool-paths.patch \ |
29 | file://systemd-create-runtime-dirs.patch \ | 29 | file://systemd-create-runtime-dirs.patch \ |
30 | file://0001-ovs-use-run-instead-of-var-run-for-in-systemd-units.patch \ | 30 | file://0001-ovs-use-run-instead-of-var-run-for-in-systemd-units.patch \ |
31 | file://0001-ofp-actions-Fix-use-after-free-while-decoding-RAW_EN.patch \ | ||
31 | " | 32 | " |
32 | 33 | ||
33 | LIC_FILES_CHKSUM = "file://LICENSE;md5=1ce5d23a6429dff345518758f13aaeab" | 34 | LIC_FILES_CHKSUM = "file://LICENSE;md5=1ce5d23a6429dff345518758f13aaeab" |