aboutsummaryrefslogtreecommitdiffstats
path: root/net/bridge
diff options
context:
space:
mode:
Diffstat (limited to 'net/bridge')
-rw-r--r--net/bridge/netfilter/ebt_ip6.c4
-rw-r--r--net/bridge/netfilter/ebt_log.c9
-rw-r--r--net/bridge/netfilter/ebt_stp.c2
-rw-r--r--net/bridge/netfilter/ebt_vlan.c15
-rw-r--r--net/bridge/netfilter/ebtable_filter.c2
-rw-r--r--net/bridge/netfilter/ebtable_nat.c2
-rw-r--r--net/bridge/netfilter/ebtables.c139
-rw-r--r--net/bridge/netfilter/nft_meta_bridge.c1
8 files changed, 91 insertions, 83 deletions
diff --git a/net/bridge/netfilter/ebt_ip6.c b/net/bridge/netfilter/ebt_ip6.c
index 17fd5f2cb4b8..98de6e7fd86d 100644
--- a/net/bridge/netfilter/ebt_ip6.c
+++ b/net/bridge/netfilter/ebt_ip6.c
@@ -65,8 +65,8 @@ ebt_ip6_mt(const struct sk_buff *skb, struct xt_action_param *par)
65 return false; 65 return false;
66 if (FWINV(info->protocol != nexthdr, EBT_IP6_PROTO)) 66 if (FWINV(info->protocol != nexthdr, EBT_IP6_PROTO))
67 return false; 67 return false;
68 if (!(info->bitmask & ( EBT_IP6_DPORT | 68 if (!(info->bitmask & (EBT_IP6_DPORT |
69 EBT_IP6_SPORT | EBT_IP6_ICMP6))) 69 EBT_IP6_SPORT | EBT_IP6_ICMP6)))
70 return true; 70 return true;
71 71
72 /* min icmpv6 headersize is 4, so sizeof(_pkthdr) is ok. */ 72 /* min icmpv6 headersize is 4, so sizeof(_pkthdr) is ok. */
diff --git a/net/bridge/netfilter/ebt_log.c b/net/bridge/netfilter/ebt_log.c
index 0ad639a96142..152300d164ac 100644
--- a/net/bridge/netfilter/ebt_log.c
+++ b/net/bridge/netfilter/ebt_log.c
@@ -36,14 +36,12 @@ static int ebt_log_tg_check(const struct xt_tgchk_param *par)
36 return 0; 36 return 0;
37} 37}
38 38
39struct tcpudphdr 39struct tcpudphdr {
40{
41 __be16 src; 40 __be16 src;
42 __be16 dst; 41 __be16 dst;
43}; 42};
44 43
45struct arppayload 44struct arppayload {
46{
47 unsigned char mac_src[ETH_ALEN]; 45 unsigned char mac_src[ETH_ALEN];
48 unsigned char ip_src[4]; 46 unsigned char ip_src[4];
49 unsigned char mac_dst[ETH_ALEN]; 47 unsigned char mac_dst[ETH_ALEN];
@@ -152,7 +150,8 @@ ebt_log_packet(struct net *net, u_int8_t pf, unsigned int hooknum,
152 ntohs(ah->ar_op)); 150 ntohs(ah->ar_op));
153 151
154 /* If it's for Ethernet and the lengths are OK, 152 /* If it's for Ethernet and the lengths are OK,
155 * then log the ARP payload */ 153 * then log the ARP payload
154 */
156 if (ah->ar_hrd == htons(1) && 155 if (ah->ar_hrd == htons(1) &&
157 ah->ar_hln == ETH_ALEN && 156 ah->ar_hln == ETH_ALEN &&
158 ah->ar_pln == sizeof(__be32)) { 157 ah->ar_pln == sizeof(__be32)) {
diff --git a/net/bridge/netfilter/ebt_stp.c b/net/bridge/netfilter/ebt_stp.c
index 0c40570069ba..6b731e12ecfa 100644
--- a/net/bridge/netfilter/ebt_stp.c
+++ b/net/bridge/netfilter/ebt_stp.c
@@ -41,7 +41,7 @@ struct stp_config_pdu {
41#define NR32(p) ((p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]) 41#define NR32(p) ((p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3])
42 42
43static bool ebt_filter_config(const struct ebt_stp_info *info, 43static bool ebt_filter_config(const struct ebt_stp_info *info,
44 const struct stp_config_pdu *stpc) 44 const struct stp_config_pdu *stpc)
45{ 45{
46 const struct ebt_stp_config_info *c; 46 const struct ebt_stp_config_info *c;
47 uint16_t v16; 47 uint16_t v16;
diff --git a/net/bridge/netfilter/ebt_vlan.c b/net/bridge/netfilter/ebt_vlan.c
index 618568888128..98c221dbf059 100644
--- a/net/bridge/netfilter/ebt_vlan.c
+++ b/net/bridge/netfilter/ebt_vlan.c
@@ -66,7 +66,8 @@ ebt_vlan_mt(const struct sk_buff *skb, struct xt_action_param *par)
66 * - Canonical Format Indicator (CFI). The Canonical Format Indicator 66 * - Canonical Format Indicator (CFI). The Canonical Format Indicator
67 * (CFI) is a single bit flag value. Currently ignored. 67 * (CFI) is a single bit flag value. Currently ignored.
68 * - VLAN Identifier (VID). The VID is encoded as 68 * - VLAN Identifier (VID). The VID is encoded as
69 * an unsigned binary number. */ 69 * an unsigned binary number.
70 */
70 id = TCI & VLAN_VID_MASK; 71 id = TCI & VLAN_VID_MASK;
71 prio = (TCI >> 13) & 0x7; 72 prio = (TCI >> 13) & 0x7;
72 73
@@ -98,7 +99,8 @@ static int ebt_vlan_mt_check(const struct xt_mtchk_param *par)
98 } 99 }
99 100
100 /* Check for bitmask range 101 /* Check for bitmask range
101 * True if even one bit is out of mask */ 102 * True if even one bit is out of mask
103 */
102 if (info->bitmask & ~EBT_VLAN_MASK) { 104 if (info->bitmask & ~EBT_VLAN_MASK) {
103 pr_debug("bitmask %2X is out of mask (%2X)\n", 105 pr_debug("bitmask %2X is out of mask (%2X)\n",
104 info->bitmask, EBT_VLAN_MASK); 106 info->bitmask, EBT_VLAN_MASK);
@@ -117,7 +119,8 @@ static int ebt_vlan_mt_check(const struct xt_mtchk_param *par)
117 * 0 - The null VLAN ID. 119 * 0 - The null VLAN ID.
118 * 1 - The default Port VID (PVID) 120 * 1 - The default Port VID (PVID)
119 * 0x0FFF - Reserved for implementation use. 121 * 0x0FFF - Reserved for implementation use.
120 * if_vlan.h: VLAN_N_VID 4096. */ 122 * if_vlan.h: VLAN_N_VID 4096.
123 */
121 if (GET_BITMASK(EBT_VLAN_ID)) { 124 if (GET_BITMASK(EBT_VLAN_ID)) {
122 if (!!info->id) { /* if id!=0 => check vid range */ 125 if (!!info->id) { /* if id!=0 => check vid range */
123 if (info->id > VLAN_N_VID) { 126 if (info->id > VLAN_N_VID) {
@@ -128,7 +131,8 @@ static int ebt_vlan_mt_check(const struct xt_mtchk_param *par)
128 /* Note: This is valid VLAN-tagged frame point. 131 /* Note: This is valid VLAN-tagged frame point.
129 * Any value of user_priority are acceptable, 132 * Any value of user_priority are acceptable,
130 * but should be ignored according to 802.1Q Std. 133 * but should be ignored according to 802.1Q Std.
131 * So we just drop the prio flag. */ 134 * So we just drop the prio flag.
135 */
132 info->bitmask &= ~EBT_VLAN_PRIO; 136 info->bitmask &= ~EBT_VLAN_PRIO;
133 } 137 }
134 /* Else, id=0 (null VLAN ID) => user_priority range (any?) */ 138 /* Else, id=0 (null VLAN ID) => user_priority range (any?) */
@@ -143,7 +147,8 @@ static int ebt_vlan_mt_check(const struct xt_mtchk_param *par)
143 } 147 }
144 /* Check for encapsulated proto range - it is possible to be 148 /* Check for encapsulated proto range - it is possible to be
145 * any value for u_short range. 149 * any value for u_short range.
146 * if_ether.h: ETH_ZLEN 60 - Min. octets in frame sans FCS */ 150 * if_ether.h: ETH_ZLEN 60 - Min. octets in frame sans FCS
151 */
147 if (GET_BITMASK(EBT_VLAN_ENCAP)) { 152 if (GET_BITMASK(EBT_VLAN_ENCAP)) {
148 if ((unsigned short) ntohs(info->encap) < ETH_ZLEN) { 153 if ((unsigned short) ntohs(info->encap) < ETH_ZLEN) {
149 pr_debug("encap frame length %d is less than " 154 pr_debug("encap frame length %d is less than "
diff --git a/net/bridge/netfilter/ebtable_filter.c b/net/bridge/netfilter/ebtable_filter.c
index 32eccd101f26..593a1bdc079e 100644
--- a/net/bridge/netfilter/ebtable_filter.c
+++ b/net/bridge/netfilter/ebtable_filter.c
@@ -12,7 +12,7 @@
12#include <linux/module.h> 12#include <linux/module.h>
13 13
14#define FILTER_VALID_HOOKS ((1 << NF_BR_LOCAL_IN) | (1 << NF_BR_FORWARD) | \ 14#define FILTER_VALID_HOOKS ((1 << NF_BR_LOCAL_IN) | (1 << NF_BR_FORWARD) | \
15 (1 << NF_BR_LOCAL_OUT)) 15 (1 << NF_BR_LOCAL_OUT))
16 16
17static struct ebt_entries initial_chains[] = { 17static struct ebt_entries initial_chains[] = {
18 { 18 {
diff --git a/net/bridge/netfilter/ebtable_nat.c b/net/bridge/netfilter/ebtable_nat.c
index ec55358f00c8..eb33919821ee 100644
--- a/net/bridge/netfilter/ebtable_nat.c
+++ b/net/bridge/netfilter/ebtable_nat.c
@@ -12,7 +12,7 @@
12#include <linux/module.h> 12#include <linux/module.h>
13 13
14#define NAT_VALID_HOOKS ((1 << NF_BR_PRE_ROUTING) | (1 << NF_BR_LOCAL_OUT) | \ 14#define NAT_VALID_HOOKS ((1 << NF_BR_PRE_ROUTING) | (1 << NF_BR_LOCAL_OUT) | \
15 (1 << NF_BR_POST_ROUTING)) 15 (1 << NF_BR_POST_ROUTING))
16 16
17static struct ebt_entries initial_chains[] = { 17static struct ebt_entries initial_chains[] = {
18 { 18 {
diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
index f46ca417bf2d..67b2e27999aa 100644
--- a/net/bridge/netfilter/ebtables.c
+++ b/net/bridge/netfilter/ebtables.c
@@ -35,8 +35,7 @@
35 "report to author: "format, ## args) 35 "report to author: "format, ## args)
36/* #define BUGPRINT(format, args...) */ 36/* #define BUGPRINT(format, args...) */
37 37
38/* 38/* Each cpu has its own set of counters, so there is no need for write_lock in
39 * Each cpu has its own set of counters, so there is no need for write_lock in
40 * the softirq 39 * the softirq
41 * For reading or updating the counters, the user context needs to 40 * For reading or updating the counters, the user context needs to
42 * get a write_lock 41 * get a write_lock
@@ -46,7 +45,7 @@
46#define SMP_ALIGN(x) (((x) + SMP_CACHE_BYTES-1) & ~(SMP_CACHE_BYTES-1)) 45#define SMP_ALIGN(x) (((x) + SMP_CACHE_BYTES-1) & ~(SMP_CACHE_BYTES-1))
47#define COUNTER_OFFSET(n) (SMP_ALIGN(n * sizeof(struct ebt_counter))) 46#define COUNTER_OFFSET(n) (SMP_ALIGN(n * sizeof(struct ebt_counter)))
48#define COUNTER_BASE(c, n, cpu) ((struct ebt_counter *)(((char *)c) + \ 47#define COUNTER_BASE(c, n, cpu) ((struct ebt_counter *)(((char *)c) + \
49 COUNTER_OFFSET(n) * cpu)) 48 COUNTER_OFFSET(n) * cpu))
50 49
51 50
52 51
@@ -126,7 +125,7 @@ ebt_dev_check(const char *entry, const struct net_device *device)
126/* process standard matches */ 125/* process standard matches */
127static inline int 126static inline int
128ebt_basic_match(const struct ebt_entry *e, const struct sk_buff *skb, 127ebt_basic_match(const struct ebt_entry *e, const struct sk_buff *skb,
129 const struct net_device *in, const struct net_device *out) 128 const struct net_device *in, const struct net_device *out)
130{ 129{
131 const struct ethhdr *h = eth_hdr(skb); 130 const struct ethhdr *h = eth_hdr(skb);
132 const struct net_bridge_port *p; 131 const struct net_bridge_port *p;
@@ -162,7 +161,7 @@ ebt_basic_match(const struct ebt_entry *e, const struct sk_buff *skb,
162 for (i = 0; i < 6; i++) 161 for (i = 0; i < 6; i++)
163 verdict |= (h->h_source[i] ^ e->sourcemac[i]) & 162 verdict |= (h->h_source[i] ^ e->sourcemac[i]) &
164 e->sourcemsk[i]; 163 e->sourcemsk[i];
165 if (FWINV2(verdict != 0, EBT_ISOURCE) ) 164 if (FWINV2(verdict != 0, EBT_ISOURCE))
166 return 1; 165 return 1;
167 } 166 }
168 if (e->bitmask & EBT_DESTMAC) { 167 if (e->bitmask & EBT_DESTMAC) {
@@ -170,7 +169,7 @@ ebt_basic_match(const struct ebt_entry *e, const struct sk_buff *skb,
170 for (i = 0; i < 6; i++) 169 for (i = 0; i < 6; i++)
171 verdict |= (h->h_dest[i] ^ e->destmac[i]) & 170 verdict |= (h->h_dest[i] ^ e->destmac[i]) &
172 e->destmsk[i]; 171 e->destmsk[i];
173 if (FWINV2(verdict != 0, EBT_IDEST) ) 172 if (FWINV2(verdict != 0, EBT_IDEST))
174 return 1; 173 return 1;
175 } 174 }
176 return 0; 175 return 0;
@@ -237,7 +236,8 @@ unsigned int ebt_do_table(struct sk_buff *skb,
237 (*(counter_base + i)).bcnt += skb->len; 236 (*(counter_base + i)).bcnt += skb->len;
238 237
239 /* these should only watch: not modify, nor tell us 238 /* these should only watch: not modify, nor tell us
240 what to do with the packet */ 239 * what to do with the packet
240 */
241 EBT_WATCHER_ITERATE(point, ebt_do_watcher, skb, &acpar); 241 EBT_WATCHER_ITERATE(point, ebt_do_watcher, skb, &acpar);
242 242
243 t = (struct ebt_entry_target *) 243 t = (struct ebt_entry_target *)
@@ -323,7 +323,7 @@ letscontinue:
323/* If it succeeds, returns element and locks mutex */ 323/* If it succeeds, returns element and locks mutex */
324static inline void * 324static inline void *
325find_inlist_lock_noload(struct list_head *head, const char *name, int *error, 325find_inlist_lock_noload(struct list_head *head, const char *name, int *error,
326 struct mutex *mutex) 326 struct mutex *mutex)
327{ 327{
328 struct { 328 struct {
329 struct list_head list; 329 struct list_head list;
@@ -342,7 +342,7 @@ find_inlist_lock_noload(struct list_head *head, const char *name, int *error,
342 342
343static void * 343static void *
344find_inlist_lock(struct list_head *head, const char *name, const char *prefix, 344find_inlist_lock(struct list_head *head, const char *name, const char *prefix,
345 int *error, struct mutex *mutex) 345 int *error, struct mutex *mutex)
346{ 346{
347 return try_then_request_module( 347 return try_then_request_module(
348 find_inlist_lock_noload(head, name, error, mutex), 348 find_inlist_lock_noload(head, name, error, mutex),
@@ -451,7 +451,8 @@ static int ebt_verify_pointers(const struct ebt_replace *repl,
451 if (i != NF_BR_NUMHOOKS || !(e->bitmask & EBT_ENTRY_OR_ENTRIES)) { 451 if (i != NF_BR_NUMHOOKS || !(e->bitmask & EBT_ENTRY_OR_ENTRIES)) {
452 if (e->bitmask != 0) { 452 if (e->bitmask != 0) {
453 /* we make userspace set this right, 453 /* we make userspace set this right,
454 so there is no misunderstanding */ 454 * so there is no misunderstanding
455 */
455 BUGPRINT("EBT_ENTRY_OR_ENTRIES shouldn't be set " 456 BUGPRINT("EBT_ENTRY_OR_ENTRIES shouldn't be set "
456 "in distinguisher\n"); 457 "in distinguisher\n");
457 return -EINVAL; 458 return -EINVAL;
@@ -487,15 +488,14 @@ static int ebt_verify_pointers(const struct ebt_replace *repl,
487 return 0; 488 return 0;
488} 489}
489 490
490/* 491/* this one is very careful, as it is the first function
491 * this one is very careful, as it is the first function
492 * to parse the userspace data 492 * to parse the userspace data
493 */ 493 */
494static inline int 494static inline int
495ebt_check_entry_size_and_hooks(const struct ebt_entry *e, 495ebt_check_entry_size_and_hooks(const struct ebt_entry *e,
496 const struct ebt_table_info *newinfo, 496 const struct ebt_table_info *newinfo,
497 unsigned int *n, unsigned int *cnt, 497 unsigned int *n, unsigned int *cnt,
498 unsigned int *totalcnt, unsigned int *udc_cnt) 498 unsigned int *totalcnt, unsigned int *udc_cnt)
499{ 499{
500 int i; 500 int i;
501 501
@@ -504,10 +504,12 @@ ebt_check_entry_size_and_hooks(const struct ebt_entry *e,
504 break; 504 break;
505 } 505 }
506 /* beginning of a new chain 506 /* beginning of a new chain
507 if i == NF_BR_NUMHOOKS it must be a user defined chain */ 507 * if i == NF_BR_NUMHOOKS it must be a user defined chain
508 */
508 if (i != NF_BR_NUMHOOKS || !e->bitmask) { 509 if (i != NF_BR_NUMHOOKS || !e->bitmask) {
509 /* this checks if the previous chain has as many entries 510 /* this checks if the previous chain has as many entries
510 as it said it has */ 511 * as it said it has
512 */
511 if (*n != *cnt) { 513 if (*n != *cnt) {
512 BUGPRINT("nentries does not equal the nr of entries " 514 BUGPRINT("nentries does not equal the nr of entries "
513 "in the chain\n"); 515 "in the chain\n");
@@ -549,20 +551,18 @@ ebt_check_entry_size_and_hooks(const struct ebt_entry *e,
549 return 0; 551 return 0;
550} 552}
551 553
552struct ebt_cl_stack 554struct ebt_cl_stack {
553{
554 struct ebt_chainstack cs; 555 struct ebt_chainstack cs;
555 int from; 556 int from;
556 unsigned int hookmask; 557 unsigned int hookmask;
557}; 558};
558 559
559/* 560/* We need these positions to check that the jumps to a different part of the
560 * we need these positions to check that the jumps to a different part of the
561 * entries is a jump to the beginning of a new chain. 561 * entries is a jump to the beginning of a new chain.
562 */ 562 */
563static inline int 563static inline int
564ebt_get_udc_positions(struct ebt_entry *e, struct ebt_table_info *newinfo, 564ebt_get_udc_positions(struct ebt_entry *e, struct ebt_table_info *newinfo,
565 unsigned int *n, struct ebt_cl_stack *udc) 565 unsigned int *n, struct ebt_cl_stack *udc)
566{ 566{
567 int i; 567 int i;
568 568
@@ -649,9 +649,9 @@ ebt_cleanup_entry(struct ebt_entry *e, struct net *net, unsigned int *cnt)
649 649
650static inline int 650static inline int
651ebt_check_entry(struct ebt_entry *e, struct net *net, 651ebt_check_entry(struct ebt_entry *e, struct net *net,
652 const struct ebt_table_info *newinfo, 652 const struct ebt_table_info *newinfo,
653 const char *name, unsigned int *cnt, 653 const char *name, unsigned int *cnt,
654 struct ebt_cl_stack *cl_s, unsigned int udc_cnt) 654 struct ebt_cl_stack *cl_s, unsigned int udc_cnt)
655{ 655{
656 struct ebt_entry_target *t; 656 struct ebt_entry_target *t;
657 struct xt_target *target; 657 struct xt_target *target;
@@ -673,7 +673,7 @@ ebt_check_entry(struct ebt_entry *e, struct net *net,
673 BUGPRINT("Unknown flag for inv bitmask\n"); 673 BUGPRINT("Unknown flag for inv bitmask\n");
674 return -EINVAL; 674 return -EINVAL;
675 } 675 }
676 if ( (e->bitmask & EBT_NOPROTO) && (e->bitmask & EBT_802_3) ) { 676 if ((e->bitmask & EBT_NOPROTO) && (e->bitmask & EBT_802_3)) {
677 BUGPRINT("NOPROTO & 802_3 not allowed\n"); 677 BUGPRINT("NOPROTO & 802_3 not allowed\n");
678 return -EINVAL; 678 return -EINVAL;
679 } 679 }
@@ -687,7 +687,8 @@ ebt_check_entry(struct ebt_entry *e, struct net *net,
687 break; 687 break;
688 } 688 }
689 /* (1 << NF_BR_NUMHOOKS) tells the check functions the rule is on 689 /* (1 << NF_BR_NUMHOOKS) tells the check functions the rule is on
690 a base chain */ 690 * a base chain
691 */
691 if (i < NF_BR_NUMHOOKS) 692 if (i < NF_BR_NUMHOOKS)
692 hookmask = (1 << hook) | (1 << NF_BR_NUMHOOKS); 693 hookmask = (1 << hook) | (1 << NF_BR_NUMHOOKS);
693 else { 694 else {
@@ -758,13 +759,12 @@ cleanup_matches:
758 return ret; 759 return ret;
759} 760}
760 761
761/* 762/* checks for loops and sets the hook mask for udc
762 * checks for loops and sets the hook mask for udc
763 * the hook mask for udc tells us from which base chains the udc can be 763 * the hook mask for udc tells us from which base chains the udc can be
764 * accessed. This mask is a parameter to the check() functions of the extensions 764 * accessed. This mask is a parameter to the check() functions of the extensions
765 */ 765 */
766static int check_chainloops(const struct ebt_entries *chain, struct ebt_cl_stack *cl_s, 766static int check_chainloops(const struct ebt_entries *chain, struct ebt_cl_stack *cl_s,
767 unsigned int udc_cnt, unsigned int hooknr, char *base) 767 unsigned int udc_cnt, unsigned int hooknr, char *base)
768{ 768{
769 int i, chain_nr = -1, pos = 0, nentries = chain->nentries, verdict; 769 int i, chain_nr = -1, pos = 0, nentries = chain->nentries, verdict;
770 const struct ebt_entry *e = (struct ebt_entry *)chain->data; 770 const struct ebt_entry *e = (struct ebt_entry *)chain->data;
@@ -853,7 +853,8 @@ static int translate_table(struct net *net, const char *name,
853 return -EINVAL; 853 return -EINVAL;
854 } 854 }
855 /* make sure chains are ordered after each other in same order 855 /* make sure chains are ordered after each other in same order
856 as their corresponding hooks */ 856 * as their corresponding hooks
857 */
857 for (j = i + 1; j < NF_BR_NUMHOOKS; j++) { 858 for (j = i + 1; j < NF_BR_NUMHOOKS; j++) {
858 if (!newinfo->hook_entry[j]) 859 if (!newinfo->hook_entry[j])
859 continue; 860 continue;
@@ -868,7 +869,8 @@ static int translate_table(struct net *net, const char *name,
868 i = 0; /* holds the expected nr. of entries for the chain */ 869 i = 0; /* holds the expected nr. of entries for the chain */
869 j = 0; /* holds the up to now counted entries for the chain */ 870 j = 0; /* holds the up to now counted entries for the chain */
870 k = 0; /* holds the total nr. of entries, should equal 871 k = 0; /* holds the total nr. of entries, should equal
871 newinfo->nentries afterwards */ 872 * newinfo->nentries afterwards
873 */
872 udc_cnt = 0; /* will hold the nr. of user defined chains (udc) */ 874 udc_cnt = 0; /* will hold the nr. of user defined chains (udc) */
873 ret = EBT_ENTRY_ITERATE(newinfo->entries, newinfo->entries_size, 875 ret = EBT_ENTRY_ITERATE(newinfo->entries, newinfo->entries_size,
874 ebt_check_entry_size_and_hooks, newinfo, 876 ebt_check_entry_size_and_hooks, newinfo,
@@ -888,10 +890,12 @@ static int translate_table(struct net *net, const char *name,
888 } 890 }
889 891
890 /* get the location of the udc, put them in an array 892 /* get the location of the udc, put them in an array
891 while we're at it, allocate the chainstack */ 893 * while we're at it, allocate the chainstack
894 */
892 if (udc_cnt) { 895 if (udc_cnt) {
893 /* this will get free'd in do_replace()/ebt_register_table() 896 /* this will get free'd in do_replace()/ebt_register_table()
894 if an error occurs */ 897 * if an error occurs
898 */
895 newinfo->chainstack = 899 newinfo->chainstack =
896 vmalloc(nr_cpu_ids * sizeof(*(newinfo->chainstack))); 900 vmalloc(nr_cpu_ids * sizeof(*(newinfo->chainstack)));
897 if (!newinfo->chainstack) 901 if (!newinfo->chainstack)
@@ -932,14 +936,15 @@ static int translate_table(struct net *net, const char *name,
932 } 936 }
933 937
934 /* we now know the following (along with E=mc²): 938 /* we now know the following (along with E=mc²):
935 - the nr of entries in each chain is right 939 * - the nr of entries in each chain is right
936 - the size of the allocated space is right 940 * - the size of the allocated space is right
937 - all valid hooks have a corresponding chain 941 * - all valid hooks have a corresponding chain
938 - there are no loops 942 * - there are no loops
939 - wrong data can still be on the level of a single entry 943 * - wrong data can still be on the level of a single entry
940 - could be there are jumps to places that are not the 944 * - could be there are jumps to places that are not the
941 beginning of a chain. This can only occur in chains that 945 * beginning of a chain. This can only occur in chains that
942 are not accessible from any base chains, so we don't care. */ 946 * are not accessible from any base chains, so we don't care.
947 */
943 948
944 /* used to know what we need to clean up if something goes wrong */ 949 /* used to know what we need to clean up if something goes wrong */
945 i = 0; 950 i = 0;
@@ -955,7 +960,7 @@ static int translate_table(struct net *net, const char *name,
955 960
956/* called under write_lock */ 961/* called under write_lock */
957static void get_counters(const struct ebt_counter *oldcounters, 962static void get_counters(const struct ebt_counter *oldcounters,
958 struct ebt_counter *counters, unsigned int nentries) 963 struct ebt_counter *counters, unsigned int nentries)
959{ 964{
960 int i, cpu; 965 int i, cpu;
961 struct ebt_counter *counter_base; 966 struct ebt_counter *counter_base;
@@ -986,7 +991,8 @@ static int do_replace_finish(struct net *net, struct ebt_replace *repl,
986 struct ebt_table *t; 991 struct ebt_table *t;
987 992
988 /* the user wants counters back 993 /* the user wants counters back
989 the check on the size is done later, when we have the lock */ 994 * the check on the size is done later, when we have the lock
995 */
990 if (repl->num_counters) { 996 if (repl->num_counters) {
991 unsigned long size = repl->num_counters * sizeof(*counterstmp); 997 unsigned long size = repl->num_counters * sizeof(*counterstmp);
992 counterstmp = vmalloc(size); 998 counterstmp = vmalloc(size);
@@ -1038,9 +1044,10 @@ static int do_replace_finish(struct net *net, struct ebt_replace *repl,
1038 write_unlock_bh(&t->lock); 1044 write_unlock_bh(&t->lock);
1039 mutex_unlock(&ebt_mutex); 1045 mutex_unlock(&ebt_mutex);
1040 /* so, a user can change the chains while having messed up her counter 1046 /* so, a user can change the chains while having messed up her counter
1041 allocation. Only reason why this is done is because this way the lock 1047 * allocation. Only reason why this is done is because this way the lock
1042 is held only once, while this doesn't bring the kernel into a 1048 * is held only once, while this doesn't bring the kernel into a
1043 dangerous state. */ 1049 * dangerous state.
1050 */
1044 if (repl->num_counters && 1051 if (repl->num_counters &&
1045 copy_to_user(repl->counters, counterstmp, 1052 copy_to_user(repl->counters, counterstmp,
1046 repl->num_counters * sizeof(struct ebt_counter))) { 1053 repl->num_counters * sizeof(struct ebt_counter))) {
@@ -1342,13 +1349,14 @@ static int update_counters(struct net *net, const void __user *user,
1342} 1349}
1343 1350
1344static inline int ebt_make_matchname(const struct ebt_entry_match *m, 1351static inline int ebt_make_matchname(const struct ebt_entry_match *m,
1345 const char *base, char __user *ubase) 1352 const char *base, char __user *ubase)
1346{ 1353{
1347 char __user *hlp = ubase + ((char *)m - base); 1354 char __user *hlp = ubase + ((char *)m - base);
1348 char name[EBT_FUNCTION_MAXNAMELEN] = {}; 1355 char name[EBT_FUNCTION_MAXNAMELEN] = {};
1349 1356
1350 /* ebtables expects 32 bytes long names but xt_match names are 29 bytes 1357 /* ebtables expects 32 bytes long names but xt_match names are 29 bytes
1351 long. Copy 29 bytes and fill remaining bytes with zeroes. */ 1358 * long. Copy 29 bytes and fill remaining bytes with zeroes.
1359 */
1352 strlcpy(name, m->u.match->name, sizeof(name)); 1360 strlcpy(name, m->u.match->name, sizeof(name));
1353 if (copy_to_user(hlp, name, EBT_FUNCTION_MAXNAMELEN)) 1361 if (copy_to_user(hlp, name, EBT_FUNCTION_MAXNAMELEN))
1354 return -EFAULT; 1362 return -EFAULT;
@@ -1356,19 +1364,19 @@ static inline int ebt_make_matchname(const struct ebt_entry_match *m,
1356} 1364}
1357 1365
1358static inline int ebt_make_watchername(const struct ebt_entry_watcher *w, 1366static inline int ebt_make_watchername(const struct ebt_entry_watcher *w,
1359 const char *base, char __user *ubase) 1367 const char *base, char __user *ubase)
1360{ 1368{
1361 char __user *hlp = ubase + ((char *)w - base); 1369 char __user *hlp = ubase + ((char *)w - base);
1362 char name[EBT_FUNCTION_MAXNAMELEN] = {}; 1370 char name[EBT_FUNCTION_MAXNAMELEN] = {};
1363 1371
1364 strlcpy(name, w->u.watcher->name, sizeof(name)); 1372 strlcpy(name, w->u.watcher->name, sizeof(name));
1365 if (copy_to_user(hlp , name, EBT_FUNCTION_MAXNAMELEN)) 1373 if (copy_to_user(hlp, name, EBT_FUNCTION_MAXNAMELEN))
1366 return -EFAULT; 1374 return -EFAULT;
1367 return 0; 1375 return 0;
1368} 1376}
1369 1377
1370static inline int 1378static inline int ebt_make_names(struct ebt_entry *e, const char *base,
1371ebt_make_names(struct ebt_entry *e, const char *base, char __user *ubase) 1379 char __user *ubase)
1372{ 1380{
1373 int ret; 1381 int ret;
1374 char __user *hlp; 1382 char __user *hlp;
@@ -1394,9 +1402,9 @@ ebt_make_names(struct ebt_entry *e, const char *base, char __user *ubase)
1394} 1402}
1395 1403
1396static int copy_counters_to_user(struct ebt_table *t, 1404static int copy_counters_to_user(struct ebt_table *t,
1397 const struct ebt_counter *oldcounters, 1405 const struct ebt_counter *oldcounters,
1398 void __user *user, unsigned int num_counters, 1406 void __user *user, unsigned int num_counters,
1399 unsigned int nentries) 1407 unsigned int nentries)
1400{ 1408{
1401 struct ebt_counter *counterstmp; 1409 struct ebt_counter *counterstmp;
1402 int ret = 0; 1410 int ret = 0;
@@ -1427,7 +1435,7 @@ static int copy_counters_to_user(struct ebt_table *t,
1427 1435
1428/* called with ebt_mutex locked */ 1436/* called with ebt_mutex locked */
1429static int copy_everything_to_user(struct ebt_table *t, void __user *user, 1437static int copy_everything_to_user(struct ebt_table *t, void __user *user,
1430 const int *len, int cmd) 1438 const int *len, int cmd)
1431{ 1439{
1432 struct ebt_replace tmp; 1440 struct ebt_replace tmp;
1433 const struct ebt_counter *oldcounters; 1441 const struct ebt_counter *oldcounters;
@@ -1595,8 +1603,7 @@ static int ebt_compat_entry_padsize(void)
1595static int ebt_compat_match_offset(const struct xt_match *match, 1603static int ebt_compat_match_offset(const struct xt_match *match,
1596 unsigned int userlen) 1604 unsigned int userlen)
1597{ 1605{
1598 /* 1606 /* ebt_among needs special handling. The kernel .matchsize is
1599 * ebt_among needs special handling. The kernel .matchsize is
1600 * set to -1 at registration time; at runtime an EBT_ALIGN()ed 1607 * set to -1 at registration time; at runtime an EBT_ALIGN()ed
1601 * value is expected. 1608 * value is expected.
1602 * Example: userspace sends 4500, ebt_among.c wants 4504. 1609 * Example: userspace sends 4500, ebt_among.c wants 4504.
@@ -1966,8 +1973,7 @@ static int compat_mtw_from_user(struct compat_ebt_entry_mwt *mwt,
1966 return off + match_size; 1973 return off + match_size;
1967} 1974}
1968 1975
1969/* 1976/* return size of all matches, watchers or target, including necessary
1970 * return size of all matches, watchers or target, including necessary
1971 * alignment and padding. 1977 * alignment and padding.
1972 */ 1978 */
1973static int ebt_size_mwt(struct compat_ebt_entry_mwt *match32, 1979static int ebt_size_mwt(struct compat_ebt_entry_mwt *match32,
@@ -2070,8 +2076,7 @@ static int size_entry_mwt(struct ebt_entry *entry, const unsigned char *base,
2070 if (ret < 0) 2076 if (ret < 0)
2071 return ret; 2077 return ret;
2072 buf_start = (char *) entry; 2078 buf_start = (char *) entry;
2073 /* 2079 /* 0: matches offset, always follows ebt_entry.
2074 * 0: matches offset, always follows ebt_entry.
2075 * 1: watchers offset, from ebt_entry structure 2080 * 1: watchers offset, from ebt_entry structure
2076 * 2: target offset, from ebt_entry structure 2081 * 2: target offset, from ebt_entry structure
2077 * 3: next ebt_entry offset, from ebt_entry structure 2082 * 3: next ebt_entry offset, from ebt_entry structure
@@ -2115,8 +2120,7 @@ static int size_entry_mwt(struct ebt_entry *entry, const unsigned char *base,
2115 return 0; 2120 return 0;
2116} 2121}
2117 2122
2118/* 2123/* repl->entries_size is the size of the ebt_entry blob in userspace.
2119 * repl->entries_size is the size of the ebt_entry blob in userspace.
2120 * It might need more memory when copied to a 64 bit kernel in case 2124 * It might need more memory when copied to a 64 bit kernel in case
2121 * userspace is 32-bit. So, first task: find out how much memory is needed. 2125 * userspace is 32-bit. So, first task: find out how much memory is needed.
2122 * 2126 *
@@ -2305,7 +2309,7 @@ static int compat_do_ebt_set_ctl(struct sock *sk,
2305 break; 2309 break;
2306 default: 2310 default:
2307 ret = -EINVAL; 2311 ret = -EINVAL;
2308 } 2312 }
2309 return ret; 2313 return ret;
2310} 2314}
2311 2315
@@ -2360,8 +2364,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
2360 break; 2364 break;
2361 case EBT_SO_GET_ENTRIES: 2365 case EBT_SO_GET_ENTRIES:
2362 case EBT_SO_GET_INIT_ENTRIES: 2366 case EBT_SO_GET_INIT_ENTRIES:
2363 /* 2367 /* try real handler first in case of userland-side padding.
2364 * try real handler first in case of userland-side padding.
2365 * in case we are dealing with an 'ordinary' 32 bit binary 2368 * in case we are dealing with an 'ordinary' 32 bit binary
2366 * without 64bit compatibility padding, this will fail right 2369 * without 64bit compatibility padding, this will fail right
2367 * after copy_from_user when the *len argument is validated. 2370 * after copy_from_user when the *len argument is validated.
diff --git a/net/bridge/netfilter/nft_meta_bridge.c b/net/bridge/netfilter/nft_meta_bridge.c
index a21269b83f16..4b901d9f2e7c 100644
--- a/net/bridge/netfilter/nft_meta_bridge.c
+++ b/net/bridge/netfilter/nft_meta_bridge.c
@@ -84,6 +84,7 @@ static const struct nft_expr_ops nft_meta_bridge_set_ops = {
84 .size = NFT_EXPR_SIZE(sizeof(struct nft_meta)), 84 .size = NFT_EXPR_SIZE(sizeof(struct nft_meta)),
85 .eval = nft_meta_set_eval, 85 .eval = nft_meta_set_eval,
86 .init = nft_meta_set_init, 86 .init = nft_meta_set_init,
87 .destroy = nft_meta_set_destroy,
87 .dump = nft_meta_set_dump, 88 .dump = nft_meta_set_dump,
88}; 89};
89 90