summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/bridge/netfilter/ebt_among.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/net/bridge/netfilter/ebt_among.c b/net/bridge/netfilter/ebt_among.c
index ce7152a12bd8..c5afb4232ecb 100644
--- a/net/bridge/netfilter/ebt_among.c
+++ b/net/bridge/netfilter/ebt_among.c
@@ -172,18 +172,35 @@ ebt_among_mt(const struct sk_buff *skb, struct xt_action_param *par)
172 return true; 172 return true;
173} 173}
174 174
175static bool poolsize_invalid(const struct ebt_mac_wormhash *w)
176{
177 return w && w->poolsize >= (INT_MAX / sizeof(struct ebt_mac_wormhash_tuple));
178}
179
175static int ebt_among_mt_check(const struct xt_mtchk_param *par) 180static int ebt_among_mt_check(const struct xt_mtchk_param *par)
176{ 181{
177 const struct ebt_among_info *info = par->matchinfo; 182 const struct ebt_among_info *info = par->matchinfo;
178 const struct ebt_entry_match *em = 183 const struct ebt_entry_match *em =
179 container_of(par->matchinfo, const struct ebt_entry_match, data); 184 container_of(par->matchinfo, const struct ebt_entry_match, data);
180 int expected_length = sizeof(struct ebt_among_info); 185 unsigned int expected_length = sizeof(struct ebt_among_info);
181 const struct ebt_mac_wormhash *wh_dst, *wh_src; 186 const struct ebt_mac_wormhash *wh_dst, *wh_src;
182 int err; 187 int err;
183 188
189 if (expected_length > em->match_size)
190 return -EINVAL;
191
184 wh_dst = ebt_among_wh_dst(info); 192 wh_dst = ebt_among_wh_dst(info);
185 wh_src = ebt_among_wh_src(info); 193 if (poolsize_invalid(wh_dst))
194 return -EINVAL;
195
186 expected_length += ebt_mac_wormhash_size(wh_dst); 196 expected_length += ebt_mac_wormhash_size(wh_dst);
197 if (expected_length > em->match_size)
198 return -EINVAL;
199
200 wh_src = ebt_among_wh_src(info);
201 if (poolsize_invalid(wh_src))
202 return -EINVAL;
203
187 expected_length += ebt_mac_wormhash_size(wh_src); 204 expected_length += ebt_mac_wormhash_size(wh_src);
188 205
189 if (em->match_size != EBT_ALIGN(expected_length)) { 206 if (em->match_size != EBT_ALIGN(expected_length)) {