Skip to content

Commit 6bc803b

Browse files
Florian Westphalgregkh
authored andcommitted
netfilter: x_tables: kill check_entry helper
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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent cfdca13 commit 6bc803b

3 files changed

Lines changed: 24 additions & 35 deletions

File tree

net/ipv4/netfilter/arp_tables.c

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -494,14 +494,6 @@ static int mark_source_chains(const struct xt_table_info *newinfo,
494494
return 1;
495495
}
496496

497-
static inline int check_entry(const struct arpt_entry *e)
498-
{
499-
if (!arp_checkentry(&e->arp))
500-
return -EINVAL;
501-
502-
return xt_check_entry_offsets(e, e->target_offset, e->next_offset);
503-
}
504-
505497
static inline int check_target(struct arpt_entry *e, const char *name)
506498
{
507499
struct xt_entry_target *t = arpt_get_target(e);
@@ -597,7 +589,10 @@ static inline int check_entry_size_and_hooks(struct arpt_entry *e,
597589
return -EINVAL;
598590
}
599591

600-
err = check_entry(e);
592+
if (!arp_checkentry(&e->arp))
593+
return -EINVAL;
594+
595+
err = xt_check_entry_offsets(e, e->target_offset, e->next_offset);
601596
if (err)
602597
return err;
603598

@@ -1255,8 +1250,10 @@ check_compat_entry_size_and_hooks(struct compat_arpt_entry *e,
12551250
return -EINVAL;
12561251
}
12571252

1258-
/* For purposes of check_entry casting the compat entry is fine */
1259-
ret = check_entry((struct arpt_entry *)e);
1253+
if (!arp_checkentry(&e->arp))
1254+
return -EINVAL;
1255+
1256+
ret = xt_check_entry_offsets(e, e->target_offset, e->next_offset);
12601257
if (ret)
12611258
return ret;
12621259

net/ipv4/netfilter/ip_tables.c

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -587,15 +587,6 @@ static void cleanup_match(struct xt_entry_match *m, struct net *net)
587587
module_put(par.match->me);
588588
}
589589

590-
static int
591-
check_entry(const struct ipt_entry *e)
592-
{
593-
if (!ip_checkentry(&e->ip))
594-
return -EINVAL;
595-
596-
return xt_check_entry_offsets(e, e->target_offset, e->next_offset);
597-
}
598-
599590
static int
600591
check_match(struct xt_entry_match *m, struct xt_mtchk_param *par)
601592
{
@@ -760,7 +751,10 @@ check_entry_size_and_hooks(struct ipt_entry *e,
760751
return -EINVAL;
761752
}
762753

763-
err = check_entry(e);
754+
if (!ip_checkentry(&e->ip))
755+
return -EINVAL;
756+
757+
err = xt_check_entry_offsets(e, e->target_offset, e->next_offset);
764758
if (err)
765759
return err;
766760

@@ -1515,8 +1509,10 @@ check_compat_entry_size_and_hooks(struct compat_ipt_entry *e,
15151509
return -EINVAL;
15161510
}
15171511

1518-
/* For purposes of check_entry casting the compat entry is fine */
1519-
ret = check_entry((struct ipt_entry *)e);
1512+
if (!ip_checkentry(&e->ip))
1513+
return -EINVAL;
1514+
1515+
ret = xt_check_entry_offsets(e, e->target_offset, e->next_offset);
15201516
if (ret)
15211517
return ret;
15221518

net/ipv6/netfilter/ip6_tables.c

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -599,15 +599,6 @@ static void cleanup_match(struct xt_entry_match *m, struct net *net)
599599
module_put(par.match->me);
600600
}
601601

602-
static int
603-
check_entry(const struct ip6t_entry *e)
604-
{
605-
if (!ip6_checkentry(&e->ipv6))
606-
return -EINVAL;
607-
608-
return xt_check_entry_offsets(e, e->target_offset, e->next_offset);
609-
}
610-
611602
static int check_match(struct xt_entry_match *m, struct xt_mtchk_param *par)
612603
{
613604
const struct ip6t_ip6 *ipv6 = par->entryinfo;
@@ -772,7 +763,10 @@ check_entry_size_and_hooks(struct ip6t_entry *e,
772763
return -EINVAL;
773764
}
774765

775-
err = check_entry(e);
766+
if (!ip6_checkentry(&e->ipv6))
767+
return -EINVAL;
768+
769+
err = xt_check_entry_offsets(e, e->target_offset, e->next_offset);
776770
if (err)
777771
return err;
778772

@@ -1527,8 +1521,10 @@ check_compat_entry_size_and_hooks(struct compat_ip6t_entry *e,
15271521
return -EINVAL;
15281522
}
15291523

1530-
/* For purposes of check_entry casting the compat entry is fine */
1531-
ret = check_entry((struct ip6t_entry *)e);
1524+
if (!ip6_checkentry(&e->ipv6))
1525+
return -EINVAL;
1526+
1527+
ret = xt_check_entry_offsets(e, e->target_offset, e->next_offset);
15321528
if (ret)
15331529
return ret;
15341530

0 commit comments

Comments
 (0)