]> git.hungrycats.org Git - linux/commitdiff
netfilter: x_tables: kill check_entry helper
authorFlorian Westphal <fw@strlen.de>
Fri, 1 Apr 2016 12:17:24 +0000 (14:17 +0200)
committerBen Hutchings <ben@decadent.org.uk>
Mon, 22 Aug 2016 21:38:29 +0000 (22:38 +0100)
commit aa412ba225dd3bc36d404c28cdc3d674850d80d0 upstream.

Once we add more sanity testing to xt_check_entry_offsets it
becomes relvant if we're expecting a 32bit 'config_compat' blob
or a normal one.

Since we already have a lot of similar-named functions (check_entry,
compat_check_entry, find_and_check_entry, etc.) and the current
incarnation is short just fold its contents into the callers.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
net/ipv4/netfilter/arp_tables.c
net/ipv4/netfilter/ip_tables.c
net/ipv6/netfilter/ip6_tables.c

index 1f7fa3b8c5028cb2686329fcb5c42f9f4640005d..0c7022671ef47c5795e8a527a57c5cf27fcee4c0 100644 (file)
@@ -474,14 +474,6 @@ static int mark_source_chains(const struct xt_table_info *newinfo,
        return 1;
 }
 
-static inline int check_entry(const struct arpt_entry *e)
-{
-       if (!arp_checkentry(&e->arp))
-               return -EINVAL;
-
-       return xt_check_entry_offsets(e, e->target_offset, e->next_offset);
-}
-
 static inline int check_target(struct arpt_entry *e, const char *name)
 {
        struct xt_entry_target *t = arpt_get_target(e);
@@ -571,7 +563,10 @@ static inline int check_entry_size_and_hooks(struct arpt_entry *e,
                return -EINVAL;
        }
 
-       err = check_entry(e);
+       if (!arp_checkentry(&e->arp))
+               return -EINVAL;
+
+       err = xt_check_entry_offsets(e, e->target_offset, e->next_offset);
        if (err)
                return err;
 
@@ -1230,8 +1225,10 @@ check_compat_entry_size_and_hooks(struct compat_arpt_entry *e,
                return -EINVAL;
        }
 
-       /* For purposes of check_entry casting the compat entry is fine */
-       ret = check_entry((struct arpt_entry *)e);
+       if (!arp_checkentry(&e->arp))
+               return -EINVAL;
+
+       ret = xt_check_entry_offsets(e, e->target_offset, e->next_offset);
        if (ret)
                return ret;
 
index 266548ddaf3e5f4f982d31f815e553670fee08a0..5835d11d15450b0c66fd4efc777bfa139af697bd 100644 (file)
@@ -567,15 +567,6 @@ static void cleanup_match(struct xt_entry_match *m, struct net *net)
        module_put(par.match->me);
 }
 
-static int
-check_entry(const struct ipt_entry *e)
-{
-       if (!ip_checkentry(&e->ip))
-               return -EINVAL;
-
-       return xt_check_entry_offsets(e, e->target_offset, e->next_offset);
-}
-
 static int
 check_match(struct xt_entry_match *m, struct xt_mtchk_param *par)
 {
@@ -732,7 +723,10 @@ check_entry_size_and_hooks(struct ipt_entry *e,
                return -EINVAL;
        }
 
-       err = check_entry(e);
+       if (!ip_checkentry(&e->ip))
+               return -EINVAL;
+
+       err = xt_check_entry_offsets(e, e->target_offset, e->next_offset);
        if (err)
                return err;
 
@@ -1496,8 +1490,10 @@ check_compat_entry_size_and_hooks(struct compat_ipt_entry *e,
                return -EINVAL;
        }
 
-       /* For purposes of check_entry casting the compat entry is fine */
-       ret = check_entry((struct ipt_entry *)e);
+       if (!ip_checkentry(&e->ip))
+               return -EINVAL;
+
+       ret = xt_check_entry_offsets(e, e->target_offset, e->next_offset);
        if (ret)
                return ret;
 
index 67f5f8beea0d3193b8977da0d5de7ea27cb1c8f5..5ce8abd74810ac1337bd41c17fe539c1f50e1d8c 100644 (file)
@@ -577,15 +577,6 @@ static void cleanup_match(struct xt_entry_match *m, struct net *net)
        module_put(par.match->me);
 }
 
-static int
-check_entry(const struct ip6t_entry *e)
-{
-       if (!ip6_checkentry(&e->ipv6))
-               return -EINVAL;
-
-       return xt_check_entry_offsets(e, e->target_offset, e->next_offset);
-}
-
 static int check_match(struct xt_entry_match *m, struct xt_mtchk_param *par)
 {
        const struct ip6t_ip6 *ipv6 = par->entryinfo;
@@ -743,7 +734,10 @@ check_entry_size_and_hooks(struct ip6t_entry *e,
                return -EINVAL;
        }
 
-       err = check_entry(e);
+       if (!ip6_checkentry(&e->ipv6))
+               return -EINVAL;
+
+       err = xt_check_entry_offsets(e, e->target_offset, e->next_offset);
        if (err)
                return err;
 
@@ -1508,8 +1502,10 @@ check_compat_entry_size_and_hooks(struct compat_ip6t_entry *e,
                return -EINVAL;
        }
 
-       /* For purposes of check_entry casting the compat entry is fine */
-       ret = check_entry((struct ip6t_entry *)e);
+       if (!ip6_checkentry(&e->ipv6))
+               return -EINVAL;
+
+       ret = xt_check_entry_offsets(e, e->target_offset, e->next_offset);
        if (ret)
                return ret;