Browse code

openvswitch : Fix CVE-2017-14970 in 1.0 branch.

Change-Id: I4fb6e8880b424e84ae2a908ec510c8898e561447
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/4251
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Dheeraj S Shetty <dheerajs@vmware.com>

xiaolin-vmware authored on 2017/11/10 02:33:13
Showing 2 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,174 @@
0
+diff -dupr a/lib/ofp-util.c b/lib/ofp-util.c
1
+--- a/lib/ofp-util.c	2017-02-23 23:26:16.769982618 -0800
2
+@@ -8690,6 +8690,7 @@ ofputil_pull_ofp11_buckets(struct ofpbuf
3
+         if (!ob) {
4
+             VLOG_WARN_RL(&bad_ofmsg_rl, "buckets end with %"PRIuSIZE" leftover bytes",
5
+                          buckets_length);
6
++            ofputil_bucket_list_destroy(buckets);
7
+             return OFPERR_OFPGMFC_BAD_BUCKET;
8
+         }
9
+ 
10
+@@ -8697,11 +8698,13 @@ ofputil_pull_ofp11_buckets(struct ofpbuf
11
+         if (ob_len < sizeof *ob) {
12
+             VLOG_WARN_RL(&bad_ofmsg_rl, "OpenFlow message bucket length "
13
+                          "%"PRIuSIZE" is not valid", ob_len);
14
++            ofputil_bucket_list_destroy(buckets);
15
+             return OFPERR_OFPGMFC_BAD_BUCKET;
16
+         } else if (ob_len > buckets_length) {
17
+             VLOG_WARN_RL(&bad_ofmsg_rl, "OpenFlow message bucket length "
18
+                          "%"PRIuSIZE" exceeds remaining buckets data size %"PRIuSIZE,
19
+                          ob_len, buckets_length);
20
++            ofputil_bucket_list_destroy(buckets);
21
+             return OFPERR_OFPGMFC_BAD_BUCKET;
22
+         }
23
+         buckets_length -= ob_len;
24
+@@ -9093,8 +9096,13 @@ ofputil_decode_ofp15_group_desc_reply(st
25
+      * Such properties are valid for group desc replies so
26
+      * claim that the group mod command is OFPGC15_ADD to
27
+      * satisfy the check in parse_group_prop_ntr_selection_method() */
28
+-    return parse_ofp15_group_properties(msg, gd->type, OFPGC15_ADD, &gd->props,
29
+-                                        length - sizeof *ogds - bucket_list_len);
30
++    error = parse_ofp15_group_properties(
31
++        msg, gd->type, OFPGC15_ADD, &gd->props,
32
++        length - sizeof *ogds - bucket_list_len);
33
++    if (error) {
34
++        ofputil_bucket_list_destroy(&gd->buckets);
35
++    }
36
++    return error;
37
+ }
38
+ 
39
+ /* Converts a group description reply in 'msg' into an abstract
40
+@@ -9331,6 +9339,7 @@ ofputil_pull_ofp11_group_mod(struct ofpb
41
+         && gm->command == OFPGC11_DELETE
42
+         && !ovs_list_is_empty(&gm->buckets)) {
43
+         error = OFPERR_OFPGMFC_INVALID_GROUP;
44
++        ofputil_bucket_list_destroy(&gm->buckets);
45
+     }
46
+ 
47
+     return error;
48
+@@ -9388,45 +9397,17 @@ ofputil_pull_ofp15_group_mod(struct ofpb
49
+         return error;
50
+     }
51
+ 
52
+-    return parse_ofp15_group_properties(msg, gm->type, gm->command, &gm->props,
53
+-                                        msg->size);
54
++    error = parse_ofp15_group_properties(msg, gm->type, gm->command,
55
++                                         &gm->props, msg->size);
56
++    if (error) {
57
++        ofputil_bucket_list_destroy(&gm->buckets);
58
++    }
59
++    return error;
60
+ }
61
+ 
62
+-/* Converts OpenFlow group mod message 'oh' into an abstract group mod in
63
+- * 'gm'.  Returns 0 if successful, otherwise an OpenFlow error code. */
64
+-enum ofperr
65
+-ofputil_decode_group_mod(const struct ofp_header *oh,
66
+-                         struct ofputil_group_mod *gm)
67
++static enum ofperr
68
++ofputil_check_group_mod(const struct ofputil_group_mod *gm)
69
+ {
70
+-    ofputil_init_group_properties(&gm->props);
71
+-
72
+-    enum ofp_version ofp_version = oh->version;
73
+-    struct ofpbuf msg = ofpbuf_const_initializer(oh, ntohs(oh->length));
74
+-    ofpraw_pull_assert(&msg);
75
+-
76
+-    enum ofperr err;
77
+-    switch (ofp_version)
78
+-    {
79
+-    case OFP11_VERSION:
80
+-    case OFP12_VERSION:
81
+-    case OFP13_VERSION:
82
+-    case OFP14_VERSION:
83
+-        err = ofputil_pull_ofp11_group_mod(&msg, ofp_version, gm);
84
+-        break;
85
+-
86
+-    case OFP15_VERSION:
87
+-    case OFP16_VERSION:
88
+-        err = ofputil_pull_ofp15_group_mod(&msg, ofp_version, gm);
89
+-        break;
90
+-
91
+-    case OFP10_VERSION:
92
+-    default:
93
+-        OVS_NOT_REACHED();
94
+-    }
95
+-    if (err) {
96
+-        return err;
97
+-    }
98
+-
99
+     switch (gm->type) {
100
+     case OFPGT11_INDIRECT:
101
+         if (gm->command != OFPGC11_DELETE
102
+@@ -9473,6 +9473,48 @@ ofputil_check_group_mod(const struct ofputil_group_mod *gm)
103
+     return 0;
104
+ }
105
+ 
106
++/* Converts OpenFlow group mod message 'oh' into an abstract group mod in
107
++ * 'gm'.  Returns 0 if successful, otherwise an OpenFlow error code. */
108
++enum ofperr
109
++ofputil_decode_group_mod(const struct ofp_header *oh,
110
++                         struct ofputil_group_mod *gm)
111
++{
112
++    ofputil_init_group_properties(&gm->props);
113
++
114
++    enum ofp_version ofp_version = oh->version;
115
++    struct ofpbuf msg = ofpbuf_const_initializer(oh, ntohs(oh->length));
116
++    ofpraw_pull_assert(&msg);
117
++
118
++    enum ofperr err;
119
++    switch (ofp_version)
120
++    {
121
++    case OFP11_VERSION:
122
++    case OFP12_VERSION:
123
++    case OFP13_VERSION:
124
++    case OFP14_VERSION:
125
++        err = ofputil_pull_ofp11_group_mod(&msg, ofp_version, gm);
126
++        break;
127
++
128
++    case OFP15_VERSION:
129
++    case OFP16_VERSION:
130
++        err = ofputil_pull_ofp15_group_mod(&msg, ofp_version, gm);
131
++        break;
132
++
133
++    case OFP10_VERSION:
134
++    default:
135
++        OVS_NOT_REACHED();
136
++    }
137
++    if (err) {
138
++        return err;
139
++    }
140
++
141
++    err = ofputil_check_group_mod(gm);
142
++    if (err) {
143
++        ofputil_uninit_group_mod(gm);
144
++    }
145
++    return err;
146
++}
147
++
148
+ /* Destroys 'bms'. */
149
+ void
150
+ ofputil_encode_bundle_msgs(struct ofputil_bundle_msg *bms, size_t n_bms,
151
+@@ -10020,14 +10043,21 @@ ofputil_decode_bundle_add(const struct o
152
+                           enum ofptype *typep)
153
+ {
154
+     struct ofpbuf b = ofpbuf_const_initializer(oh, ntohs(oh->length));
155
++
156
++    /* Pull the outer ofp_header. */
157
+     enum ofpraw raw = ofpraw_pull_assert(&b);
158
+     ovs_assert(raw == OFPRAW_OFPT14_BUNDLE_ADD_MESSAGE
159
+                || raw == OFPRAW_ONFT13_BUNDLE_ADD_MESSAGE);
160
+ 
161
++    /* Pull the bundle_ctrl header. */
162
+     const struct ofp14_bundle_ctrl_msg *m = ofpbuf_pull(&b, sizeof *m);
163
+     msg->bundle_id = ntohl(m->bundle_id);
164
+     msg->flags = ntohs(m->flags);
165
+ 
166
++    /* Pull the inner ofp_header. */
167
++    if (b.size < sizeof(struct ofp_header)) {
168
++        return OFPERR_OFPBFC_MSG_BAD_LEN;
169
++    }
170
+     msg->msg = b.data;
171
+     if (msg->msg->version != oh->version) {
172
+         return OFPERR_OFPBFC_BAD_VERSION;
... ...
@@ -1,7 +1,7 @@
1 1
 Summary:        Open vSwitch daemon/database/utilities
2 2
 Name:           openvswitch
3 3
 Version:        2.6.1
4
-Release:        4%{?dist}
4
+Release:        5%{?dist}
5 5
 License:        ASL 2.0 and LGPLv2+
6 6
 URL:            http://www.openvswitch.org/
7 7
 Group:          System Environment/Daemons
... ...
@@ -11,7 +11,8 @@ Distribution:   Photon
11 11
 Source0:        http://openvswitch.org/releases/%{name}-%{version}.tar.gz
12 12
 Patch0:         ovs-CVE-2017-9264.patch
13 13
 Patch1:         OVS-CVE-2017-9263.patch
14
-%define sha1 openvswitch=2865fe03b3906b5aea984102c4b65772b5dd7450
14
+Patch2:         OVS-CVE-2017-14970.patch
15
+%define sha1    openvswitch=2865fe03b3906b5aea984102c4b65772b5dd7450
15 16
 
16 17
 BuildRequires:  gcc >= 4.0.0
17 18
 BuildRequires:  libcap-ng
... ...
@@ -44,9 +45,9 @@ Open vSwitch provides standard network bridging functions and
44 44
 support for the OpenFlow protocol for remote per-flow control of
45 45
 traffic.
46 46
 
47
-%package	devel
48
-Summary:	Header and development files for openvswitch
49
-Requires:	%{name} = %{version}
47
+%package        devel
48
+Summary:        Header and development files for openvswitch
49
+Requires:       %{name} = %{version}
50 50
 %description    devel
51 51
 openvswitch-devel package contains header files and libs.
52 52
 
... ...
@@ -60,6 +61,7 @@ It contains the documentation and manpages for openvswitch.
60 60
 %setup -q
61 61
 %patch0 -p1
62 62
 %patch1 -p0
63
+%patch2 -p1
63 64
 
64 65
 %build
65 66
 ./configure \
... ...
@@ -141,19 +143,21 @@ make -k check |& tee %{_specdir}/%{name}-check-log || %{nocheck}
141 141
 /usr/share/man/man8/vtep-ctl.8.gz
142 142
 
143 143
 %changelog
144
-*	Wed Oct 18 2017 Dheeraj Shetty <dheerajs@vmware.com> 2.6.1-4
145
--	Fix CVE-2017-9263
146
-*	Mon Jun 12 2017 Vinay Kulkarni <kulkarniv@vmware.com> 2.6.1-3
147
--	Fix CVE-2017-9264
148
-*	Fri Feb 10 2017 Vinay Kulkarni <kulkarniv@vmware.com> 2.6.1-2
149
--	Build ovs shared library
150
-*	Wed Nov 16 2016 Vinay Kulkarni <kulkarniv@vmware.com> 2.6.1-1
151
--	Update to openvswitch 2.6.1
152
-*	Tue May 24 2016 Priyesh Padmavilasom <ppadmavilasom@vmware.com> 2.4.0-3
153
--	GA - Bump release of all rpms
154
-*       Sat Oct 31 2015 Vinay Kulkarni <kulkarniv@vmware.com> 2.4.0-2
155
--       OVS requires libatomic.so.1 provided by gcc.
156
-*       Mon Oct 12 2015 Vinay Kulkarni <kulkarniv@vmware.com> 2.4.0-1
157
--       Update to OVS v2.4.0
158
-*       Fri May 29 2015 Kumar Kaushik <kaushikk@vmware.com> 2.3.1-1
159
--       Initial build. First version
144
+*   Thu Nov 09 2017 Xiaolin Li <xiaolinl@vmware.com> 2.6.1-5
145
+-   Fix CVE-2017-14970
146
+*   Wed Oct 18 2017 Dheeraj Shetty <dheerajs@vmware.com> 2.6.1-4
147
+-   Fix CVE-2017-9263
148
+*   Mon Jun 12 2017 Vinay Kulkarni <kulkarniv@vmware.com> 2.6.1-3
149
+-   Fix CVE-2017-9264
150
+*   Fri Feb 10 2017 Vinay Kulkarni <kulkarniv@vmware.com> 2.6.1-2
151
+-   Build ovs shared library
152
+*   Wed Nov 16 2016 Vinay Kulkarni <kulkarniv@vmware.com> 2.6.1-1
153
+-   Update to openvswitch 2.6.1
154
+*   Tue May 24 2016 Priyesh Padmavilasom <ppadmavilasom@vmware.com> 2.4.0-3
155
+-   GA - Bump release of all rpms
156
+*   Sat Oct 31 2015 Vinay Kulkarni <kulkarniv@vmware.com> 2.4.0-2
157
+-   OVS requires libatomic.so.1 provided by gcc.
158
+*   Mon Oct 12 2015 Vinay Kulkarni <kulkarniv@vmware.com> 2.4.0-1
159
+-   Update to OVS v2.4.0
160
+*   Fri May 29 2015 Kumar Kaushik <kaushikk@vmware.com> 2.3.1-1
161
+-   Initial build. First version