-
Notifications
You must be signed in to change notification settings - Fork 16
/
0004-Fix-too-large-stack-frame-size.patch
264 lines (239 loc) · 7.89 KB
/
0004-Fix-too-large-stack-frame-size.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
From d0b6a5234f80301305123a7fbf09cdc2254bc09c Mon Sep 17 00:00:00 2001
From: Yi Yang <[email protected]>
Date: Wed, 13 Apr 2016 18:17:21 +0800
Subject: [PATCH 4/8] Fix too large stack frame size
Signed-off-by: Yi Yang <[email protected]>
---
datapath/datapath.c | 92 +++++++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 78 insertions(+), 14 deletions(-)
diff --git a/datapath/datapath.c b/datapath/datapath.c
index 5bec072..4baf242 100644
--- a/datapath/datapath.c
+++ b/datapath/datapath.c
@@ -928,7 +928,7 @@ static int ovs_flow_cmd_new(struct sk_buff *skb, struct genl_info *info)
struct sw_flow_mask mask;
struct sk_buff *reply;
struct datapath *dp;
- struct sw_flow_key key;
+ struct sw_flow_key *key = NULL;
struct sw_flow_actions *acts;
struct sw_flow_match match;
u32 ufid_flags = ovs_nla_get_ufid_flags(a[OVS_FLOW_ATTR_UFID_FLAGS]);
@@ -946,6 +946,12 @@ static int ovs_flow_cmd_new(struct sk_buff *skb, struct genl_info *info)
goto error;
}
+ error = -ENOMEM;
+ key = kzalloc(sizeof(struct sw_flow_key), GFP_KERNEL);
+ if (key == NULL) {
+ goto error;
+ }
+
/* Most of the time we need to allocate a new flow, do it before
* locking.
*/
@@ -956,17 +962,17 @@ static int ovs_flow_cmd_new(struct sk_buff *skb, struct genl_info *info)
}
/* Extract key. */
- ovs_match_init(&match, &key, &mask);
+ ovs_match_init(&match, key, &mask);
error = ovs_nla_get_match(net, &match, a[OVS_FLOW_ATTR_KEY],
a[OVS_FLOW_ATTR_MASK], log);
if (error)
goto err_kfree_flow;
- ovs_flow_mask_key(&new_flow->key, &key, true, &mask);
+ ovs_flow_mask_key(&new_flow->key, key, true, &mask);
/* Extract flow identifier. */
error = ovs_nla_get_identifier(&new_flow->id, a[OVS_FLOW_ATTR_UFID],
- &key, log);
+ key, log);
if (error)
goto err_kfree_flow;
@@ -996,7 +1002,7 @@ static int ovs_flow_cmd_new(struct sk_buff *skb, struct genl_info *info)
if (ovs_identifier_is_ufid(&new_flow->id))
flow = ovs_flow_tbl_lookup_ufid(&dp->table, &new_flow->id);
if (!flow)
- flow = ovs_flow_tbl_lookup(&dp->table, &key);
+ flow = ovs_flow_tbl_lookup(&dp->table, key);
if (likely(!flow)) {
rcu_assign_pointer(new_flow->sf_acts, acts);
@@ -1066,6 +1072,10 @@ static int ovs_flow_cmd_new(struct sk_buff *skb, struct genl_info *info)
if (reply)
ovs_notify(&dp_flow_genl_family, &ovs_dp_flow_multicast_group, reply, info);
+ if (key != NULL) {
+ kfree(key);
+ key = NULL;
+ }
return 0;
err_unlock_ovs:
@@ -1076,6 +1086,10 @@ err_kfree_acts:
err_kfree_flow:
ovs_flow_free(new_flow, false);
error:
+ if (key != NULL) {
+ kfree(key);
+ key = NULL;
+ }
return error;
}
@@ -1106,7 +1120,7 @@ static int ovs_flow_cmd_set(struct sk_buff *skb, struct genl_info *info)
struct net *net = sock_net(skb->sk);
struct nlattr **a = info->attrs;
struct ovs_header *ovs_header = info->userhdr;
- struct sw_flow_key key;
+ struct sw_flow_key *key = NULL;
struct sw_flow *flow;
struct sw_flow_mask mask;
struct sk_buff *reply = NULL;
@@ -1119,6 +1133,12 @@ static int ovs_flow_cmd_set(struct sk_buff *skb, struct genl_info *info)
bool log = !a[OVS_FLOW_ATTR_PROBE];
bool ufid_present;
+ error = -ENOMEM;
+ key = kzalloc(sizeof(struct sw_flow_key), GFP_KERNEL);
+ if (key == NULL) {
+ goto error;
+ }
+
/* Extract key. */
error = -EINVAL;
if (!a[OVS_FLOW_ATTR_KEY]) {
@@ -1127,7 +1147,7 @@ static int ovs_flow_cmd_set(struct sk_buff *skb, struct genl_info *info)
}
ufid_present = ovs_nla_get_ufid(&sfid, a[OVS_FLOW_ATTR_UFID], log);
- ovs_match_init(&match, &key, &mask);
+ ovs_match_init(&match, key, &mask);
error = ovs_nla_get_match(net, &match, a[OVS_FLOW_ATTR_KEY],
a[OVS_FLOW_ATTR_MASK], log);
if (error)
@@ -1135,7 +1155,7 @@ static int ovs_flow_cmd_set(struct sk_buff *skb, struct genl_info *info)
/* Validate actions. */
if (a[OVS_FLOW_ATTR_ACTIONS]) {
- acts = get_flow_actions(net, a[OVS_FLOW_ATTR_ACTIONS], &key,
+ acts = get_flow_actions(net, a[OVS_FLOW_ATTR_ACTIONS], key,
&mask, log);
if (IS_ERR(acts)) {
error = PTR_ERR(acts);
@@ -1203,6 +1223,10 @@ static int ovs_flow_cmd_set(struct sk_buff *skb, struct genl_info *info)
if (old_acts)
ovs_nla_free_flow_actions_rcu(old_acts);
+ if (key != NULL) {
+ kfree(key);
+ key = NULL;
+ }
return 0;
err_unlock_ovs:
@@ -1211,6 +1235,10 @@ err_unlock_ovs:
err_kfree_acts:
ovs_nla_free_flow_actions(acts);
error:
+ if (key != NULL) {
+ kfree(key);
+ key = NULL;
+ }
return error;
}
@@ -1219,7 +1247,7 @@ static int ovs_flow_cmd_get(struct sk_buff *skb, struct genl_info *info)
struct nlattr **a = info->attrs;
struct ovs_header *ovs_header = info->userhdr;
struct net *net = sock_net(skb->sk);
- struct sw_flow_key key;
+ struct sw_flow_key *key = NULL;
struct sk_buff *reply;
struct sw_flow *flow;
struct datapath *dp;
@@ -1230,9 +1258,15 @@ static int ovs_flow_cmd_get(struct sk_buff *skb, struct genl_info *info)
bool log = !a[OVS_FLOW_ATTR_PROBE];
bool ufid_present;
+ err = -ENOMEM;
+ key = kzalloc(sizeof(struct sw_flow_key), GFP_KERNEL);
+ if (key == NULL) {
+ return err;
+ }
+
ufid_present = ovs_nla_get_ufid(&ufid, a[OVS_FLOW_ATTR_UFID], log);
if (a[OVS_FLOW_ATTR_KEY]) {
- ovs_match_init(&match, &key, NULL);
+ ovs_match_init(&match, key, NULL);
err = ovs_nla_get_match(net, &match, a[OVS_FLOW_ATTR_KEY], NULL,
log);
} else if (!ufid_present) {
@@ -1240,9 +1274,13 @@ static int ovs_flow_cmd_get(struct sk_buff *skb, struct genl_info *info)
"Flow get message rejected, Key attribute missing.");
err = -EINVAL;
}
- if (err)
+ if (err) {
+ if (key != NULL) {
+ kfree(key);
+ key = NULL;
+ }
return err;
-
+ }
ovs_lock();
dp = get_dp(sock_net(skb->sk), ovs_header->dp_ifindex);
if (!dp) {
@@ -1267,9 +1305,17 @@ static int ovs_flow_cmd_get(struct sk_buff *skb, struct genl_info *info)
}
ovs_unlock();
+ if (key != NULL) {
+ kfree(key);
+ key = NULL;
+ }
return genlmsg_reply(reply, info);
unlock:
ovs_unlock();
+ if (key != NULL) {
+ kfree(key);
+ key = NULL;
+ }
return err;
}
@@ -1278,7 +1324,7 @@ static int ovs_flow_cmd_del(struct sk_buff *skb, struct genl_info *info)
struct nlattr **a = info->attrs;
struct ovs_header *ovs_header = info->userhdr;
struct net *net = sock_net(skb->sk);
- struct sw_flow_key key;
+ struct sw_flow_key *key = NULL;
struct sk_buff *reply;
struct sw_flow *flow = NULL;
struct datapath *dp;
@@ -1289,12 +1335,22 @@ static int ovs_flow_cmd_del(struct sk_buff *skb, struct genl_info *info)
bool log = !a[OVS_FLOW_ATTR_PROBE];
bool ufid_present;
+ err = -ENOMEM;
+ key = kzalloc(sizeof(struct sw_flow_key), GFP_KERNEL);
+ if (key == NULL) {
+ return err;
+ }
+
ufid_present = ovs_nla_get_ufid(&ufid, a[OVS_FLOW_ATTR_UFID], log);
if (a[OVS_FLOW_ATTR_KEY]) {
- ovs_match_init(&match, &key, NULL);
+ ovs_match_init(&match, key, NULL);
err = ovs_nla_get_match(net, &match, a[OVS_FLOW_ATTR_KEY],
NULL, log);
if (unlikely(err))
+ if (key != NULL) {
+ kfree(key);
+ key = NULL;
+ }
return err;
}
@@ -1344,9 +1400,17 @@ static int ovs_flow_cmd_del(struct sk_buff *skb, struct genl_info *info)
}
ovs_flow_free(flow, true);
+ if (key != NULL) {
+ kfree(key);
+ key = NULL;
+ }
return 0;
unlock:
ovs_unlock();
+ if (key != NULL) {
+ kfree(key);
+ key = NULL;
+ }
return err;
}
--
2.1.0