summaryrefslogtreecommitdiffstats
path: root/net/bridge
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2018-03-06 00:53:44 -0500
committerDavid S. Miller <davem@davemloft.net>2018-03-06 01:20:46 -0500
commit0f3e9c97eb5a97972b0c0076a5cc01bb142f8e70 (patch)
tree439c89ea3c87496c23e167148f2cdbefb6e82b30 /net/bridge
parentef3f6c256f0b4711a3ef1489797b95820be5ab01 (diff)
parentce380619fab99036f5e745c7a865b21c59f005f6 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
All of the conflicts were cases of overlapping changes. In net/core/devlink.c, we have to make care that the resouce size_params have become a struct member rather than a pointer to such an object. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/bridge')
-rw-r--r--net/bridge/br_netfilter_hooks.c4
-rw-r--r--net/bridge/br_vlan.c2
-rw-r--r--net/bridge/netfilter/ebt_among.c21
-rw-r--r--net/bridge/netfilter/ebtables.c40
4 files changed, 54 insertions, 13 deletions
diff --git a/net/bridge/br_netfilter_hooks.c b/net/bridge/br_netfilter_hooks.c
index 484f54150525..c2120eb889a9 100644
--- a/net/bridge/br_netfilter_hooks.c
+++ b/net/bridge/br_netfilter_hooks.c
@@ -214,7 +214,7 @@ static int br_validate_ipv4(struct net *net, struct sk_buff *skb)
214 214
215 iph = ip_hdr(skb); 215 iph = ip_hdr(skb);
216 if (unlikely(ip_fast_csum((u8 *)iph, iph->ihl))) 216 if (unlikely(ip_fast_csum((u8 *)iph, iph->ihl)))
217 goto inhdr_error; 217 goto csum_error;
218 218
219 len = ntohs(iph->tot_len); 219 len = ntohs(iph->tot_len);
220 if (skb->len < len) { 220 if (skb->len < len) {
@@ -236,6 +236,8 @@ static int br_validate_ipv4(struct net *net, struct sk_buff *skb)
236 */ 236 */
237 return 0; 237 return 0;
238 238
239csum_error:
240 __IP_INC_STATS(net, IPSTATS_MIB_CSUMERRORS);
239inhdr_error: 241inhdr_error:
240 __IP_INC_STATS(net, IPSTATS_MIB_INHDRERRORS); 242 __IP_INC_STATS(net, IPSTATS_MIB_INHDRERRORS);
241drop: 243drop:
diff --git a/net/bridge/br_vlan.c b/net/bridge/br_vlan.c
index 51935270c651..9896f4975353 100644
--- a/net/bridge/br_vlan.c
+++ b/net/bridge/br_vlan.c
@@ -168,6 +168,8 @@ static struct net_bridge_vlan *br_vlan_get_master(struct net_bridge *br, u16 vid
168 masterv = br_vlan_find(vg, vid); 168 masterv = br_vlan_find(vg, vid);
169 if (WARN_ON(!masterv)) 169 if (WARN_ON(!masterv))
170 return NULL; 170 return NULL;
171 refcount_set(&masterv->refcnt, 1);
172 return masterv;
171 } 173 }
172 refcount_inc(&masterv->refcnt); 174 refcount_inc(&masterv->refcnt);
173 175
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)) {
diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
index 02c4b409d317..254ef9f49567 100644
--- a/net/bridge/netfilter/ebtables.c
+++ b/net/bridge/netfilter/ebtables.c
@@ -1641,7 +1641,8 @@ static int compat_match_to_user(struct ebt_entry_match *m, void __user **dstptr,
1641 int off = ebt_compat_match_offset(match, m->match_size); 1641 int off = ebt_compat_match_offset(match, m->match_size);
1642 compat_uint_t msize = m->match_size - off; 1642 compat_uint_t msize = m->match_size - off;
1643 1643
1644 BUG_ON(off >= m->match_size); 1644 if (WARN_ON(off >= m->match_size))
1645 return -EINVAL;
1645 1646
1646 if (copy_to_user(cm->u.name, match->name, 1647 if (copy_to_user(cm->u.name, match->name,
1647 strlen(match->name) + 1) || put_user(msize, &cm->match_size)) 1648 strlen(match->name) + 1) || put_user(msize, &cm->match_size))
@@ -1671,7 +1672,8 @@ static int compat_target_to_user(struct ebt_entry_target *t,
1671 int off = xt_compat_target_offset(target); 1672 int off = xt_compat_target_offset(target);
1672 compat_uint_t tsize = t->target_size - off; 1673 compat_uint_t tsize = t->target_size - off;
1673 1674
1674 BUG_ON(off >= t->target_size); 1675 if (WARN_ON(off >= t->target_size))
1676 return -EINVAL;
1675 1677
1676 if (copy_to_user(cm->u.name, target->name, 1678 if (copy_to_user(cm->u.name, target->name,
1677 strlen(target->name) + 1) || put_user(tsize, &cm->match_size)) 1679 strlen(target->name) + 1) || put_user(tsize, &cm->match_size))
@@ -1902,7 +1904,8 @@ static int ebt_buf_add(struct ebt_entries_buf_state *state,
1902 if (state->buf_kern_start == NULL) 1904 if (state->buf_kern_start == NULL)
1903 goto count_only; 1905 goto count_only;
1904 1906
1905 BUG_ON(state->buf_kern_offset + sz > state->buf_kern_len); 1907 if (WARN_ON(state->buf_kern_offset + sz > state->buf_kern_len))
1908 return -EINVAL;
1906 1909
1907 memcpy(state->buf_kern_start + state->buf_kern_offset, data, sz); 1910 memcpy(state->buf_kern_start + state->buf_kern_offset, data, sz);
1908 1911
@@ -1915,7 +1918,8 @@ static int ebt_buf_add_pad(struct ebt_entries_buf_state *state, unsigned int sz)
1915{ 1918{
1916 char *b = state->buf_kern_start; 1919 char *b = state->buf_kern_start;
1917 1920
1918 BUG_ON(b && state->buf_kern_offset > state->buf_kern_len); 1921 if (WARN_ON(b && state->buf_kern_offset > state->buf_kern_len))
1922 return -EINVAL;
1919 1923
1920 if (b != NULL && sz > 0) 1924 if (b != NULL && sz > 0)
1921 memset(b + state->buf_kern_offset, 0, sz); 1925 memset(b + state->buf_kern_offset, 0, sz);
@@ -1992,8 +1996,10 @@ static int compat_mtw_from_user(struct compat_ebt_entry_mwt *mwt,
1992 pad = XT_ALIGN(size_kern) - size_kern; 1996 pad = XT_ALIGN(size_kern) - size_kern;
1993 1997
1994 if (pad > 0 && dst) { 1998 if (pad > 0 && dst) {
1995 BUG_ON(state->buf_kern_len <= pad); 1999 if (WARN_ON(state->buf_kern_len <= pad))
1996 BUG_ON(state->buf_kern_offset - (match_size + off) + size_kern > state->buf_kern_len - pad); 2000 return -EINVAL;
2001 if (WARN_ON(state->buf_kern_offset - (match_size + off) + size_kern > state->buf_kern_len - pad))
2002 return -EINVAL;
1997 memset(dst + size_kern, 0, pad); 2003 memset(dst + size_kern, 0, pad);
1998 } 2004 }
1999 return off + match_size; 2005 return off + match_size;
@@ -2043,7 +2049,8 @@ static int ebt_size_mwt(struct compat_ebt_entry_mwt *match32,
2043 if (ret < 0) 2049 if (ret < 0)
2044 return ret; 2050 return ret;
2045 2051
2046 BUG_ON(ret < match32->match_size); 2052 if (WARN_ON(ret < match32->match_size))
2053 return -EINVAL;
2047 growth += ret - match32->match_size; 2054 growth += ret - match32->match_size;
2048 growth += ebt_compat_entry_padsize(); 2055 growth += ebt_compat_entry_padsize();
2049 2056
@@ -2053,7 +2060,9 @@ static int ebt_size_mwt(struct compat_ebt_entry_mwt *match32,
2053 if (match_kern) 2060 if (match_kern)
2054 match_kern->match_size = ret; 2061 match_kern->match_size = ret;
2055 2062
2056 WARN_ON(type == EBT_COMPAT_TARGET && size_left); 2063 if (WARN_ON(type == EBT_COMPAT_TARGET && size_left))
2064 return -EINVAL;
2065
2057 match32 = (struct compat_ebt_entry_mwt *) buf; 2066 match32 = (struct compat_ebt_entry_mwt *) buf;
2058 } 2067 }
2059 2068
@@ -2109,6 +2118,15 @@ static int size_entry_mwt(struct ebt_entry *entry, const unsigned char *base,
2109 * 2118 *
2110 * offsets are relative to beginning of struct ebt_entry (i.e., 0). 2119 * offsets are relative to beginning of struct ebt_entry (i.e., 0).
2111 */ 2120 */
2121 for (i = 0; i < 4 ; ++i) {
2122 if (offsets[i] >= *total)
2123 return -EINVAL;
2124 if (i == 0)
2125 continue;
2126 if (offsets[i-1] > offsets[i])
2127 return -EINVAL;
2128 }
2129
2112 for (i = 0, j = 1 ; j < 4 ; j++, i++) { 2130 for (i = 0, j = 1 ; j < 4 ; j++, i++) {
2113 struct compat_ebt_entry_mwt *match32; 2131 struct compat_ebt_entry_mwt *match32;
2114 unsigned int size; 2132 unsigned int size;
@@ -2140,7 +2158,8 @@ static int size_entry_mwt(struct ebt_entry *entry, const unsigned char *base,
2140 2158
2141 startoff = state->buf_user_offset - startoff; 2159 startoff = state->buf_user_offset - startoff;
2142 2160
2143 BUG_ON(*total < startoff); 2161 if (WARN_ON(*total < startoff))
2162 return -EINVAL;
2144 *total -= startoff; 2163 *total -= startoff;
2145 return 0; 2164 return 0;
2146} 2165}
@@ -2267,7 +2286,8 @@ static int compat_do_replace(struct net *net, void __user *user,
2267 state.buf_kern_len = size64; 2286 state.buf_kern_len = size64;
2268 2287
2269 ret = compat_copy_entries(entries_tmp, tmp.entries_size, &state); 2288 ret = compat_copy_entries(entries_tmp, tmp.entries_size, &state);
2270 BUG_ON(ret < 0); /* parses same data again */ 2289 if (WARN_ON(ret < 0))
2290 goto out_unlock;
2271 2291
2272 vfree(entries_tmp); 2292 vfree(entries_tmp);
2273 tmp.entries_size = size64; 2293 tmp.entries_size = size64;